--- a/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
498124337041ad53cbaa7eb110f3d7acd6d4eac4 jdk8-b23
7d3720d8c595d1519c31e9ff7366203fc2c61350 jdk8-b24
0071a6d64113a35ba345bb1580c256de5ce17d3e jdk8-b25
+6c805d8ed4e5449ea5e4d158c7bdbd7b0b70efd1 jdk8-b26
+c51754cddc037b9609e202b9ed38363d8683e7a8 jdk8-b27
--- a/.hgtags-top-repo Thu Mar 01 15:31:33 2012 -0800
+++ b/.hgtags-top-repo Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
60d6f64a86b1e511169d264727f6d51415978df0 jdk8-b23
1a5f1d6b98d6827cdb529a4abe6e52a886d944f4 jdk8-b24
221a378e06a326f45e5d89e2123cd6323e0181d1 jdk8-b25
+2accafff224ae39caf5f532c305251ba624bf2c0 jdk8-b26
+1533dfab9903e4edcfead3b0192643f38c418b9b jdk8-b27
--- a/corba/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/corba/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
5218eb256658442b62b05295aafa5b5f35252972 jdk8-b23
b98f0e6dddf987df565029a1f58417fc1844c3f3 jdk8-b24
e45d6b406d5f91ff5256a5c82456ab1e7eb8becd jdk8-b25
+79f709a099f40c08f76567fa6d813f9009a69826 jdk8-b26
+4fffe75e4edd39a2517f10b743941bf94edb143d jdk8-b27
--- a/corba/src/share/classes/com/sun/corba/se/impl/dynamicany/DynAnyFactoryImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/corba/src/share/classes/com/sun/corba/se/impl/dynamicany/DynAnyFactoryImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -82,6 +82,6 @@
private String[] __ids = { "IDL:omg.org/DynamicAny/DynAnyFactory:1.0" };
public String[] _ids() {
- return __ids;
+ return (String[]) __ids.clone();
}
}
--- a/corba/src/share/classes/com/sun/corba/se/impl/dynamicany/DynAnyImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/corba/src/share/classes/com/sun/corba/se/impl/dynamicany/DynAnyImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -195,6 +195,6 @@
private String[] __ids = { "IDL:omg.org/DynamicAny/DynAny:1.0" };
public String[] _ids() {
- return __ids;
+ return (String[]) __ids.clone();
}
}
--- a/corba/src/share/classes/com/sun/org/omg/SendingContext/_CodeBaseImplBase.java Thu Mar 01 15:31:33 2012 -0800
+++ b/corba/src/share/classes/com/sun/org/omg/SendingContext/_CodeBaseImplBase.java Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -138,7 +138,7 @@
public String[] _ids ()
{
- return __ids;
+ return (String[]) __ids.clone();
}
--- a/hotspot/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -222,3 +222,7 @@
d71e662fe03741b6de498ca2077220148405a978 hs23-b15
fd3060701216a11c0df6dcd053c6fd7c2b17a42c jdk8-b26
f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16
+f92a171cf0071ca6c3fa8231d7d570377f8b2f4d hs23-b16
+931e5f39e365a0d550d79148ff87a7f9e864d2e1 hs23-b16
+3b24e7e01d20ca590d0f86b1222bb7c3f1a2aa2d jdk8-b27
+975c4105f1e2ef1190a75b77124033f1fd4290b5 hs24-b01
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java Fri Mar 02 09:13:13 2012 -0800
@@ -648,7 +648,12 @@
}
public void printValueOn(PrintStream tty) {
- tty.print("ConstantPool for " + getPoolHolder().getName().asString());
+ Oop holder = poolHolder.getValue(this);
+ if (holder instanceof Klass) {
+ tty.print("ConstantPool for " + ((Klass)holder).getName().asString());
+ } else {
+ tty.print("ConstantPool for partially loaded class");
+ }
}
public long getObjectSize() {
--- a/hotspot/make/bsd/makefiles/buildtree.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/bsd/makefiles/buildtree.make Fri Mar 02 09:13:13 2012 -0800
@@ -58,6 +58,7 @@
# needs to be set here since this Makefile doesn't include defs.make
OS_VENDOR:=$(shell uname -s)
+-include $(SPEC)
include $(GAMMADIR)/make/scm.make
include $(GAMMADIR)/make/altsrc.make
@@ -247,6 +248,8 @@
echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
echo; \
+ [ -n "$(SPEC)" ] && \
+ echo "include $(SPEC)"; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
) > $@
--- a/hotspot/make/bsd/makefiles/gcc.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/bsd/makefiles/gcc.make Fri Mar 02 09:13:13 2012 -0800
@@ -27,53 +27,57 @@
#------------------------------------------------------------------------
# CC, CXX & AS
-# When cross-compiling the ALT_COMPILER_PATH points
-# to the cross-compilation toolset
-ifdef CROSS_COMPILE_ARCH
- CXX = $(ALT_COMPILER_PATH)/g++
- CC = $(ALT_COMPILER_PATH)/gcc
- HOSTCXX = g++
- HOSTCC = gcc
-else ifneq ($(OS_VENDOR), Darwin)
- CXX = g++
- CC = gcc
- HOSTCXX = $(CXX)
- HOSTCC = $(CC)
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+ # When cross-compiling the ALT_COMPILER_PATH points
+ # to the cross-compilation toolset
+ ifdef CROSS_COMPILE_ARCH
+ CXX = $(ALT_COMPILER_PATH)/g++
+ CC = $(ALT_COMPILER_PATH)/gcc
+ HOSTCXX = g++
+ HOSTCC = gcc
+ else ifneq ($(OS_VENDOR), Darwin)
+ CXX = g++
+ CC = gcc
+ HOSTCXX = $(CXX)
+ HOSTCC = $(CC)
+ endif
+
+ # i486 hotspot requires -mstackrealign on Darwin.
+ # llvm-gcc supports this in Xcode 3.2.6 and 4.0.
+ # gcc-4.0 supports this on earlier versions.
+ # Prefer llvm-gcc where available.
+ ifeq ($(OS_VENDOR), Darwin)
+ ifeq ($(origin CXX), default)
+ CXX = llvm-g++
+ endif
+ ifeq ($(origin CC), default)
+ CC = llvm-gcc
+ endif
+
+ ifeq ($(ARCH), i486)
+ LLVM_SUPPORTS_STACKREALIGN := $(shell \
+ [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
+ && echo true || echo false)
+
+ ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
+ CXX32 ?= llvm-g++
+ CC32 ?= llvm-gcc
+ else
+ CXX32 ?= g++-4.0
+ CC32 ?= gcc-4.0
+ endif
+ CXX = $(CXX32)
+ CC = $(CC32)
+ endif
+
+ HOSTCXX = $(CXX)
+ HOSTCC = $(CC)
+ endif
+
+ AS = $(CC) -c -x assembler-with-cpp
endif
-# i486 hotspot requires -mstackrealign on Darwin.
-# llvm-gcc supports this in Xcode 3.2.6 and 4.0.
-# gcc-4.0 supports this on earlier versions.
-# Prefer llvm-gcc where available.
-ifeq ($(OS_VENDOR), Darwin)
- ifeq ($(origin CXX), default)
- CXX = llvm-g++
- endif
- ifeq ($(origin CC), default)
- CC = llvm-gcc
- endif
-
- ifeq ($(ARCH), i486)
- LLVM_SUPPORTS_STACKREALIGN := $(shell \
- [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \
- && echo true || echo false)
-
- ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true)
- CXX32 ?= llvm-g++
- CC32 ?= llvm-gcc
- else
- CXX32 ?= g++-4.0
- CC32 ?= gcc-4.0
- endif
- CXX = $(CXX32)
- CC = $(CC32)
- endif
-
- HOSTCXX = $(CXX)
- HOSTCC = $(CC)
-endif
-
-AS = $(CC) -c -x assembler-with-cpp
# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
# prints the numbers (e.g. "2.95", "3.2.1")
--- a/hotspot/make/bsd/makefiles/sparcWorks.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/bsd/makefiles/sparcWorks.make Fri Mar 02 09:13:13 2012 -0800
@@ -25,12 +25,15 @@
#------------------------------------------------------------------------
# CC, CXX & AS
-CXX = CC
-CC = cc
-AS = $(CC) -c
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+ CXX = CC
+ CC = cc
+ AS = $(CC) -c
-HOSTCXX = $(CXX)
-HOSTCC = $(CC)
+ HOSTCXX = $(CXX)
+ HOSTCC = $(CC)
+endif
ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
ARCHFLAG/i486 = -m32
--- a/hotspot/make/defs.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/defs.make Fri Mar 02 09:13:13 2012 -0800
@@ -24,6 +24,11 @@
# The common definitions for hotspot builds.
+# Optionally include SPEC file generated by configure.
+ifneq ($(SPEC),)
+ include $(SPEC)
+endif
+
# Default to verbose build logs (show all compile lines):
MAKE_VERBOSE=y
--- a/hotspot/make/hotspot_version Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/hotspot_version Fri Mar 02 09:13:13 2012 -0800
@@ -35,7 +35,7 @@
HS_MAJOR_VER=24
HS_MINOR_VER=0
-HS_BUILD_NUMBER=01
+HS_BUILD_NUMBER=02
JDK_MAJOR_VER=1
JDK_MINOR_VER=8
--- a/hotspot/make/linux/makefiles/buildtree.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/linux/makefiles/buildtree.make Fri Mar 02 09:13:13 2012 -0800
@@ -55,6 +55,7 @@
# The makefiles are split this way so that "make foo" will run faster by not
# having to read the dependency files for the vm.
+-include $(SPEC)
include $(GAMMADIR)/make/scm.make
include $(GAMMADIR)/make/altsrc.make
@@ -244,6 +245,8 @@
echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
echo; \
+ [ -n "$(SPEC)" ] && \
+ echo "include $(SPEC)"; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
) > $@
--- a/hotspot/make/linux/makefiles/gcc.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/linux/makefiles/gcc.make Fri Mar 02 09:13:13 2012 -0800
@@ -25,21 +25,26 @@
#------------------------------------------------------------------------
# CC, CXX & AS
-# When cross-compiling the ALT_COMPILER_PATH points
-# to the cross-compilation toolset
-ifdef CROSS_COMPILE_ARCH
-CXX = $(ALT_COMPILER_PATH)/g++
-CC = $(ALT_COMPILER_PATH)/gcc
-HOSTCXX = g++
-HOSTCC = gcc
-else
-CXX = g++
-CC = gcc
-HOSTCXX = $(CXX)
-HOSTCC = $(CC)
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+ # When cross-compiling the ALT_COMPILER_PATH points
+ # to the cross-compilation toolset
+ ifdef CROSS_COMPILE_ARCH
+ CXX = $(ALT_COMPILER_PATH)/g++
+ CC = $(ALT_COMPILER_PATH)/gcc
+ HOSTCXX = g++
+ HOSTCC = gcc
+ STRIP = $(ALT_COMPILER_PATH)/strip
+ else
+ CXX = g++
+ CC = gcc
+ HOSTCXX = $(CXX)
+ HOSTCC = $(CC)
+ STRIP = strip
+ endif
+ AS = $(CC) -c
endif
-AS = $(CC) -c
# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only
# prints the numbers (e.g. "2.95", "3.2.1")
@@ -261,9 +266,3 @@
ifdef MINIMIZE_RAM_USAGE
CFLAGS += -DMINIMIZE_RAM_USAGE
endif
-
-ifdef CROSS_COMPILE_ARCH
- STRIP = $(ALT_COMPILER_PATH)/strip
-else
- STRIP = strip
-endif
--- a/hotspot/make/linux/makefiles/ppc.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/linux/makefiles/ppc.make Fri Mar 02 09:13:13 2012 -0800
@@ -28,3 +28,6 @@
# Must also specify if CPU is big endian
CFLAGS += -DVM_BIG_ENDIAN
+ifdef E500V2
+ASFLAGS += -Wa,-mspe -Wa,--defsym -Wa,E500V2=1
+endif
--- a/hotspot/make/linux/makefiles/sparcWorks.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/linux/makefiles/sparcWorks.make Fri Mar 02 09:13:13 2012 -0800
@@ -25,12 +25,15 @@
#------------------------------------------------------------------------
# CC, CXX & AS
-CXX = CC
-CC = cc
-AS = $(CC) -c
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+ CXX = CC
+ CC = cc
+ AS = $(CC) -c
-HOSTCXX = $(CXX)
-HOSTCC = $(CC)
+ HOSTCXX = $(CXX)
+ HOSTCC = $(CC)
+endif
ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
ARCHFLAG/i486 = -m32
--- a/hotspot/make/solaris/makefiles/buildtree.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/solaris/makefiles/buildtree.make Fri Mar 02 09:13:13 2012 -0800
@@ -55,6 +55,7 @@
# The makefiles are split this way so that "make foo" will run faster by not
# having to read the dependency files for the vm.
+-include $(SPEC)
include $(GAMMADIR)/make/scm.make
include $(GAMMADIR)/make/altsrc.make
@@ -237,6 +238,8 @@
echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \
echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \
echo; \
+ [ -n "$(SPEC)" ] && \
+ echo "include $(SPEC)"; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \
echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \
) > $@
--- a/hotspot/make/solaris/makefiles/gcc.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/solaris/makefiles/gcc.make Fri Mar 02 09:13:13 2012 -0800
@@ -25,9 +25,13 @@
#------------------------------------------------------------------------
# CC, CXX & AS
-CXX = g++
-CC = gcc
-AS = $(CC) -c
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+ CXX = g++
+ CC = gcc
+ AS = $(CC) -c
+ MCS = /usr/ccs/bin/mcs
+endif
Compiler = gcc
@@ -193,5 +197,3 @@
ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),)
DEBUG_CFLAGS += -gstabs
endif
-
-MCS = /usr/ccs/bin/mcs
--- a/hotspot/make/solaris/makefiles/sparcWorks.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/solaris/makefiles/sparcWorks.make Fri Mar 02 09:13:13 2012 -0800
@@ -22,18 +22,22 @@
#
#
-# Compiler-specific flags for sparcworks.
-
-# tell make which C and C++ compilers to use
-CC = cc
-CXX = CC
+# If a SPEC is not set already, then use these defaults.
+ifeq ($(SPEC),)
+ # Compiler-specific flags for sparcworks.
+ CC = cc
+ CXX = CC
-# Note that this 'as' is an older version of the Sun Studio 'fbe', and will
-# use the older style options. The 'fbe' options will match 'cc' and 'CC'.
-AS = /usr/ccs/bin/as
+ # Note that this 'as' is an older version of the Sun Studio 'fbe', and will
+ # use the older style options. The 'fbe' options will match 'cc' and 'CC'.
+ AS = /usr/ccs/bin/as
-NM = /usr/ccs/bin/nm
-NAWK = /bin/nawk
+ NM = /usr/ccs/bin/nm
+ NAWK = /bin/nawk
+
+ MCS = /usr/ccs/bin/mcs
+ STRIP = /usr/ccs/bin/strip
+endif
REORDER_FLAG = -xF
@@ -557,9 +561,6 @@
#LINK_INTO = LIBJVM
endif
-MCS = /usr/ccs/bin/mcs
-STRIP = /usr/ccs/bin/strip
-
# Solaris platforms collect lots of redundant file-ident lines,
# to the point of wasting a significant percentage of file space.
# (The text is stored in ELF .comment sections, contributed by
--- a/hotspot/make/windows/build.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/windows/build.make Fri Mar 02 09:13:13 2012 -0800
@@ -297,6 +297,10 @@
@ echo BUILDARCH=$(BUILDARCH) >> $@
@ echo Platform_arch=$(Platform_arch) >> $@
@ echo Platform_arch_model=$(Platform_arch_model) >> $@
+ @ echo CXX=$(CXX) >> $@
+ @ echo LD=$(LD) >> $@
+ @ echo MT=$(MT) >> $@
+ @ echo RC=$(RC) >> $@
@ sh $(WorkSpace)/make/windows/get_msc_ver.sh >> $@
checks: checkVariant checkWorkSpace checkSA
--- a/hotspot/make/windows/makefiles/compile.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/windows/makefiles/compile.make Fri Mar 02 09:13:13 2012 -0800
@@ -23,7 +23,9 @@
#
# Generic compiler settings
+!if "x$(CXX)" == "x"
CXX=cl.exe
+!endif
# CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
# /nologo Supress copyright message at every cl.exe startup
@@ -183,8 +185,10 @@
LD_FLAGS = /manifest $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
+!if "x$(MT)" == "x"
MT=mt.exe
!endif
+!endif
!if "$(COMPILER_NAME)" == "VS2008"
PRODUCT_OPT_OPTION = /O2 /Oy-
@@ -194,8 +198,10 @@
LD_FLAGS = /manifest $(LD_FLAGS)
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
+!if "x$(MT)" == "x"
MT=mt.exe
!endif
+!endif
!if "$(COMPILER_NAME)" == "VS2010"
PRODUCT_OPT_OPTION = /O2 /Oy-
@@ -205,7 +211,9 @@
LD_FLAGS = /manifest $(LD_FLAGS)
# Manifest Tool - used in VS2005 and later to adjust manifests stored
# as resources inside build artifacts.
+!if "x$(MT)" == "x"
MT=mt.exe
+!endif
!if "$(BUILDARCH)" == "i486"
LD_FLAGS = /SAFESEH $(LD_FLAGS)
!endif
@@ -225,7 +233,9 @@
!endif
# Generic linker settings
+!if "x$(LD)" == "x"
LD=link.exe
+!endif
LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
uuid.lib Wsock32.lib winmm.lib /nologo /machine:$(MACHINE) /opt:REF \
@@ -237,7 +247,9 @@
!endif
# Resource compiler settings
+!if "x$(RC)" == "x"
RC=rc.exe
+!endif
RC_FLAGS=/D "HS_VER=$(HS_VER)" \
/D "HS_DOTVER=$(HS_DOTVER)" \
/D "HS_BUILD_ID=$(HS_BUILD_ID)" \
--- a/hotspot/make/windows/makefiles/defs.make Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/make/windows/makefiles/defs.make Fri Mar 02 09:13:13 2012 -0800
@@ -202,3 +202,19 @@
# Must pass this down to nmake.
MAKE_ARGS += BUILD_WIN_SA=1
endif
+
+# Propagate compiler and tools paths from configure to nmake.
+# Need to make sure they contain \\ and not /.
+ifneq ($(SPEC),)
+ ifeq ($(USING_CYGWIN), true)
+ MAKE_ARGS += CXX="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(CXX)))"
+ MAKE_ARGS += LD="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(LD)))"
+ MAKE_ARGS += RC="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(RC)))"
+ MAKE_ARGS += MT="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(MT)))"
+ else
+ MAKE_ARGS += CXX="$(subst /,\\,$(CXX))"
+ MAKE_ARGS += LD="$(subst /,\\,$(LD))"
+ MAKE_ARGS += RC="$(subst /,\\,$(RC))"
+ MAKE_ARGS += MT="$(subst /,\\,$(MT))"
+ endif
+endif
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -3231,6 +3231,26 @@
// no-op on TSO
}
+void LIR_Assembler::membar_loadload() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
+}
+
+void LIR_Assembler::membar_storestore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
+}
+
+void LIR_Assembler::membar_loadstore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
+}
+
+void LIR_Assembler::membar_storeload() {
+ __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
+}
+
+
// Pack two sequential registers containing 32 bit values
// into a single 64 bit register.
// src and src->successor() are packed into dst
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -3713,6 +3713,25 @@
// __ store_fence();
}
+void LIR_Assembler::membar_loadload() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadload));
+}
+
+void LIR_Assembler::membar_storestore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::storestore));
+}
+
+void LIR_Assembler::membar_loadstore() {
+ // no-op
+ //__ membar(Assembler::Membar_mask_bits(Assembler::loadstore));
+}
+
+void LIR_Assembler::membar_storeload() {
+ __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad));
+}
+
void LIR_Assembler::get_thread(LIR_Opr result_reg) {
assert(result_reg->is_register(), "check");
#ifdef _LP64
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Fri Mar 02 09:13:13 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
@@ -65,8 +65,8 @@
address generate_getPsrInfo() {
// Flags to test CPU type.
- const uint32_t EFL_AC = 0x40000;
- const uint32_t EFL_ID = 0x200000;
+ const uint32_t HS_EFL_AC = 0x40000;
+ const uint32_t HS_EFL_ID = 0x200000;
// Values for when we don't have a CPUID instruction.
const int CPU_FAMILY_SHIFT = 8;
const uint32_t CPU_FAMILY_386 = (3 << CPU_FAMILY_SHIFT);
@@ -100,7 +100,7 @@
//
// if we are unable to change the AC flag, we have a 386
//
- __ xorl(rax, EFL_AC);
+ __ xorl(rax, HS_EFL_AC);
__ push(rax);
__ popf();
__ pushf();
@@ -118,7 +118,7 @@
//
__ bind(detect_486);
__ mov(rax, rcx);
- __ xorl(rax, EFL_ID);
+ __ xorl(rax, HS_EFL_ID);
__ push(rax);
__ popf();
__ pushf();
--- a/hotspot/src/os/bsd/vm/osThread_bsd.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.cpp Fri Mar 02 09:13:13 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
@@ -49,7 +49,11 @@
void OSThread::pd_initialize() {
assert(this != NULL, "check");
+#ifdef __APPLE__
+ _thread_id = 0;
+#else
_thread_id = NULL;
+#endif
_pthread_id = NULL;
_siginfo = NULL;
_ucontext = NULL;
--- a/hotspot/src/os/bsd/vm/osThread_bsd.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/os/bsd/vm/osThread_bsd.hpp Fri Mar 02 09:13:13 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
@@ -40,10 +40,17 @@
private:
#ifdef _ALLBSD_SOURCE
- // _thread_id and _pthread_id are the same on BSD
- // keep both to minimize code divergence in os_bsd.cpp
+
+#ifdef __APPLE__
+ thread_t _thread_id;
+#else
pthread_t _thread_id;
+#endif
+
+ // _pthread_id is the pthread id, which is used by library calls
+ // (e.g. pthread_kill).
pthread_t _pthread_id;
+
#else
// _thread_id is kernel thread id (similar to LWP id on Solaris). Each
// thread has a unique thread_id (BsdThreads or NPTL). It can be used
@@ -64,9 +71,15 @@
void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; }
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ thread_t thread_id() const {
+ return _thread_id;
+ }
+#else
pthread_t thread_id() const {
return _thread_id;
}
+#endif
#else
pid_t thread_id() const {
return _thread_id;
@@ -84,9 +97,15 @@
}
#endif // ASSERT
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ void set_thread_id(thread_t id) {
+ _thread_id = id;
+ }
+#else
void set_thread_id(pthread_t id) {
_thread_id = id;
}
+#endif
#else
void set_thread_id(pid_t id) {
_thread_id = id;
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -568,6 +568,25 @@
sprintf(ld_library_path, "%s:%s", v, t);
free(t);
}
+
+#ifdef __APPLE__
+ // Apple's Java6 has "." at the beginning of java.library.path.
+ // OpenJDK on Windows has "." at the end of java.library.path.
+ // OpenJDK on Linux and Solaris don't have "." in java.library.path
+ // at all. To ease the transition from Apple's Java6 to OpenJDK7,
+ // "." is appended to the end of java.library.path. Yes, this
+ // could cause a change in behavior, but Apple's Java6 behavior
+ // can be achieved by putting "." at the beginning of the
+ // JAVA_LIBRARY_PATH environment variable.
+ {
+ char *t = ld_library_path;
+ // that's +3 for appending ":." and the trailing '\0'
+ ld_library_path = (char *) malloc(strlen(t) + 3);
+ sprintf(ld_library_path, "%s:%s", t, ".");
+ free(t);
+ }
+#endif
+
Arguments::set_library_path(ld_library_path);
}
@@ -979,8 +998,13 @@
}
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ // thread_id is mach thread on macos
+ osthread->set_thread_id(::mach_thread_self());
+#else
// thread_id is pthread_id on BSD
osthread->set_thread_id(::pthread_self());
+#endif
#else
// thread_id is kernel thread id (similar to Solaris LWP id)
osthread->set_thread_id(os::Bsd::gettid());
@@ -1171,7 +1195,11 @@
// Store pthread info into the OSThread
#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ osthread->set_thread_id(::mach_thread_self());
+#else
osthread->set_thread_id(::pthread_self());
+#endif
#else
osthread->set_thread_id(os::Bsd::gettid());
#endif
@@ -1788,7 +1816,13 @@
return n;
}
-intx os::current_thread_id() { return (intx)pthread_self(); }
+intx os::current_thread_id() {
+#ifdef __APPLE__
+ return (intx)::mach_thread_self();
+#else
+ return (intx)::pthread_self();
+#endif
+}
int os::current_process_id() {
// Under the old bsd thread library, bsd gives each thread
@@ -5133,9 +5167,9 @@
struct thread_basic_info tinfo;
mach_msg_type_number_t tcount = THREAD_INFO_MAX;
kern_return_t kr;
- mach_port_t mach_thread;
-
- mach_thread = pthread_mach_thread_np(thread->osthread()->thread_id());
+ thread_t mach_thread;
+
+ mach_thread = thread->osthread()->thread_id();
kr = thread_info(mach_thread, THREAD_BASIC_INFO, (thread_info_t)&tinfo, &tcount);
if (kr != KERN_SUCCESS)
return -1;
--- a/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/os_cpu/bsd_x86/vm/vmStructs_bsd_x86.hpp Fri Mar 02 09:13:13 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
@@ -29,12 +29,18 @@
// constants required by the Serviceability Agent. This file is
// referenced by vmStructs.cpp.
+#ifdef __APPLE__
+#define OS_THREAD_ID_TYPE thread_t
+#else
+#define OS_THREAD_ID_TYPE pthread_t
+#endif
+
#define VM_STRUCTS_OS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field, last_entry) \
\
/******************************/ \
/* Threads (NOTE: incomplete) */ \
/******************************/ \
- nonstatic_field(OSThread, _thread_id, pthread_t) \
+ nonstatic_field(OSThread, _thread_id, OS_THREAD_ID_TYPE) \
nonstatic_field(OSThread, _pthread_id, pthread_t) \
/* This must be the last entry, and must be present */ \
last_entry()
@@ -46,7 +52,7 @@
/* Posix Thread IDs */ \
/**********************/ \
\
- declare_integer_type(pid_t) \
+ declare_unsigned_integer_type(thread_t) \
declare_unsigned_integer_type(pthread_t) \
\
/* This must be the last entry, and must be present */ \
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -908,3 +908,4 @@
void Canonicalizer::do_ProfileCall(ProfileCall* x) {}
void Canonicalizer::do_ProfileInvoke(ProfileInvoke* x) {}
void Canonicalizer::do_RuntimeCall(RuntimeCall* x) {}
+void Canonicalizer::do_MemBar(MemBar* x) {}
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -104,6 +104,7 @@
virtual void do_ProfileCall (ProfileCall* x);
virtual void do_ProfileInvoke (ProfileInvoke* x);
virtual void do_RuntimeCall (RuntimeCall* x);
+ virtual void do_MemBar (MemBar* x);
};
#endif // SHARE_VM_C1_C1_CANONICALIZER_HPP
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -1418,6 +1418,12 @@
call_register_finalizer();
}
+ bool need_mem_bar = false;
+ if (method()->name() == ciSymbol::object_initializer_name() &&
+ scope()->wrote_final()) {
+ need_mem_bar = true;
+ }
+
// Check to see whether we are inlining. If so, Return
// instructions become Gotos to the continuation point.
if (continuation() != NULL) {
@@ -1437,6 +1443,10 @@
monitorexit(state()->lock_at(0), SynchronizationEntryBCI);
}
+ if (need_mem_bar) {
+ append(new MemBar(lir_membar_storestore));
+ }
+
// State at end of inlined method is the state of the caller
// without the method parameters on stack, including the
// return value, if any, of the inlined method on operand stack.
@@ -1456,7 +1466,6 @@
// the continuation point.
append_with_bci(goto_callee, scope_data()->continuation()->bci());
incr_num_returns();
-
return;
}
@@ -1472,6 +1481,10 @@
append_split(new MonitorExit(receiver, state()->unlock()));
}
+ if (need_mem_bar) {
+ append(new MemBar(lir_membar_storestore));
+ }
+
append(new Return(x));
}
@@ -1504,6 +1517,9 @@
}
}
+ if (field->is_final() && (code == Bytecodes::_putfield)) {
+ scope()->set_wrote_final();
+ }
const int offset = !needs_patching ? field->offset() : -1;
switch (code) {
--- a/hotspot/src/share/vm/c1/c1_IR.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_IR.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -141,6 +141,7 @@
_xhandlers = new XHandlers(method);
_number_of_locks = 0;
_monitor_pairing_ok = method->has_balanced_monitors();
+ _wrote_final = false;
_start = NULL;
if (osr_bci == -1) {
--- a/hotspot/src/share/vm/c1/c1_IR.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_IR.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -149,6 +149,7 @@
XHandlers* _xhandlers; // the exception handlers
int _number_of_locks; // the number of monitor lock slots needed
bool _monitor_pairing_ok; // the monitor pairing info
+ bool _wrote_final; // has written final field
BlockBegin* _start; // the start block, successsors are method entries
BitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable
@@ -181,6 +182,8 @@
void set_min_number_of_locks(int n) { if (n > _number_of_locks) _number_of_locks = n; }
bool monitor_pairing_ok() const { return _monitor_pairing_ok; }
BlockBegin* start() const { return _start; }
+ void set_wrote_final() { _wrote_final = true; }
+ bool wrote_final () const { return _wrote_final; }
};
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -107,6 +107,7 @@
class ProfileCall;
class ProfileInvoke;
class RuntimeCall;
+class MemBar;
// A Value is a reference to the instruction creating the value
typedef Instruction* Value;
@@ -204,6 +205,7 @@
virtual void do_ProfileCall (ProfileCall* x) = 0;
virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
virtual void do_RuntimeCall (RuntimeCall* x) = 0;
+ virtual void do_MemBar (MemBar* x) = 0;
};
@@ -2351,6 +2353,23 @@
virtual void state_values_do(ValueVisitor*);
};
+LEAF(MemBar, Instruction)
+ private:
+ LIR_Code _code;
+
+ public:
+ MemBar(LIR_Code code)
+ : Instruction(voidType)
+ , _code(code)
+ {
+ pin();
+ }
+
+ LIR_Code code() { return _code; }
+
+ virtual void input_values_do(ValueVisitor*) {}
+};
+
class BlockPair: public CompilationResourceObj {
private:
BlockBegin* _from;
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -855,4 +855,20 @@
output()->put(')');
}
+void InstructionPrinter::do_MemBar(MemBar* x) {
+ if (os::is_MP()) {
+ LIR_Code code = x->code();
+ switch (code) {
+ case lir_membar_acquire : output()->print("membar_acquire"); break;
+ case lir_membar_release : output()->print("membar_release"); break;
+ case lir_membar : output()->print("membar"); break;
+ case lir_membar_loadload : output()->print("membar_loadload"); break;
+ case lir_membar_storestore: output()->print("membar_storestore"); break;
+ case lir_membar_loadstore : output()->print("membar_loadstore"); break;
+ case lir_membar_storeload : output()->print("membar_storeload"); break;
+ default : ShouldNotReachHere(); break;
+ }
+ }
+}
+
#endif // PRODUCT
--- a/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_InstructionPrinter.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -132,6 +132,7 @@
virtual void do_ProfileCall (ProfileCall* x);
virtual void do_ProfileInvoke (ProfileInvoke* x);
virtual void do_RuntimeCall (RuntimeCall* x);
+ virtual void do_MemBar (MemBar* x);
};
#endif // PRODUCT
--- a/hotspot/src/share/vm/c1/c1_LIR.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -464,6 +464,10 @@
case lir_membar: // result and info always invalid
case lir_membar_acquire: // result and info always invalid
case lir_membar_release: // result and info always invalid
+ case lir_membar_loadload: // result and info always invalid
+ case lir_membar_storestore: // result and info always invalid
+ case lir_membar_loadstore: // result and info always invalid
+ case lir_membar_storeload: // result and info always invalid
{
assert(op->as_Op0() != NULL, "must be");
assert(op->_info == NULL, "info not used by this instruction");
@@ -1607,6 +1611,10 @@
case lir_membar: s = "membar"; break;
case lir_membar_acquire: s = "membar_acquire"; break;
case lir_membar_release: s = "membar_release"; break;
+ case lir_membar_loadload: s = "membar_loadload"; break;
+ case lir_membar_storestore: s = "membar_storestore"; break;
+ case lir_membar_loadstore: s = "membar_loadstore"; break;
+ case lir_membar_storeload: s = "membar_storeload"; break;
case lir_word_align: s = "word_align"; break;
case lir_label: s = "label"; break;
case lir_nop: s = "nop"; break;
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -866,6 +866,10 @@
, lir_membar
, lir_membar_acquire
, lir_membar_release
+ , lir_membar_loadload
+ , lir_membar_storestore
+ , lir_membar_loadstore
+ , lir_membar_storeload
, lir_get_thread
, end_op0
, begin_op1
@@ -1918,6 +1922,10 @@
void membar() { append(new LIR_Op0(lir_membar)); }
void membar_acquire() { append(new LIR_Op0(lir_membar_acquire)); }
void membar_release() { append(new LIR_Op0(lir_membar_release)); }
+ void membar_loadload() { append(new LIR_Op0(lir_membar_loadload)); }
+ void membar_storestore() { append(new LIR_Op0(lir_membar_storestore)); }
+ void membar_loadstore() { append(new LIR_Op0(lir_membar_loadstore)); }
+ void membar_storeload() { append(new LIR_Op0(lir_membar_storeload)); }
void nop() { append(new LIR_Op0(lir_nop)); }
void build_frame() { append(new LIR_Op0(lir_build_frame)); }
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -664,6 +664,22 @@
membar_release();
break;
+ case lir_membar_loadload:
+ membar_loadload();
+ break;
+
+ case lir_membar_storestore:
+ membar_storestore();
+ break;
+
+ case lir_membar_loadstore:
+ membar_loadstore();
+ break;
+
+ case lir_membar_storeload:
+ membar_storeload();
+ break;
+
case lir_get_thread:
get_thread(op->result_opr());
break;
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -241,6 +241,10 @@
void membar();
void membar_acquire();
void membar_release();
+ void membar_loadload();
+ void membar_storestore();
+ void membar_loadstore();
+ void membar_storeload();
void get_thread(LIR_Opr result);
void verify_oop_map(CodeEmitInfo* info);
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -3165,3 +3165,20 @@
}
return result;
}
+
+void LIRGenerator::do_MemBar(MemBar* x) {
+ if (os::is_MP()) {
+ LIR_Code code = x->code();
+ switch(code) {
+ case lir_membar_acquire : __ membar_acquire(); break;
+ case lir_membar_release : __ membar_release(); break;
+ case lir_membar : __ membar(); break;
+ case lir_membar_loadload : __ membar_loadload(); break;
+ case lir_membar_storestore: __ membar_storestore(); break;
+ case lir_membar_loadstore : __ membar_loadstore(); break;
+ case lir_membar_storeload : __ membar_storeload(); break;
+ default : ShouldNotReachHere(); break;
+ }
+ }
+}
+
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -525,6 +525,7 @@
virtual void do_ProfileCall (ProfileCall* x);
virtual void do_ProfileInvoke (ProfileInvoke* x);
virtual void do_RuntimeCall (RuntimeCall* x);
+ virtual void do_MemBar (MemBar* x);
};
--- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -509,6 +509,7 @@
void do_ProfileCall (ProfileCall* x);
void do_ProfileInvoke (ProfileInvoke* x);
void do_RuntimeCall (RuntimeCall* x);
+ void do_MemBar (MemBar* x);
};
@@ -678,6 +679,7 @@
void NullCheckVisitor::do_ProfileCall (ProfileCall* x) { nce()->clear_last_explicit_null_check(); }
void NullCheckVisitor::do_ProfileInvoke (ProfileInvoke* x) {}
void NullCheckVisitor::do_RuntimeCall (RuntimeCall* x) {}
+void NullCheckVisitor::do_MemBar (MemBar* x) {}
void NullCheckEliminator::visit(Value* p) {
--- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -200,6 +200,7 @@
void do_ProfileCall (ProfileCall* x) { /* nothing to do */ }
void do_ProfileInvoke (ProfileInvoke* x) { /* nothing to do */ };
void do_RuntimeCall (RuntimeCall* x) { /* nothing to do */ };
+ void do_MemBar (MemBar* x) { /* nothing to do */ };
};
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Fri Mar 02 09:13:13 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
@@ -509,6 +509,9 @@
template(clear_name, "clear") \
template(trigger_method_signature, "(ILjava/lang/management/MemoryUsage;)V") \
template(startAgent_name, "startAgent") \
+ template(startRemoteAgent_name, "startRemoteManagementAgent") \
+ template(startLocalAgent_name, "startLocalManagementAgent") \
+ template(stopRemoteAgent_name, "stopRemoteManagementAgent") \
template(java_lang_management_ThreadInfo_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;)V") \
template(java_lang_management_ThreadInfo_with_locks_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;[Ljava/lang/Object;[I[Ljava/lang/Object;)V") \
template(long_long_long_long_void_signature, "(JJJJ)V") \
--- a/hotspot/src/share/vm/oops/cpCacheOop.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -504,17 +504,17 @@
void ConstantPoolCacheEntry::print(outputStream* st, int index) const {
// print separator
- if (index == 0) tty->print_cr(" -------------");
+ if (index == 0) st->print_cr(" -------------");
// print entry
- tty->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this);
+ st->print("%3d ("PTR_FORMAT") ", index, (intptr_t)this);
if (is_secondary_entry())
- tty->print_cr("[%5d|secondary]", main_entry_index());
+ st->print_cr("[%5d|secondary]", main_entry_index());
else
- tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
- tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)(oop)_f1);
- tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2);
- tty->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags);
- tty->print_cr(" -------------");
+ st->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index());
+ st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)(oop)_f1);
+ st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_f2);
+ st->print_cr(" [ "PTR_FORMAT"]", (intptr_t)_flags);
+ st->print_cr(" -------------");
}
void ConstantPoolCacheEntry::verify(outputStream* st) const {
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp Fri Mar 02 09:13:13 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
@@ -49,6 +49,11 @@
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ClassHistogramDCmd>(true, false));
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<ThreadDumpDCmd>(true, false));
+ //Enhanced JMX Agent Support
+ DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartRemoteDCmd>(true,false));
+ DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStartLocalDCmd>(true,false));
+ DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<JMXStopRemoteDCmd>(true,false));
+
}
#ifndef HAVE_EXTRA_DCMD
@@ -344,3 +349,185 @@
return 0;
}
}
+
+// Enhanced JMX Agent support
+
+JMXStartRemoteDCmd::JMXStartRemoteDCmd(outputStream *output, bool heap_allocated) :
+
+ DCmdWithParser(output, heap_allocated),
+
+ _config_file
+ ("config.file",
+ "set com.sun.management.config.file", "STRING", false),
+
+ _jmxremote_port
+ ("jmxremote.port",
+ "set com.sun.management.jmxremote.port", "STRING", false),
+
+ _jmxremote_rmi_port
+ ("jmxremote.rmi.port",
+ "set com.sun.management.jmxremote.rmi.port", "STRING", false),
+
+ _jmxremote_ssl
+ ("jmxremote.ssl",
+ "set com.sun.management.jmxremote.ssl", "STRING", false),
+
+ _jmxremote_registry_ssl
+ ("jmxremote.registry.ssl",
+ "set com.sun.management.jmxremote.registry.ssl", "STRING", false),
+
+ _jmxremote_authenticate
+ ("jmxremote.authenticate",
+ "set com.sun.management.jmxremote.authenticate", "STRING", false),
+
+ _jmxremote_password_file
+ ("jmxremote.password.file",
+ "set com.sun.management.jmxremote.password.file", "STRING", false),
+
+ _jmxremote_access_file
+ ("jmxremote.access.file",
+ "set com.sun.management.jmxremote.access.file", "STRING", false),
+
+ _jmxremote_login_config
+ ("jmxremote.login.config",
+ "set com.sun.management.jmxremote.login.config", "STRING", false),
+
+ _jmxremote_ssl_enabled_cipher_suites
+ ("jmxremote.ssl.enabled.cipher.suites",
+ "set com.sun.management.jmxremote.ssl.enabled.cipher.suite", "STRING", false),
+
+ _jmxremote_ssl_enabled_protocols
+ ("jmxremote.ssl.enabled.protocols",
+ "set com.sun.management.jmxremote.ssl.enabled.protocols", "STRING", false),
+
+ _jmxremote_ssl_need_client_auth
+ ("jmxremote.ssl.need.client.auth",
+ "set com.sun.management.jmxremote.need.client.auth", "STRING", false),
+
+ _jmxremote_ssl_config_file
+ ("jmxremote.ssl.config.file",
+ "set com.sun.management.jmxremote.ssl_config_file", "STRING", false)
+
+ {
+ _dcmdparser.add_dcmd_option(&_config_file);
+ _dcmdparser.add_dcmd_option(&_jmxremote_port);
+ _dcmdparser.add_dcmd_option(&_jmxremote_rmi_port);
+ _dcmdparser.add_dcmd_option(&_jmxremote_ssl);
+ _dcmdparser.add_dcmd_option(&_jmxremote_registry_ssl);
+ _dcmdparser.add_dcmd_option(&_jmxremote_authenticate);
+ _dcmdparser.add_dcmd_option(&_jmxremote_password_file);
+ _dcmdparser.add_dcmd_option(&_jmxremote_access_file);
+ _dcmdparser.add_dcmd_option(&_jmxremote_login_config);
+ _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_cipher_suites);
+ _dcmdparser.add_dcmd_option(&_jmxremote_ssl_enabled_protocols);
+ _dcmdparser.add_dcmd_option(&_jmxremote_ssl_need_client_auth);
+ _dcmdparser.add_dcmd_option(&_jmxremote_ssl_config_file);
+}
+
+
+int JMXStartRemoteDCmd::num_arguments() {
+ ResourceMark rm;
+ JMXStartRemoteDCmd* dcmd = new JMXStartRemoteDCmd(NULL, false);
+ if (dcmd != NULL) {
+ DCmdMark mark(dcmd);
+ return dcmd->_dcmdparser.num_arguments();
+ } else {
+ return 0;
+ }
+}
+
+
+void JMXStartRemoteDCmd::execute(TRAPS) {
+ ResourceMark rm(THREAD);
+ HandleMark hm(THREAD);
+
+ // Load and initialize the sun.management.Agent class
+ // invoke startRemoteManagementAgent(string) method to start
+ // the remote management server.
+ // throw java.lang.NoSuchMethodError if the method doesn't exist
+
+ Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+ klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+ instanceKlassHandle ik (THREAD, k);
+
+ JavaValue result(T_VOID);
+
+ // Pass all command line arguments to java as key=value,...
+ // All checks are done on java side
+
+ int len = 0;
+ stringStream options;
+ char comma[2] = {0,0};
+
+ // Leave default values on Agent.class side and pass only
+ // agruments explicitly set by user. All arguments passed
+ // to jcmd override properties with the same name set by
+ // command line with -D or by managmenent.properties
+ // file.
+#define PUT_OPTION(a) \
+ if ( (a).is_set() ){ \
+ options.print("%scom.sun.management.%s=%s", comma, (a).name(), (a).value()); \
+ comma[0] = ','; \
+ }
+
+ PUT_OPTION(_config_file);
+ PUT_OPTION(_jmxremote_port);
+ PUT_OPTION(_jmxremote_rmi_port);
+ PUT_OPTION(_jmxremote_ssl);
+ PUT_OPTION(_jmxremote_registry_ssl);
+ PUT_OPTION(_jmxremote_authenticate);
+ PUT_OPTION(_jmxremote_password_file);
+ PUT_OPTION(_jmxremote_access_file);
+ PUT_OPTION(_jmxremote_login_config);
+ PUT_OPTION(_jmxremote_ssl_enabled_cipher_suites);
+ PUT_OPTION(_jmxremote_ssl_enabled_protocols);
+ PUT_OPTION(_jmxremote_ssl_need_client_auth);
+ PUT_OPTION(_jmxremote_ssl_config_file);
+
+#undef PUT_OPTION
+
+ Handle str = java_lang_String::create_from_str(options.as_string(), CHECK);
+ JavaCalls::call_static(&result, ik, vmSymbols::startRemoteAgent_name(), vmSymbols::string_void_signature(), str, CHECK);
+}
+
+JMXStartLocalDCmd::JMXStartLocalDCmd(outputStream *output, bool heap_allocated) :
+ DCmd(output, heap_allocated)
+{
+ // do nothing
+}
+
+void JMXStartLocalDCmd::execute(TRAPS) {
+ ResourceMark rm(THREAD);
+ HandleMark hm(THREAD);
+
+ // Load and initialize the sun.management.Agent class
+ // invoke startLocalManagementAgent(void) method to start
+ // the local management server
+ // throw java.lang.NoSuchMethodError if method doesn't exist
+
+ Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+ klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+ instanceKlassHandle ik (THREAD, k);
+
+ JavaValue result(T_VOID);
+ JavaCalls::call_static(&result, ik, vmSymbols::startLocalAgent_name(), vmSymbols::void_method_signature(), CHECK);
+}
+
+
+void JMXStopRemoteDCmd::execute(TRAPS) {
+ ResourceMark rm(THREAD);
+ HandleMark hm(THREAD);
+
+ // Load and initialize the sun.management.Agent class
+ // invoke stopRemoteManagementAgent method to stop the
+ // management server
+ // throw java.lang.NoSuchMethodError if method doesn't exist
+
+ Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+ klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(), loader, Handle(), true, CHECK);
+ instanceKlassHandle ik (THREAD, k);
+
+ JavaValue result(T_VOID);
+ JavaCalls::call_static(&result, ik, vmSymbols::stopRemoteAgent_name(), vmSymbols::void_method_signature(), CHECK);
+}
+
--- a/hotspot/src/share/vm/services/diagnosticCommand.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/services/diagnosticCommand.hpp Fri Mar 02 09:13:13 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
@@ -214,4 +214,82 @@
virtual void execute(TRAPS);
};
+// Enhanced JMX Agent support
+
+class JMXStartRemoteDCmd : public DCmdWithParser {
+
+ // Explicitly list all properties that could be
+ // passed to Agent.startRemoteManagementAgent()
+ // com.sun.management is omitted
+
+ DCmdArgument<char *> _config_file;
+ DCmdArgument<char *> _jmxremote_port;
+ DCmdArgument<char *> _jmxremote_rmi_port;
+ DCmdArgument<char *> _jmxremote_ssl;
+ DCmdArgument<char *> _jmxremote_registry_ssl;
+ DCmdArgument<char *> _jmxremote_authenticate;
+ DCmdArgument<char *> _jmxremote_password_file;
+ DCmdArgument<char *> _jmxremote_access_file;
+ DCmdArgument<char *> _jmxremote_login_config;
+ DCmdArgument<char *> _jmxremote_ssl_enabled_cipher_suites;
+ DCmdArgument<char *> _jmxremote_ssl_enabled_protocols;
+ DCmdArgument<char *> _jmxremote_ssl_need_client_auth;
+ DCmdArgument<char *> _jmxremote_ssl_config_file;
+
+public:
+ JMXStartRemoteDCmd(outputStream *output, bool heap_allocated);
+
+ static const char *name() {
+ return "ManagementAgent.start";
+ }
+
+ static const char *description() {
+ return "Start remote management agent.";
+ }
+
+ static int num_arguments();
+
+ virtual void execute(TRAPS);
+
+};
+
+class JMXStartLocalDCmd : public DCmd {
+
+ // Explicitly request start of local agent,
+ // it will not be started by start dcmd
+
+
+public:
+ JMXStartLocalDCmd(outputStream *output, bool heap_allocated);
+
+ static const char *name() {
+ return "ManagementAgent.start_local";
+ }
+
+ static const char *description() {
+ return "Start local management agent.";
+ }
+
+ virtual void execute(TRAPS);
+
+};
+
+class JMXStopRemoteDCmd : public DCmd {
+public:
+ JMXStopRemoteDCmd(outputStream *output, bool heap_allocated) :
+ DCmd(output, heap_allocated) {
+ // Do Nothing
+ }
+
+ static const char *name() {
+ return "ManagementAgent.stop";
+ }
+
+ static const char *description() {
+ return "Stop remote management agent.";
+ }
+
+ virtual void execute(TRAPS);
+};
+
#endif // SHARE_VM_SERVICES_DIAGNOSTICCOMMAND_HPP
--- a/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp Thu Mar 01 15:31:33 2012 -0800
+++ b/hotspot/src/share/vm/utilities/globalDefinitions_gcc.hpp Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -87,14 +87,7 @@
#endif
#ifdef __APPLE__
#include <AvailabilityMacros.h>
- #if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
- // Mac OS X 10.4 defines EFL_AC and EFL_ID,
- // which conflict with hotspot variable names.
- //
- // This has been fixed in Mac OS X 10.5.
- #undef EFL_AC
- #undef EFL_ID
- #endif
+ #include <mach/mach.h>
#endif
#include <sys/time.h>
#endif // LINUX || _ALLBSD_SOURCE
--- a/jaxp/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/jaxp/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
95102fd334183d15dc98a95dd0d749527b6c7300 jdk8-b23
7836655e2495646c462f13de73dcc3ada197b64f jdk8-b24
bb694c151fc7b5c8f9edc8af6a80738530feacaf jdk8-b25
+dbb7283c197b27da1fc12ae8a83785c851b68c12 jdk8-b26
+80c47eb83d24fdd64bbb48f288bd6d4f03e0ec88 jdk8-b27
--- a/jaxws/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/jaxws/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
25ce7a0004874273f6aeda14e7c3538cba34bdf1 jdk8-b23
e0d90803439b174fe0b0033e09d50444ba12498f jdk8-b24
b376d901e006cd9e0c59733c84e190aace23eec6 jdk8-b25
+3518639eab6ce5c7b482bdb0a60342c392ab97a8 jdk8-b26
+38c037af4127289de12efc67f45d19bb67abff69 jdk8-b27
--- a/jaxws/build-defs.xml Thu Mar 01 15:31:33 2012 -0800
+++ b/jaxws/build-defs.xml Fri Mar 02 09:13:13 2012 -0800
@@ -101,7 +101,7 @@
<copy todir="${build.classes.dir}/META-INF"
file="${secondary.src.dir}/META-INF/mimetypes.default"/>
<copy todir="${build.classes.dir}/META-INF/services"
- file="${primary.src.dir}/com/sun/tools/etc/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory"/>
+ file="${primary.src.dir}/com/sun/tools/etc/META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin"/>
<copy todir="${build.classes.dir}/META-INF/services"
file="${primary.src.dir}/com/sun/tools/etc/META-INF/services/com.sun.tools.internal.xjc.Plugin"/>
<mkdir dir="${build.classes.dir}/com/sun/tools/internal/xjc/runtime"/>
--- a/jaxws/jaxws.properties Thu Mar 01 15:31:33 2012 -0800
+++ b/jaxws/jaxws.properties Fri Mar 02 09:13:13 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
--- a/jdk/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
54202e0148ec7d4570cab5bc9b00d216a7677569 jdk8-b23
34029a0c69bba882264a29fc822f8283fd15f104 jdk8-b24
ec17fbe5b8fbc52da070eec43b4711d9354b2ab8 jdk8-b25
+5aca406e87cb9144a9405be312dadd728a9c6fe2 jdk8-b26
+c68342532e2e7deb3a25fc04ed3e4c142278f747 jdk8-b27
--- a/jdk/make/com/sun/Makefile Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/com/sun/Makefile Fri Mar 02 09:13:13 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
--- a/jdk/make/com/sun/nio/sctp/Exportedfiles.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/com/sun/nio/sctp/Exportedfiles.gmk Fri Mar 02 09:13:13 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
--- a/jdk/make/com/sun/nio/sctp/FILES_java.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/com/sun/nio/sctp/FILES_java.gmk Fri Mar 02 09:13:13 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
--- a/jdk/make/com/sun/nio/sctp/Makefile Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/com/sun/nio/sctp/Makefile Fri Mar 02 09:13:13 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
--- a/jdk/make/com/sun/nio/sctp/mapfile-vers Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/com/sun/nio/sctp/mapfile-vers Fri Mar 02 09:13:13 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:
*;
--- a/jdk/make/common/Release.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/common/Release.gmk Fri Mar 02 09:13:13 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
@#
--- a/jdk/make/common/internal/Defs-jaxws.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/common/internal/Defs-jaxws.gmk Fri Mar 02 09:13:13 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
+
--- a/jdk/make/common/internal/Defs-langtools.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/common/internal/Defs-langtools.gmk Fri Mar 02 09:13:13 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 \
--- a/jdk/make/docs/Makefile Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/docs/Makefile Fri Mar 02 09:13:13 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 := <strong>Mirror API</strong>
-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
#
--- a/jdk/make/docs/NON_CORE_PKGS.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/docs/NON_CORE_PKGS.gmk Fri Mar 02 09:13:13 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
--- a/jdk/make/java/java/FILES_java.gmk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/java/java/FILES_java.gmk Fri Mar 02 09:13:13 2012 -0800
@@ -474,6 +474,7 @@
sun/misc/MessageUtils.java \
sun/misc/GC.java \
sun/misc/Service.java \
+ sun/misc/JavaAWTAccess.java \
sun/misc/JavaLangAccess.java \
sun/misc/JavaIOAccess.java \
sun/misc/JavaIOFileDescriptorAccess.java \
--- a/jdk/make/java/management/mapfile-vers Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/java/management/mapfile-vers Fri Mar 02 09:13:13 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;
--- a/jdk/make/launchers/Makefile Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/launchers/Makefile Fri Mar 02 09:13:13 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, , )
--- a/jdk/make/launchers/Makefile.launcher Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/make/launchers/Makefile.launcher Fri Mar 02 09:13:13 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...
--- a/jdk/src/linux/doc/man/apt.1 Thu Mar 01 15:31:33 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
-
--- a/jdk/src/linux/doc/man/ja/apt.1 Thu Mar 01 15:31:33 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
-
--- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java Fri Mar 02 09:13:13 2012 -0800
@@ -55,9 +55,12 @@
// Should allow an empty password.
passwd = new char[0];
}
- for (int i=0; i<passwd.length; i++) {
- if ((passwd[i] < '\u0020') || (passwd[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<passwd.length; i++) {
+ if ((passwd[i] < '\u0020') || (passwd[i] > '\u007E')) {
+ throw new InvalidKeySpecException("Password is not ASCII");
+ }
}
}
this.key = new byte[passwd.length];
--- a/jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java Fri Mar 02 09:13:13 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)
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java Fri Mar 02 09:13:13 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));
--- a/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/dns/DnsClient.java Fri Mar 02 09:13:13 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
@@ -622,11 +622,7 @@
//-------------------------------------------------------------------------
- private static boolean debug = false;
-
- public static void setDebug(boolean flag) {
- debug = flag;
- }
+ private static final boolean debug = false;
private static void dprint(String mess) {
if (debug) {
--- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java Thu Mar 01 15:31:33 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:
- * <blockquote>
- * <command name> [<option>=<value>] [<argument_value>]
- * </blockquote>
- * Example:
- * <blockquote>
- * command_name option1=value1 option2=value argumentA argumentB argumentC
- * </blockquote>
- * 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;
- }
-}
--- a/jdk/src/share/classes/com/sun/management/DiagnosticCommandInfo.java Thu Mar 01 15:31:33 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<DiagnosticCommandArgumentInfo> 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<DiagnosticCommandArgumentInfo> getArgumentsInfo() {
- return arguments;
- }
-
- @ConstructorProperties({"name", "description","impact","enabled",
- "argumentsInfo"})
- public DiagnosticCommandInfo(String name, String description,
- String impact, boolean enabled,
- List<DiagnosticCommandArgumentInfo> arguments)
- {
- this.name = name;
- this.description = description;
- this.impact = impact;
- this.enabled = enabled;
- this.arguments = arguments;
- }
-}
--- a/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java Fri Mar 02 09:13:13 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.
*
- * <p>{@linkplain #getDiagnosticCommands Diagnostic commands}
- * are actions that can be invoked dynamically and
- * executed in a target Java virtual machine, mainly for troubleshooting
- * and diagnosis.
- *
* <p>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<String> 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<DiagnosticCommandInfo> 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<DiagnosticCommandInfo> getDiagnosticCommandInfo(List<String> 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:
- * <blockquote>
- * <command name> [<option>=<value>] [<argument_value>]
- * </blockquote>
- *
- * @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:
- * <blockquote>
- * [<option>=<value>] [<argument_value>]
- * </blockquote>
- *
- * @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);
}
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Fri Mar 02 09:13:13 2012 -0800
@@ -736,7 +736,7 @@
if (off < 0) {
throw new ArrayIndexOutOfBoundsException(off);
}
- if (off + len > b.length) {
+ if ((long)off + (long)len > (long)b.length) {
throw new ArrayIndexOutOfBoundsException(b.length);
}
@@ -964,7 +964,7 @@
if (off < 0) {
throw new ArrayIndexOutOfBoundsException(off);
}
- if (off + len > b.length) {
+ if ((long)off + (long)len > (long)b.length) {
throw new ArrayIndexOutOfBoundsException(b.length);
}
if (!isActive() && doIO) {
--- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java Fri Mar 02 09:13:13 2012 -0800
@@ -130,6 +130,12 @@
if (len % framesize != 0)
throw new IllegalArgumentException(
"Number of bytes does not represent an integral number of sample frames.");
+ if (off < 0) {
+ throw new ArrayIndexOutOfBoundsException(off);
+ }
+ if ((long)off + (long)len > (long)b.length) {
+ throw new ArrayIndexOutOfBoundsException(b.length);
+ }
byte[] buff = cycling_buffer;
int buff_len = cycling_buffer.length;
--- a/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java Fri Mar 02 09:13:13 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);
}
/**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java Fri Mar 02 09:13:13 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);
}
/**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java Fri Mar 02 09:13:13 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);
}
/**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java Fri Mar 02 09:13:13 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);
}
/**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java Fri Mar 02 09:13:13 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<Boolean> SCTP_DISABLE_FRAGMENTS = new
SctpStdSocketOption<Boolean>("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<Boolean> SCTP_EXPLICIT_COMPLETE = new
SctpStdSocketOption<Boolean>("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<Integer> SCTP_FRAGMENT_INTERLEAVE =
new SctpStdSocketOption<Integer>("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<Boolean> SCTP_NODELAY =
new SctpStdSocketOption<Boolean>("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<Integer> SO_SNDBUF =
new SctpStdSocketOption<Integer>("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<Integer> SO_RCVBUF =
new SctpStdSocketOption<Integer>("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<Integer> SO_LINGER =
new SctpStdSocketOption<Integer>("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
--- a/jdk/src/share/classes/java/awt/List.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/awt/List.java Fri Mar 02 09:13:13 2012 -0800
@@ -115,7 +115,7 @@
* @see #addItem(String)
* @see #getItem(int)
*/
- Vector items = new Vector();
+ Vector<String> 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);
}
/**
--- a/jdk/src/share/classes/java/awt/Window.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/awt/Window.java Fri Mar 02 09:13:13 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"));
}
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java Fri Mar 02 09:13:13 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<ICC_Profile>() {
+ public ICC_Profile run() {
ICC_Profile p = null;
try {
p = getInstance (name);
--- a/jdk/src/share/classes/java/awt/event/InputEvent.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/awt/event/InputEvent.java Fri Mar 02 09:13:13 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 <code>source</code> is null
* @see #getSource()
* @see #getID()
@@ -416,9 +417,13 @@
/**
* Returns the extended modifier mask for this event.
+ * <P>
+ * Extended modifiers are the modifiers that ends with the _DOWN_MASK suffix,
+ * such as ALT_DOWN_MASK, BUTTON1_DOWN_MASK, and others.
+ * <P>
* 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.
* <P>
* For example, if the user presses <b>button 1</b> followed by
* <b>button 2</b>, and then releases them in the same order,
--- a/jdk/src/share/classes/java/awt/event/MouseEvent.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/awt/event/MouseEvent.java Fri Mar 02 09:13:13 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.
--- a/jdk/src/share/classes/java/io/File.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/io/File.java Fri Mar 02 09:13:13 2012 -0800
@@ -153,7 +153,7 @@
/**
* The FileSystem object representing the platform's local file system.
*/
- static private FileSystem fs = FileSystem.getFileSystem();
+ private static final FileSystem fs = FileSystem.getFileSystem();
/**
* This abstract pathname's normalized pathname string. A normalized
@@ -162,13 +162,13 @@
*
* @serial
*/
- private String path;
+ private final String path;
/**
* The length of this abstract pathname's prefix, or zero if it has no
* prefix.
*/
- private transient int prefixLength;
+ private final transient int prefixLength;
/**
* Returns the length of this abstract pathname's prefix.
@@ -2023,10 +2023,28 @@
char sep = s.readChar(); // read the previous separator char
if (sep != separatorChar)
pathField = pathField.replace(sep, separatorChar);
- this.path = fs.normalize(pathField);
- this.prefixLength = fs.prefixLength(this.path);
+ String path = fs.normalize(pathField);
+ UNSAFE.putObject(this, PATH_OFFSET, path);
+ UNSAFE.putIntVolatile(this, PREFIX_LENGTH_OFFSET, fs.prefixLength(path));
}
+ private static final long PATH_OFFSET;
+ private static final long PREFIX_LENGTH_OFFSET;
+ private static final sun.misc.Unsafe UNSAFE;
+ static {
+ try {
+ sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
+ PATH_OFFSET = unsafe.objectFieldOffset(
+ File.class.getDeclaredField("path"));
+ PREFIX_LENGTH_OFFSET = unsafe.objectFieldOffset(
+ File.class.getDeclaredField("prefixLength"));
+ UNSAFE = unsafe;
+ } catch (ReflectiveOperationException e) {
+ throw new Error(e);
+ }
+ }
+
+
/** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = 301077366599181567L;
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java Fri Mar 02 09:13:13 2012 -0800
@@ -123,14 +123,39 @@
*/
private boolean hasBlockExternalData = true;
+ /**
+ * Contains information about InvalidClassException instances to be thrown
+ * when attempting operations on an invalid class. Note that instances of
+ * this class are immutable and are potentially shared among
+ * ObjectStreamClass instances.
+ */
+ private static class ExceptionInfo {
+ private final String className;
+ private final String message;
+
+ ExceptionInfo(String cn, String msg) {
+ className = cn;
+ message = msg;
+ }
+
+ /**
+ * Returns (does not throw) an InvalidClassException instance created
+ * from the information in this object, suitable for being thrown by
+ * the caller.
+ */
+ InvalidClassException newInvalidClassException() {
+ return new InvalidClassException(className, message);
+ }
+ }
+
/** exception (if any) thrown while attempting to resolve class */
private ClassNotFoundException resolveEx;
/** exception (if any) to throw if non-enum deserialization attempted */
- private InvalidClassException deserializeEx;
+ private ExceptionInfo deserializeEx;
/** exception (if any) to throw if non-enum serialization attempted */
- private InvalidClassException serializeEx;
+ private ExceptionInfo serializeEx;
/** exception (if any) to throw if default serialization attempted */
- private InvalidClassException defaultSerializeEx;
+ private ExceptionInfo defaultSerializeEx;
/** serializable fields */
private ObjectStreamField[] fields;
@@ -444,7 +469,8 @@
fields = getSerialFields(cl);
computeFieldOffsets();
} catch (InvalidClassException e) {
- serializeEx = deserializeEx = e;
+ serializeEx = deserializeEx =
+ new ExceptionInfo(e.classname, e.getMessage());
fields = NO_FIELDS;
}
@@ -483,15 +509,14 @@
if (deserializeEx == null) {
if (isEnum) {
- deserializeEx = new InvalidClassException(name, "enum type");
+ deserializeEx = new ExceptionInfo(name, "enum type");
} else if (cons == null) {
- deserializeEx = new InvalidClassException(
- name, "no valid constructor");
+ deserializeEx = new ExceptionInfo(name, "no valid constructor");
}
}
for (int i = 0; i < fields.length; i++) {
if (fields[i].getField() == null) {
- defaultSerializeEx = new InvalidClassException(
+ defaultSerializeEx = new ExceptionInfo(
name, "unmatched serializable field(s) declared");
}
}
@@ -601,8 +626,8 @@
(externalizable != localDesc.externalizable) ||
!(serializable || externalizable))
{
- deserializeEx = new InvalidClassException(localDesc.name,
- "class invalid for deserialization");
+ deserializeEx = new ExceptionInfo(
+ localDesc.name, "class invalid for deserialization");
}
}
@@ -727,11 +752,7 @@
*/
void checkDeserialize() throws InvalidClassException {
if (deserializeEx != null) {
- InvalidClassException ice =
- new InvalidClassException(deserializeEx.classname,
- deserializeEx.getMessage());
- ice.initCause(deserializeEx);
- throw ice;
+ throw deserializeEx.newInvalidClassException();
}
}
@@ -742,11 +763,7 @@
*/
void checkSerialize() throws InvalidClassException {
if (serializeEx != null) {
- InvalidClassException ice =
- new InvalidClassException(serializeEx.classname,
- serializeEx.getMessage());
- ice.initCause(serializeEx);
- throw ice;
+ throw serializeEx.newInvalidClassException();
}
}
@@ -759,11 +776,7 @@
*/
void checkDefaultSerialize() throws InvalidClassException {
if (defaultSerializeEx != null) {
- InvalidClassException ice =
- new InvalidClassException(defaultSerializeEx.classname,
- defaultSerializeEx.getMessage());
- ice.initCause(defaultSerializeEx);
- throw ice;
+ throw defaultSerializeEx.newInvalidClassException();
}
}
--- a/jdk/src/share/classes/java/lang/Math.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/lang/Math.java Fri Mar 02 09:13:13 2012 -0800
@@ -81,6 +81,22 @@
* floating-point approximation. Not all approximations that have 1
* ulp accuracy will automatically meet the monotonicity requirements.
*
+ * <p>
+ * The platform uses signed two's complement integer arithmetic with
+ * int and long primitive types. The developer should choose
+ * the primitive type to ensure that arithmetic operations consistently
+ * produce correct results, which in some cases means the operations
+ * will not overflow the range of values of the computation.
+ * The best practice is to choose the primitive type and algorithm to avoid
+ * overflow. In cases where the size is {@code int} or {@code long} and
+ * overflow errors need to be detected, the methods {@code addExact},
+ * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
+ * throw an {@code ArithmeticException} when the results overflow.
+ * For other arithmetic operations such as divide, absolute value,
+ * increment, decrement, and negation overflow occurs only with
+ * a specific minimum or maximum value and should be checked against
+ * the minimum or maximum as appropriate.
+ *
* @author unascribed
* @author Joseph D. Darcy
* @since JDK1.0
@@ -719,6 +735,137 @@
}
/**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ public static int addExact(int x, int y) {
+ int r = x + y;
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ public static long addExact(long x, long y) {
+ long r = x + y;
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("long overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the difference of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ public static int subtractExact(int x, int y) {
+ int r = x - y;
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the difference of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ public static long subtractExact(long x, long y) {
+ long r = x - y;
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("long overflow");
+ }
+ return r;
+ }
+
+ /**
+ * Returns the product of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ public static int multiplyExact(int x, int y) {
+ long r = (long)x * (long)y;
+ if ((int)r != r) {
+ throw new ArithmeticException("long overflow");
+ }
+ return (int)r;
+ }
+
+ /**
+ * Returns the product of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ public static long multiplyExact(long x, long y) {
+ long r = x * y;
+ long ax = Math.abs(x);
+ long ay = Math.abs(y);
+ if (((ax | ay) >>> 31 != 0)) {
+ // Some bits greater than 2^31 that might cause overflow
+ // Check the result using the divide operator
+ // and check for the special case of Long.MIN_VALUE * -1
+ if (((y != 0) && (r / y != x)) ||
+ (x == Long.MIN_VALUE && y == -1)) {
+ throw new ArithmeticException("long overflow");
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Returns the value of the {@code long} argument;
+ * throwing an exception if the value overflows an {@code int}.
+ *
+ * @param value the long value
+ * @return the argument as an int
+ * @throws ArithmeticException if the {@code argument} overflows an int
+ */
+ public static int toIntExact(long value) {
+ if ((int)value != value) {
+ throw new ArithmeticException("integer overflow");
+ }
+ return (int)value;
+ }
+
+ /**
* Returns the absolute value of an {@code int} value.
* If the argument is not negative, the argument is returned.
* If the argument is negative, the negation of the argument is returned.
@@ -1737,7 +1884,7 @@
}
/**
- * Return {@code d} ×
+ * Returns {@code d} ×
* 2<sup>{@code scaleFactor}</sup> rounded as if performed
* by a single correctly rounded floating-point multiply to a
* member of the double value set. See the Java
@@ -1844,7 +1991,7 @@
}
/**
- * Return {@code f} ×
+ * Returns {@code f} ×
* 2<sup>{@code scaleFactor}</sup> rounded as if performed
* by a single correctly rounded floating-point multiply to a
* member of the float value set. See the Java
--- a/jdk/src/share/classes/java/lang/StrictMath.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/lang/StrictMath.java Fri Mar 02 09:13:13 2012 -0800
@@ -56,6 +56,22 @@
* {@code sinh}, {@code cosh}, {@code tanh},
* {@code hypot}, {@code expm1}, and {@code log1p}.
*
+ * <p>
+ * The platform uses signed two's complement integer arithmetic with
+ * int and long primitive types. The developer should choose
+ * the primitive type to ensure that arithmetic operations consistently
+ * produce correct results, which in some cases means the operations
+ * will not overflow the range of values of the computation.
+ * The best practice is to choose the primitive type and algorithm to avoid
+ * overflow. In cases where the size is {@code int} or {@code long} and
+ * overflow errors need to be detected, the methods {@code addExact},
+ * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
+ * throw an {@code ArithmeticException} when the results overflow.
+ * For other arithmetic operations such as divide, absolute value,
+ * increment, decrement, and negation overflow occurs only with
+ * a specific minimum or maximum value and should be checked against
+ * the minimum or maximum as appropriate.
+ *
* @author unascribed
* @author Joseph D. Darcy
* @since 1.3
@@ -699,7 +715,111 @@
}
/**
- * Returns the absolute value of an {@code int} value..
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ * @see Math#addExact(int,int)
+ * @since 1.8
+ */
+ public static int addExact(int x, int y) {
+ return Math.addExact(x, y);
+ }
+
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ * @see Math#addExact(long,long)
+ * @since 1.8
+ */
+ public static long addExact(long x, long y) {
+ return Math.addExact(x, y);
+ }
+
+ /**
+ * Return the difference of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ * @see Math#subtractExact(int,int)
+ * @since 1.8
+ */
+ public static int subtractExact(int x, int y) {
+ return Math.subtractExact(x, y);
+ }
+
+ /**
+ * Return the difference of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ * @see Math#subtractExact(long,long)
+ * @since 1.8
+ */
+ public static long subtractExact(long x, long y) {
+ return Math.subtractExact(x, y);
+ }
+
+ /**
+ * Return the product of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ * @see Math#multiplyExact(int,int)
+ * @since 1.8
+ */
+ public static int multiplyExact(int x, int y) {
+ return Math.multiplyExact(x, y);
+ }
+
+ /**
+ * Return the product of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ * @see Math#multiplyExact(long,long)
+ * @since 1.8
+ */
+ public static long multiplyExact(long x, long y) {
+ return Math.multiplyExact(x, y);
+ }
+
+ /**
+ * Return the value of the {@code long} argument;
+ * throwing an exception if the value overflows an {@code int}.
+ *
+ * @param value the long value
+ * @return the argument as an int
+ * @throws ArithmeticException if the {@code argument} overflows an int
+ * @see Math#toIntExact(int)
+ * @since 1.8
+ */
+ public static int toIntExact(long value) {
+ return Math.toIntExact(value);
+ }
+
+ /**
+ * Returns the absolute value of an {@code int} value.
* If the argument is not negative, the argument is returned.
* If the argument is negative, the negation of the argument is returned.
*
--- a/jdk/src/share/classes/java/lang/System.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/lang/System.java Fri Mar 02 09:13:13 2012 -0800
@@ -1100,6 +1100,19 @@
public static native String mapLibraryName(String libname);
/**
+ * Create PrintStream for stdout/err based on encoding.
+ */
+ private static PrintStream newPrintStream(FileOutputStream fos, String enc) {
+ if (enc != null) {
+ try {
+ return new PrintStream(new BufferedOutputStream(fos, 128), true, enc);
+ } catch (UnsupportedEncodingException uee) {}
+ }
+ return new PrintStream(new BufferedOutputStream(fos, 128), true);
+ }
+
+
+ /**
* Initialize the system class. Called after thread initialization.
*/
private static void initializeSystemClass() {
@@ -1139,8 +1152,9 @@
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
setIn0(new BufferedInputStream(fdIn));
- setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
- setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
+ setOut0(newPrintStream(fdOut, props.getProperty("sun.stdout.encoding")));
+ setErr0(newPrintStream(fdErr, props.getProperty("sun.stderr.encoding")));
+
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary("zip");
--- a/jdk/src/share/classes/java/lang/management/ManagementPermission.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/lang/management/ManagementPermission.java Fri Mar 02 09:13:13 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 @@
* <tr>
* <td>control</td>
* <td>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.
* </td>
* <td>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.
* </td>
* </tr>
* <tr>
--- a/jdk/src/share/classes/java/util/TimeZone.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/TimeZone.java Fri Mar 02 09:13:13 2012 -0800
@@ -43,6 +43,8 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ConcurrentHashMap;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaAWTAccess;
import sun.security.action.GetPropertyAction;
import sun.util.TimeZoneNameUtility;
import sun.util.calendar.ZoneInfo;
@@ -615,7 +617,7 @@
* method doesn't create a clone.
*/
static TimeZone getDefaultRef() {
- TimeZone defaultZone = defaultZoneTL.get();
+ TimeZone defaultZone = getDefaultInAppContext();
if (defaultZone == null) {
defaultZone = defaultTimeZone;
if (defaultZone == null) {
@@ -706,10 +708,65 @@
if (hasPermission()) {
synchronized (TimeZone.class) {
defaultTimeZone = zone;
- defaultZoneTL.set(null);
+ setDefaultInAppContext(null);
}
} else {
- defaultZoneTL.set(zone);
+ setDefaultInAppContext(zone);
+ }
+ }
+
+ /**
+ * Returns the default TimeZone in an AppContext if any AppContext
+ * has ever used. null is returned if any AppContext hasn't been
+ * used or if the AppContext doesn't have the default TimeZone.
+ */
+ private synchronized static TimeZone getDefaultInAppContext() {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+
+ // Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ // been loaded. If so, it implies that AWTSecurityManager is not our
+ // SecurityManager and we can use a local static variable.
+ // This works around a build time issue.
+ if (javaAWTAccess == null) {
+ return mainAppContextDefault;
+ } else {
+ if (!javaAWTAccess.isDisposed()) {
+ TimeZone tz = (TimeZone)
+ javaAWTAccess.get(TimeZone.class);
+ if (tz == null && javaAWTAccess.isMainAppContext()) {
+ return mainAppContextDefault;
+ } else {
+ return tz;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets the default TimeZone in the AppContext to the given
+ * tz. null is handled special: do nothing if any AppContext
+ * hasn't been used, remove the default TimeZone in the
+ * AppContext otherwise.
+ */
+ private synchronized static void setDefaultInAppContext(TimeZone tz) {
+ // JavaAWTAccess provides access implementation-private methods without using reflection.
+ JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess();
+
+ // Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
+ // been loaded. If so, it implies that AWTSecurityManager is not our
+ // SecurityManager and we can use a local static variable.
+ // This works around a build time issue.
+ if (javaAWTAccess == null) {
+ mainAppContextDefault = tz;
+ } else {
+ if (!javaAWTAccess.isDisposed()) {
+ javaAWTAccess.put(TimeZone.class, tz);
+ if (javaAWTAccess.isMainAppContext()) {
+ mainAppContextDefault = null;
+ }
+ }
}
}
@@ -760,12 +817,13 @@
*/
private String ID;
private static volatile TimeZone defaultTimeZone;
- private static final InheritableThreadLocal<TimeZone> defaultZoneTL
- = new InheritableThreadLocal<TimeZone>();
static final String GMT_ID = "GMT";
private static final int GMT_ID_LENGTH = 3;
+ // a static TimeZone we can reference if no AppContext is in place
+ private static TimeZone mainAppContextDefault;
+
/**
* Parses a custom time zone identifier and returns a corresponding zone.
* This method doesn't support the RFC 822 time zone format. (e.g., +hhmm)
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Fri Mar 02 09:13:13 2012 -0800
@@ -34,8 +34,10 @@
*/
package java.util.concurrent.atomic;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
import sun.misc.Unsafe;
-import java.util.*;
/**
* An array of object references in which elements may be updated
@@ -49,13 +51,23 @@
public class AtomicReferenceArray<E> implements java.io.Serializable {
private static final long serialVersionUID = -6209656149925076980L;
- private static final Unsafe unsafe = Unsafe.getUnsafe();
- private static final int base = unsafe.arrayBaseOffset(Object[].class);
+ private static final Unsafe unsafe;
+ private static final int base;
private static final int shift;
- private final Object[] array;
+ private static final long arrayFieldOffset;
+ private final Object[] array; // must have exact type Object[]
static {
- int scale = unsafe.arrayIndexScale(Object[].class);
+ int scale;
+ try {
+ unsafe = Unsafe.getUnsafe();
+ arrayFieldOffset = unsafe.objectFieldOffset
+ (AtomicReferenceArray.class.getDeclaredField("array"));
+ base = unsafe.arrayBaseOffset(Object[].class);
+ scale = unsafe.arrayIndexScale(Object[].class);
+ } catch (Exception e) {
+ throw new Error(e);
+ }
if ((scale & (scale - 1)) != 0)
throw new Error("data type scale not a power of two");
shift = 31 - Integer.numberOfLeadingZeros(scale);
@@ -91,7 +103,7 @@
*/
public AtomicReferenceArray(E[] array) {
// Visibility guaranteed by final field guarantees
- this.array = array.clone();
+ this.array = Arrays.copyOf(array, array.length, Object[].class);
}
/**
@@ -197,7 +209,7 @@
* @return the String representation of the current values of array
*/
public String toString() {
- int iMax = array.length - 1;
+ int iMax = array.length - 1;
if (iMax == -1)
return "[]";
@@ -211,4 +223,19 @@
}
}
+ /**
+ * Reconstitutes the instance from a stream (that is, deserializes it).
+ * @param s the stream
+ */
+ private void readObject(java.io.ObjectInputStream s)
+ throws java.io.IOException, ClassNotFoundException {
+ // Note: This must be changed if any additional fields are defined
+ Object a = s.readFields().get("array", null);
+ if (a == null || !a.getClass().isArray())
+ throw new java.io.InvalidObjectException("Not array type");
+ if (a.getClass() != Object[].class)
+ a = Arrays.copyOf((Object[])a, Array.getLength(a), Object[].class);
+ unsafe.putObjectVolatile(this, arrayFieldOffset, a);
+ }
+
}
--- a/jdk/src/share/classes/java/util/jar/Attributes.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/jar/Attributes.java Fri Mar 02 09:13:13 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<Map.Entry<Object, Object>> it = entrySet().iterator();
while (it.hasNext()) {
- Map.Entry e = (Map.Entry)it.next();
+ Map.Entry<Object, Object> 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<Map.Entry<Object, Object>> it = entrySet().iterator();
while (it.hasNext()) {
- Map.Entry e = (Map.Entry)it.next();
+ Map.Entry<Object, Object> 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<String> c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
return c.compare(name, ((Name)o).name) == 0;
} else {
return false;
--- a/jdk/src/share/classes/java/util/jar/JarOutputStream.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/jar/JarOutputStream.java Fri Mar 02 09:13:13 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);
}
/*
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java Fri Mar 02 09:13:13 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<String, CodeSigner[]> 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<String, CodeSigner[]> sigFileSigners;
/* a hash table to hold .SF bytes */
- private Hashtable sigFileData;
+ private Hashtable<String, byte[]> sigFileData;
/** "queue" of pending PKCS7 blocks that we couldn't parse
* until we parsed the .SF file */
- private ArrayList pendingBlocks;
+ private ArrayList<SignatureFileVerifier> pendingBlocks;
/* cache of CodeSigner objects */
- private ArrayList signerCache;
+ private ArrayList<CodeSigner[]> 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<SignatureFileVerifier> 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<java.security.cert.Certificate> 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<URL, Map<CodeSigner[], CodeSource>> urlToCodeSourceMap = new HashMap<>();
+ private Map<CodeSigner[], CodeSource> signerToCodeSource = new HashMap<>();
private URL lastURL;
- private Map lastURLMap;
+ private Map<CodeSigner[], CodeSource> 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<CodeSigner[], CodeSource> 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<CodeSigner[]> signers, boolean unsigned) {
+ List<CodeSource> 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<CodeSource> 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<String, CodeSigner[]> signerMap;
- private synchronized Map signerMap() {
+ private synchronized Map<String, CodeSigner[]> 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<String> entryNames(JarFile jar, final CodeSource[] cs) {
- final Map map = signerMap();
- final Iterator itor = map.entrySet().iterator();
+ final Map<String, CodeSigner[]> map = signerMap();
+ final Iterator<Map.Entry<String, CodeSigner[]>> 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<CodeSigner[]> 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<CodeSigner[]> signersReq = req;
+ final Enumeration<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
return new Enumeration<String>() {
@@ -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<String, CodeSigner[]> 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<JarEntry> entries2(final JarFile jar, Enumeration e) {
- final Map map = new HashMap();
+ public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<? extends ZipEntry> e) {
+ final Map<String, CodeSigner[]> map = new HashMap<>();
map.putAll(signerMap());
- final Enumeration enum_ = e;
+ final Enumeration<? extends ZipEntry> enum_ = e;
return new Enumeration<JarEntry>() {
- Enumeration signers = null;
+ Enumeration<String> 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<String>() {
+ private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
public boolean hasMoreElements() {
return false;
@@ -797,8 +796,8 @@
}
private Enumeration<String> unsignedEntryNames(JarFile jar) {
- final Map map = signerMap();
- final Enumeration entries = jar.entries();
+ final Map<String, CodeSigner[]> map = signerMap();
+ final Enumeration<JarEntry> entries = jar.entries();
return new Enumeration<String>() {
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<CodeSigner[]> jarCodeSigners;
- private synchronized List getJarCodeSigners() {
+ private synchronized List<CodeSigner[]> getJarCodeSigners() {
CodeSigner[] signers;
if (jarCodeSigners == null) {
- HashSet set = new HashSet();
+ HashSet<CodeSigner[]> 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);
}
--- a/jdk/src/share/classes/java/util/jar/Manifest.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/jar/Manifest.java Fri Mar 02 09:13:13 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 {
--- a/jdk/src/share/classes/java/util/zip/InflaterInputStream.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/zip/InflaterInputStream.java Fri Mar 02 09:13:13 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]);
}
/**
--- a/jdk/src/share/classes/java/util/zip/ZipInputStream.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/java/util/zip/ZipInputStream.java Fri Mar 02 09:13:13 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);
}
/*
--- a/jdk/src/share/classes/javax/crypto/CipherSpi.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/crypto/CipherSpi.java Fri Mar 02 09:13:13 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;
}
--- a/jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java Fri Mar 02 09:13:13 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 <a href=
- * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+ * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
* Java Cryptography Architecture API Specification & Reference </a>
* for information about standard algorithm names.
* <p>
@@ -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 <a href=
- * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+ * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
* Java Cryptography Architecture API Specification & Reference </a>
* for information about standard algorithm names.
*
--- a/jdk/src/share/classes/javax/net/ssl/SSLParameters.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/net/ssl/SSLParameters.java Fri Mar 02 09:13:13 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 <a href=
- * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+ * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
* Java Cryptography Architecture API Specification & Reference </a>
* for information about standard algorithm names.
*
--- a/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java Fri Mar 02 09:13:13 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);
}
/**
--- a/jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java Fri Mar 02 09:13:13 2012 -0800
@@ -141,7 +141,7 @@
* Returns the string table for class ReferenceUriSchemesSupported.
*/
protected String[] getStringTable() {
- return (String[])myStringTable.clone();
+ return myStringTable.clone();
}
/**
--- a/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/security/auth/x500/X500Principal.java Fri Mar 02 09:13:13 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.
*
+ * <p>This implementation enforces a more restrictive OID syntax than
+ * defined in RFC 1779 and 2253. It uses the more correct syntax defined in
+ * <a href="http://www.ietf.org/rfc/rfc4512.txt">RFC 4512</a>, which
+ * specifies that OIDs contain at least 2 digits:
+ *
+ * <p>{@code numericoid = number 1*( DOT number ) }
+ *
* @param name an X.500 distinguished name in RFC 1779 or RFC 2253 format
* @exception NullPointerException if the <code>name</code>
* is <code>null</code>
@@ -135,10 +142,17 @@
* keywords recognized by <code>X500Principal(String)</code>. 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
* <code>IllegalArgumentException</code> is thrown. It is permissible to
* have 2 different keywords that map to the same OID.
*
+ * <p>This implementation enforces a more restrictive OID syntax than
+ * defined in RFC 1779 and 2253. It uses the more correct syntax defined in
+ * <a href="http://www.ietf.org/rfc/rfc4512.txt">RFC 4512</a>, which
+ * specifies that OIDs contain at least 2 digits:
+ *
+ * <p>{@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
--- a/jdk/src/share/classes/javax/security/auth/x500/package.html Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/security/auth/x500/package.html Fri Mar 02 09:13:13 2012 -0800
@@ -2,7 +2,7 @@
<html>
<head>
<!--
-Copyright (c) 2000, 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
@@ -30,17 +30,26 @@
<body bgcolor="white">
This package contains the classes that should be used to store
- X500 Principal and X500 Private Crendentials in a
+ X500 Principal and X500 Private Credentials in a
<i>Subject</i>.
-<!--
<h2>Package Specification</h2>
-##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
<ul>
- <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
+ <li><a href="http://www.ietf.org/rfc/rfc1779.txt">
+ RFC 1779: A String Representation of Distinguished Names</a></li>
+ <li><a href="http://www.ietf.org/rfc/rfc2253.txt">
+ RFC 2253: Lightweight Directory Access Protocol (v3):
+ UTF-8 String Representation of Distinguished Names</a></li>
+ <li><a href="http://www.ietf.org/rfc/rfc3280.txt">
+ RFC 3280: Internet X.509 Public Key Infrastructure
+ Certificate and Certificate Revocation List (CRL) Profile</a></li>
+ <li><a href="http://www.ietf.org/rfc/rfc4512.txt">
+ RFC 4512: Lightweight Directory Access Protocol (LDAP):
+ Directory Information Models</a></li>
</ul>
+<!--
<h2>Related Documentation</h2>
For overviews, tutorials, examples, guides, and tool documentation, please see:
--- a/jdk/src/share/classes/javax/swing/JOptionPane.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/JOptionPane.java Fri Mar 02 09:13:13 2012 -0800
@@ -34,7 +34,6 @@
import java.awt.Frame;
import java.awt.Point;
import java.awt.HeadlessException;
-import java.awt.Toolkit;
import java.awt.Window;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -994,8 +993,7 @@
// if the user closed the window without selecting a button
// (newValue = null in that case). Otherwise, close the dialog.
if (dialog.isVisible() && event.getSource() == JOptionPane.this &&
- (event.getPropertyName().equals(VALUE_PROPERTY) ||
- event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) &&
+ (event.getPropertyName().equals(VALUE_PROPERTY)) &&
event.getNewValue() != null &&
event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
dialog.setVisible(false);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java Fri Mar 02 09:13:13 2012 -0800
@@ -1236,6 +1236,7 @@
int index = list.locationToIndex(e.getPoint());
optionPane.setInputValue(list.getModel().getElementAt(index));
+ optionPane.setValue(JOptionPane.OK_OPTION);
}
}
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java Fri Mar 02 09:13:13 2012 -0800
@@ -434,6 +434,8 @@
// Empty out the renderer pane, allowing renderers to be gc'ed.
rendererPane.removeAll();
+
+ paintContext = null;
}
private void configureRenderer(SynthContext context) {
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java Fri Mar 02 09:13:13 2012 -0800
@@ -156,7 +156,7 @@
protected Color borderSelectionColor;
private boolean isDropCell;
- private boolean fillBackground = true;
+ private boolean fillBackground;
/**
* Set to true after the constructor has run.
--- a/jdk/src/share/classes/sun/awt/AppContext.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/awt/AppContext.java Fri Mar 02 09:13:13 2012 -0800
@@ -787,6 +787,27 @@
}
return changeSupport.getPropertyChangeListeners(propertyName);
}
+
+ // Set up JavaAWTAccess in SharedSecrets
+ static {
+ sun.misc.SharedSecrets.setJavaAWTAccess(new sun.misc.JavaAWTAccess() {
+ public Object get(Object key) {
+ return getAppContext().get(key);
+ }
+ public void put(Object key, Object value) {
+ getAppContext().put(key, value);
+ }
+ public void remove(Object key) {
+ getAppContext().remove(key);
+ }
+ public boolean isDisposed() {
+ return getAppContext().isDisposed();
+ }
+ public boolean isMainAppContext() {
+ return (numAppContexts == 1);
+ }
+ });
+ }
}
final class MostRecentKeyValue {
--- a/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -185,6 +185,7 @@
theConsumer.setDimensions(image.getWidth(), image.getHeight());
theConsumer.setProperties(properties);
sendPixels();
+ theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
} catch (NullPointerException e) {
if (theConsumer != null) {
--- a/jdk/src/share/classes/sun/beans/infos/ComponentBeanInfo.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/beans/infos/ComponentBeanInfo.java Fri Mar 02 09:13:13 2012 -0800
@@ -32,7 +32,7 @@
*/
public class ComponentBeanInfo extends SimpleBeanInfo {
- private static final Class beanClass = java.awt.Component.class;
+ private static final Class<java.awt.Component> beanClass = java.awt.Component.class;
public PropertyDescriptor[] getPropertyDescriptors() {
try {
--- a/jdk/src/share/classes/sun/font/FileFont.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/font/FileFont.java Fri Mar 02 09:13:13 2012 -0800
@@ -163,7 +163,9 @@
}
}
}
- scaler.dispose();
+ if (scaler != null) {
+ scaler.dispose();
+ }
scaler = FontScaler.getNullScaler();
}
--- a/jdk/src/share/classes/sun/font/StandardGlyphVector.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/font/StandardGlyphVector.java Fri Mar 02 09:13:13 2012 -0800
@@ -1740,8 +1740,9 @@
tx,
sgv.font.getStyle(),
aa, fm);
-
- FontStrike strike = sgv.font2D.getStrike(desc); // !!! getStrike(desc, false)
+ // Get the strike via the handle. Shouldn't matter
+ // if we've invalidated the font but its an extra precaution.
+ FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc); // !!! getStrike(desc, false)
return new GlyphStrike(sgv, strike, dx, dy);
}
--- a/jdk/src/share/classes/sun/font/SunFontManager.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/font/SunFontManager.java Fri Mar 02 09:13:13 2012 -0800
@@ -2619,6 +2619,9 @@
physicalFonts.remove(oldFont.fullName);
fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH));
FontFamily.remove(oldFont);
+ if (oldFont instanceof FileFont) {
+ ((FileFont)oldFont).deregisterFontAndClearStrikeCache();
+ }
if (localeFullNamesToFont != null) {
Map.Entry[] mapEntries =
--- a/jdk/src/share/classes/sun/font/TrueTypeFont.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/font/TrueTypeFont.java Fri Mar 02 09:13:13 2012 -0800
@@ -1037,6 +1037,9 @@
if (head_Table != null && head_Table.capacity() >= 18) {
ShortBuffer sb = head_Table.asShortBuffer();
upem = sb.get(9) & 0xffff;
+ if (upem < 16 || upem > 16384) {
+ upem = 2048;
+ }
}
ByteBuffer os2_Table = getTableBuffer(os_2Tag);
--- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Fri Mar 02 09:13:13 2012 -0800
@@ -370,6 +370,17 @@
}
public void validatePipe() {
+ /* This workaround is for the situation when we update the Pipelines
+ * for invalid SurfaceData and run further code when the current
+ * pipeline doesn't support the type of new SurfaceData created during
+ * the current pipeline's work (in place of the invalid SurfaceData).
+ * Usually SurfaceData and Pipelines are repaired (through revalidateAll)
+ * and called again in the exception handlers */
+
+ if (!surfaceData.isValid()) {
+ throw new InvalidPipeException("attempt to validate Pipe with invalid SurfaceData");
+ }
+
surfaceData.validatePipe(this);
}
@@ -1804,7 +1815,12 @@
width += x;
height += y;
}
- if (!getCompClip().intersectsQuickCheckXYXY(x, y, width, height)) {
+
+ try {
+ if (!getCompClip().intersectsQuickCheckXYXY(x, y, width, height)) {
+ return false;
+ }
+ } catch (InvalidPipeException e) {
return false;
}
// REMIND: We could go one step further here and examine the
@@ -1988,8 +2004,8 @@
try {
doCopyArea(x, y, w, h, dx, dy);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
doCopyArea(x, y, w, h, dx, dy);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2120,8 +2136,8 @@
try {
drawpipe.drawLine(this, x1, y1, x2, y2);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawLine(this, x1, y1, x2, y2);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2137,8 +2153,8 @@
try {
drawpipe.drawRoundRect(this, x, y, w, h, arcW, arcH);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawRoundRect(this, x, y, w, h, arcW, arcH);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2154,8 +2170,8 @@
try {
fillpipe.fillRoundRect(this, x, y, w, h, arcW, arcH);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
fillpipe.fillRoundRect(this, x, y, w, h, arcW, arcH);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2171,8 +2187,8 @@
try {
drawpipe.drawOval(this, x, y, w, h);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawOval(this, x, y, w, h);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2188,8 +2204,8 @@
try {
fillpipe.fillOval(this, x, y, w, h);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
fillpipe.fillOval(this, x, y, w, h);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2206,8 +2222,8 @@
try {
drawpipe.drawArc(this, x, y, w, h, startAngl, arcAngl);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawArc(this, x, y, w, h, startAngl, arcAngl);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2224,8 +2240,8 @@
try {
fillpipe.fillArc(this, x, y, w, h, startAngl, arcAngl);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
fillpipe.fillArc(this, x, y, w, h, startAngl, arcAngl);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2241,8 +2257,8 @@
try {
drawpipe.drawPolyline(this, xPoints, yPoints, nPoints);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawPolyline(this, xPoints, yPoints, nPoints);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2258,8 +2274,8 @@
try {
drawpipe.drawPolygon(this, xPoints, yPoints, nPoints);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawPolygon(this, xPoints, yPoints, nPoints);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2275,8 +2291,8 @@
try {
fillpipe.fillPolygon(this, xPoints, yPoints, nPoints);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
fillpipe.fillPolygon(this, xPoints, yPoints, nPoints);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2292,8 +2308,8 @@
try {
drawpipe.drawRect(this, x, y, w, h);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
drawpipe.drawRect(this, x, y, w, h);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2309,8 +2325,8 @@
try {
fillpipe.fillRect(this, x, y, w, h);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
fillpipe.fillRect(this, x, y, w, h);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2358,7 +2374,6 @@
Paint p = paint;
setComposite(AlphaComposite.Src);
setColor(getBackground());
- validatePipe();
fillRect(x, y, w, h);
setPaint(p);
setComposite(c);
@@ -2382,8 +2397,8 @@
try {
shapepipe.draw(this, s);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
shapepipe.draw(this, s);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2412,8 +2427,8 @@
try {
shapepipe.fill(this, s);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
shapepipe.fill(this, s);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2560,10 +2575,17 @@
// Include padding for interpolation/antialiasing if necessary
int pad = isIntegerTranslate ? 0 : 3;
+ Region clip;
+ try {
+ clip = getCompClip();
+ } catch (InvalidPipeException e) {
+ return;
+ }
+
// Determine the region of the image that may contribute to
// the clipped drawing area
Rectangle region = getImageRegion(img,
- getCompClip(),
+ clip,
transform,
xform,
pad, pad);
@@ -2806,8 +2828,8 @@
try {
textpipe.drawString(this, str, x, y);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
textpipe.drawString(this, str, x, y);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2835,8 +2857,8 @@
try {
textpipe.drawString(this, str, x, y);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
textpipe.drawString(this, str, x, y);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2881,8 +2903,8 @@
try {
textpipe.drawGlyphVector(this, gv, x, y);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
textpipe.drawGlyphVector(this, gv, x, y);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2914,8 +2936,8 @@
try {
textpipe.drawChars(this, data, offset, length, x, y);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
textpipe.drawChars(this, data, offset, length, x, y);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2951,8 +2973,8 @@
try {
textpipe.drawChars(this, chData, 0, length, x, y);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
textpipe.drawChars(this, chData, 0, length, x, y);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -2988,8 +3010,8 @@
return imagepipe.copyImage(this, img, dx, dy, sx, sy,
width, height, bgcolor, observer);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
return imagepipe.copyImage(this, img, dx, dy, sx, sy,
width, height, bgcolor, observer);
} catch (InvalidPipeException e2) {
@@ -3025,8 +3047,8 @@
return imagepipe.scaleImage(this, img, x, y, width, height,
bg, observer);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
return imagepipe.scaleImage(this, img, x, y, width, height,
bg, observer);
} catch (InvalidPipeException e2) {
@@ -3061,8 +3083,8 @@
try {
return imagepipe.copyImage(this, img, x, y, bg, observer);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
return imagepipe.copyImage(this, img, x, y, bg, observer);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -3138,8 +3160,8 @@
sx1, sy1, sx2, sy2, bgcolor,
observer);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
return imagepipe.scaleImage(this, img, dx1, dy1, dx2, dy2,
sx1, sy1, sx2, sy2, bgcolor,
observer);
@@ -3187,8 +3209,8 @@
try {
return imagepipe.transformImage(this, img, xform, observer);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
return imagepipe.transformImage(this, img, xform, observer);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
@@ -3213,8 +3235,8 @@
try {
imagepipe.transformImage(this, bImg, op, x, y);
} catch (InvalidPipeException e) {
- revalidateAll();
try {
+ revalidateAll();
imagepipe.transformImage(this, bImg, op, x, y);
} catch (InvalidPipeException e2) {
// Still catching the exception; we are not yet ready to
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLRenderer.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLRenderer.java Fri Mar 02 09:13:13 2012 -0800
@@ -27,6 +27,7 @@
import java.awt.Transparency;
import java.awt.geom.Path2D;
+import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.BufferedRenderPipe;
@@ -46,7 +47,12 @@
int ctxflags =
sg2d.paint.getTransparency() == Transparency.OPAQUE ?
OGLContext.SRC_IS_OPAQUE : OGLContext.NO_CONTEXT_FLAGS;
- OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
+ OGLSurfaceData dstData;
+ try {
+ dstData = (OGLSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
OGLContext.validateContext(dstData, dstData,
sg2d.getCompClip(), sg2d.composite,
null, sg2d.paint, sg2d, ctxflags);
@@ -55,7 +61,12 @@
@Override
protected void validateContextAA(SunGraphics2D sg2d) {
int ctxflags = OGLContext.NO_CONTEXT_FLAGS;
- OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
+ OGLSurfaceData dstData;
+ try {
+ dstData = (OGLSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
OGLContext.validateContext(dstData, dstData,
sg2d.getCompClip(), sg2d.composite,
null, sg2d.paint, sg2d, ctxflags);
@@ -69,7 +80,12 @@
int ctxflags =
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
OGLContext.SRC_IS_OPAQUE : OGLContext.NO_CONTEXT_FLAGS;
- OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
+ OGLSurfaceData dstData;
+ try {
+ dstData = (OGLSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
OGLContext.validateContext(dstData, dstData,
sg2d.getCompClip(), sg2d.composite,
null, null, null, ctxflags);
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedContext.java Fri Mar 02 09:13:13 2012 -0800
@@ -111,6 +111,8 @@
*
* Note: must be called while the RenderQueue lock is held.
*
+ * It's assumed that the type of surfaces has been checked by the Renderer
+ *
* @throws InvalidPipeException if either src or dest surface is not valid
* or lost
* @see RenderQueue#lock
@@ -135,6 +137,8 @@
*
* Note: must be called while the RenderQueue lock is held.
*
+ * It's assumed that the type of surfaces has been checked by the Renderer
+ *
* @throws InvalidPipeException if the surface is not valid
* or lost
* @see RenderQueue#lock
@@ -160,6 +164,8 @@
*
* Note: must be called while the RenderQueue lock is held.
*
+ * It's assumed that the type of surfaces has been checked by the Renderer
+ *
* @throws InvalidPipeException if either src or dest surface is not valid
* or lost
*/
--- a/jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/management/HotSpotDiagnostic.java Fri Mar 02 09:13:13 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
@@ -27,13 +27,9 @@
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import javax.management.ObjectName;
-import com.sun.management.DiagnosticCommandInfo;
-import com.sun.management.DiagnosticCommandArgumentInfo;
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
@@ -120,54 +116,7 @@
}
}
- public List<String> getDiagnosticCommands() {
- String[] commands = getDiagnosticCommands0();
- return commands == null ? Collections.<String>emptyList() :
- Arrays.asList(commands);
- }
-
- public DiagnosticCommandInfo getDiagnosticCommandInfo(String command) {
- String[] array = new String[] { command };
- return getDiagnosticCommandInfo0(array)[0];
- }
-
- public List<DiagnosticCommandInfo> getDiagnosticCommandInfo() {
- String[] commands = getDiagnosticCommands0();
- return Arrays.asList(getDiagnosticCommandInfo0(commands));
- }
-
- public List<DiagnosticCommandInfo> getDiagnosticCommandInfo(
- List<String> commands) {
- return Arrays.asList(getDiagnosticCommandInfo0(
- commands.toArray(new String[commands.size()])));
- }
-
- public String execute(String command) {
- Util.checkControlAccess();
- return executeDiagnosticCommand0(command);
- }
-
- public String execute(String cmd, String... arguments) {
- if(cmd == null) {
- throw new NullPointerException("Missing command name");
- }
- StringBuilder sb = new StringBuilder();
- sb.append(cmd);
- sb.append(" ");
- for(String arg : arguments) {
- sb.append(arg);
- sb.append(" ");
- }
- return execute(sb.toString());
- }
-
public ObjectName getObjectName() {
return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
}
-
- private native String[] getDiagnosticCommands0();
- private native DiagnosticCommandInfo[] getDiagnosticCommandInfo0(
- String[] commands) throws IllegalArgumentException;
- private native String executeDiagnosticCommand0(String command)
- throws IllegalArgumentException;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/misc/JavaAWTAccess.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,34 @@
+/*
+ * 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 sun.misc;
+
+public interface JavaAWTAccess {
+ public Object get(Object key);
+ public void put(Object key, Object value);
+ public void remove(Object key);
+ public boolean isDisposed();
+ public boolean isMainAppContext();
+}
--- a/jdk/src/share/classes/sun/misc/SharedSecrets.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java Fri Mar 02 09:13:13 2012 -0800
@@ -52,6 +52,7 @@
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
private static JavaSecurityAccess javaSecurityAccess;
+ private static JavaAWTAccess javaAWTAccess;
public static JavaUtilJarAccess javaUtilJarAccess() {
if (javaUtilJarAccess == null) {
@@ -150,4 +151,14 @@
}
return javaSecurityAccess;
}
+
+ public static void setJavaAWTAccess(JavaAWTAccess jaa) {
+ javaAWTAccess = jaa;
+ }
+
+ public static JavaAWTAccess getJavaAWTAccess() {
+ // this may return null in which case calling code needs to
+ // provision for.
+ return javaAWTAccess;
+ }
}
--- a/jdk/src/share/classes/sun/net/httpserver/Request.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/net/httpserver/Request.java Fri Mar 02 09:13:13 2012 -0800
@@ -200,6 +200,13 @@
v = new String();
else
v = String.copyValueOf(s, keyend, len - keyend);
+
+ if (hdrs.size() >= ServerConfig.getMaxReqHeaders()) {
+ throw new IOException("Maximum number of request headers (" +
+ "sun.net.httpserver.maxReqHeaders) exceeded, " +
+ ServerConfig.getMaxReqHeaders() + ".");
+ }
+
hdrs.add (k,v);
len = 0;
}
--- a/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java Fri Mar 02 09:13:13 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
@@ -35,32 +35,33 @@
class ServerConfig {
- static int clockTick;
-
- static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.
+ private static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.
/* These values must be a reasonable multiple of clockTick */
- static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min
- static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;
+ private static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min
+ private static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;
- static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
- static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever
- static final long DEFAULT_TIMER_MILLIS = 1000;
-
- static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;
+ private static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
+ private static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever
+ private static final long DEFAULT_TIMER_MILLIS = 1000;
+ private static final int DEFAULT_MAX_REQ_HEADERS = 200;
+ private static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;
- static long idleInterval;
- static long drainAmount; // max # of bytes to drain from an inputstream
- static int maxIdleConnections;
-
+ private static int clockTick;
+ private static long idleInterval;
+ // The maximum number of bytes to drain from an inputstream
+ private static long drainAmount;
+ private static int maxIdleConnections;
+ // The maximum number of request headers allowable
+ private static int maxReqHeaders;
// max time a request or response is allowed to take
- static long maxReqTime;
- static long maxRspTime;
- static long timerMillis;
- static boolean debug;
+ private static long maxReqTime;
+ private static long maxRspTime;
+ private static long timerMillis;
+ private static boolean debug;
// the value of the TCP_NODELAY socket-level option
- static boolean noDelay;
+ private static boolean noDelay;
static {
java.security.AccessController.doPrivileged(
@@ -80,6 +81,10 @@
drainAmount = Long.getLong("sun.net.httpserver.drainAmount",
DEFAULT_DRAIN_AMOUNT);
+ maxReqHeaders = Integer.getInteger(
+ "sun.net.httpserver.maxReqHeaders",
+ DEFAULT_MAX_REQ_HEADERS);
+
maxReqTime = Long.getLong("sun.net.httpserver.maxReqTime",
DEFAULT_MAX_REQ_TIME);
@@ -99,8 +104,7 @@
}
-
- static void checkLegacyProperties (final Logger logger) {
+ static void checkLegacyProperties(final Logger logger) {
// legacy properties that are no longer used
// print a warning to logger if they are set.
@@ -137,35 +141,39 @@
);
}
- static boolean debugEnabled () {
+ static boolean debugEnabled() {
return debug;
}
- static long getIdleInterval () {
+ static long getIdleInterval() {
return idleInterval;
}
- static int getClockTick () {
+ static int getClockTick() {
return clockTick;
}
- static int getMaxIdleConnections () {
+ static int getMaxIdleConnections() {
return maxIdleConnections;
}
- static long getDrainAmount () {
+ static long getDrainAmount() {
return drainAmount;
}
- static long getMaxReqTime () {
+ static int getMaxReqHeaders() {
+ return maxReqHeaders;
+ }
+
+ static long getMaxReqTime() {
return maxReqTime;
}
- static long getMaxRspTime () {
+ static long getMaxRspTime() {
return maxRspTime;
}
- static long getTimerMillis () {
+ static long getTimerMillis() {
return timerMillis;
}
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java Fri Mar 02 09:13:13 2012 -0800
@@ -270,7 +270,7 @@
protected Proxy instProxy;
private CookieHandler cookieHandler;
- private ResponseCache cacheHandler;
+ private final ResponseCache cacheHandler;
// the cached response, and cached response headers and body
protected CacheResponse cachedResponse;
@@ -1579,7 +1579,7 @@
if (respCode == 200 || respCode == 203 || respCode == 206 ||
respCode == 300 || respCode == 301 || respCode == 410) {
- if (cacheHandler != null) {
+ if (cacheHandler != null && getUseCaches()) {
// give cache a chance to save response in cache
URI uri = ParseUtil.toURI(url);
if (uri != null) {
--- a/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java Fri Mar 02 09:13:13 2012 -0800
@@ -35,15 +35,15 @@
* @since 1.4
*/
-abstract class AbstractPollArrayWrapper {
+public abstract class AbstractPollArrayWrapper {
// Event masks
- static final short POLLIN = 0x0001;
- static final short POLLOUT = 0x0004;
- static final short POLLERR = 0x0008;
- static final short POLLHUP = 0x0010;
- static final short POLLNVAL = 0x0020;
- static final short POLLREMOVE = 0x0800;
+ public static final short POLLIN = 0x0001;
+ public static final short POLLOUT = 0x0004;
+ public static final short POLLERR = 0x0008;
+ public static final short POLLHUP = 0x0010;
+ public static final short POLLNVAL = 0x0020;
+ public static final short POLLREMOVE = 0x0800;
// Miscellaneous constants
static final short SIZE_POLLFD = 8;
--- a/jdk/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -67,7 +67,7 @@
this.channelOffset = offset;
}
- void putEventOps(SelectionKeyImpl sk, int ops) {
+ public void putEventOps(SelectionKeyImpl sk, int ops) {
synchronized (closeLock) {
if (closed)
throw new ClosedSelectorException();
--- a/jdk/src/share/classes/sun/nio/ch/IOStatus.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/IOStatus.java Fri Mar 02 09:13:13 2012 -0800
@@ -28,16 +28,16 @@
// Constants for reporting I/O status
-final class IOStatus {
+public final class IOStatus {
private IOStatus() { }
- static final int EOF = -1; // End of file
- static final int UNAVAILABLE = -2; // Nothing available (non-blocking)
- static final int INTERRUPTED = -3; // System call interrupted
- static final int UNSUPPORTED = -4; // Operation not supported
- static final int THROWN = -5; // Exception thrown in JNI code
- static final int UNSUPPORTED_CASE = -6; // This case not supported
+ public static final int EOF = -1; // End of file
+ public static final int UNAVAILABLE = -2; // Nothing available (non-blocking)
+ public static final int INTERRUPTED = -3; // System call interrupted
+ public static final int UNSUPPORTED = -4; // Operation not supported
+ public static final int THROWN = -5; // Exception thrown in JNI code
+ public static final int UNSUPPORTED_CASE = -6; // This case not supported
// The following two methods are for use in try/finally blocks where a
// status value needs to be normalized before being returned to the invoker
@@ -55,28 +55,28 @@
// }
//
- static int normalize(int n) {
+ public static int normalize(int n) {
if (n == UNAVAILABLE)
return 0;
return n;
}
- static boolean check(int n) {
+ public static boolean check(int n) {
return (n >= UNAVAILABLE);
}
- static long normalize(long n) {
+ public static long normalize(long n) {
if (n == UNAVAILABLE)
return 0;
return n;
}
- static boolean check(long n) {
+ public static boolean check(long n) {
return (n >= UNAVAILABLE);
}
// Return true iff n is not one of the IOStatus values
- static boolean checkAll(long n) {
+ public static boolean checkAll(long n) {
return ((n > EOF) || (n < UNSUPPORTED_CASE));
}
--- a/jdk/src/share/classes/sun/nio/ch/IOUtil.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/IOUtil.java Fri Mar 02 09:13:13 2012 -0800
@@ -34,7 +34,7 @@
* File-descriptor based I/O utilities that are shared by NIO classes.
*/
-class IOUtil {
+public class IOUtil {
private IOUtil() { } // No instantiation
@@ -309,7 +309,7 @@
}
}
- static FileDescriptor newFD(int i) {
+ public static FileDescriptor newFD(int i) {
FileDescriptor fd = new FileDescriptor();
setfdVal(fd, i);
return fd;
@@ -326,10 +326,11 @@
static native boolean drain(int fd) throws IOException;
- static native void configureBlocking(FileDescriptor fd, boolean blocking)
+ public static native void configureBlocking(FileDescriptor fd,
+ boolean blocking)
throws IOException;
- static native int fdVal(FileDescriptor fd);
+ public static native int fdVal(FileDescriptor fd);
static native void setfdVal(FileDescriptor fd, int value);
--- a/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/NativeThreadSet.java Fri Mar 02 09:13:13 2012 -0800
@@ -44,8 +44,9 @@
//
int add() {
long th = NativeThread.current();
- if (th == -1)
- return -1;
+ // 0 and -1 are treated as placeholders, not real thread handles
+ if (th == 0)
+ th = -1;
synchronized (this) {
int start = 0;
if (used >= elts.length) {
@@ -71,8 +72,6 @@
// Removes the thread at the given index.
//
void remove(int i) {
- if (i < 0)
- return;
synchronized (this) {
elts[i] = 0;
used--;
@@ -91,7 +90,8 @@
long th = elts[i];
if (th == 0)
continue;
- NativeThread.signal(th);
+ if (th != -1)
+ NativeThread.signal(th);
if (--u == 0)
break;
}
--- a/jdk/src/share/classes/sun/nio/ch/Net.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/Net.java Fri Mar 02 09:13:13 2012 -0800
@@ -33,7 +33,7 @@
import java.security.PrivilegedAction;
-class Net { // package-private
+public class Net {
private Net() { }
@@ -75,7 +75,7 @@
return canJoin6WithIPv4Group0();
}
- static InetSocketAddress checkAddress(SocketAddress sa) {
+ public static InetSocketAddress checkAddress(SocketAddress sa) {
if (sa == null)
throw new NullPointerException();
if (!(sa instanceof InetSocketAddress))
@@ -330,7 +330,7 @@
// Due to oddities SO_REUSEADDR on windows reuse is ignored
private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse);
- static void bind(FileDescriptor fd, InetAddress addr, int port)
+ public static void bind(FileDescriptor fd, InetAddress addr, int port)
throws IOException
{
bind(UNSPEC, fd, addr, port);
@@ -383,7 +383,7 @@
private static native InetAddress localInetAddress(FileDescriptor fd)
throws IOException;
- static InetSocketAddress localAddress(FileDescriptor fd)
+ public static InetSocketAddress localAddress(FileDescriptor fd)
throws IOException
{
return new InetSocketAddress(localInetAddress(fd), localPort(fd));
--- a/jdk/src/share/classes/sun/nio/ch/SctpMessageInfoImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import java.net.SocketAddress;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.Association;
-
-/**
- * An implementation of a MessageInfo.
- */
-public class SctpMessageInfoImpl extends MessageInfo {
- private final SocketAddress address;
- private final int bytes; /* 0 */
-
- private Association association;
- private int assocId;
- private int streamNumber;
- private boolean complete = true;
- private boolean unordered; /* false */
- private long timeToLive; /* 0L */
- private int ppid; /* 0 */
-
- public SctpMessageInfoImpl(Association association,
- SocketAddress address,
- int streamNumber) {
- this.association = association;
- this.address = address;
- this.streamNumber = streamNumber;
- bytes = 0;
- }
-
- /* Invoked from native */
- private SctpMessageInfoImpl(int assocId,
- SocketAddress address,
- int bytes,
- int streamNumber,
- boolean complete,
- boolean unordered,
- int ppid) {
- this.assocId = assocId;
- this.address = address;
- this.bytes = bytes;
- this.streamNumber = streamNumber;
- this.complete = complete;
- this.unordered = unordered;
- this.ppid = ppid;
- }
-
- @Override
- public Association association() {
- return association;
- }
-
- /**
- * SctpMessageInfoImpl instances created from native will need to have their
- * association set from the channel.
- */
- void setAssociation(Association association) {
- this.association = association;
- }
-
- int associationID() {
- return assocId;
- }
-
- @Override
- public SocketAddress address() {
- return address;
- }
-
- @Override
- public int bytes() {
- return bytes;
- }
-
- @Override
- public int streamNumber() {
- return streamNumber;
- }
-
- @Override
- public MessageInfo streamNumber(int streamNumber) {
- if (streamNumber < 0 || streamNumber > 65536)
- throw new IllegalArgumentException("Invalid stream number");
-
- this.streamNumber = streamNumber;
- return this;
- }
-
- @Override
- public int payloadProtocolID() {
- return ppid;
- }
-
- @Override
- public MessageInfo payloadProtocolID(int ppid) {
- this.ppid = ppid;
- return this;
- }
-
- @Override
- public boolean isComplete() {
- return complete;
- }
-
- @Override
- public MessageInfo complete(boolean complete) {
- this.complete = complete;
- return this;
- }
-
- @Override
- public boolean isUnordered() {
- return unordered;
- }
-
- @Override
- public MessageInfo unordered(boolean unordered) {
- this.unordered = unordered;
- return this;
- }
-
- @Override
- public long timeToLive() {
- return timeToLive;
- }
-
- @Override
- public MessageInfo timeToLive(long millis) {
- timeToLive = millis;
- return this;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(super.toString());
- sb.append( "[Address: ").append(address)
- .append(", Association: ").append(association)
- .append(", Assoc ID: ").append(assocId)
- .append(", Bytes: ").append(bytes)
- .append(", Stream Number: ").append(streamNumber)
- .append(", Complete: ").append(complete)
- .append(", isUnordered: ").append(unordered)
- .append("]");
- return sb.toString();
- }
-}
--- a/jdk/src/share/classes/sun/nio/ch/SctpStdSocketOption.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import com.sun.nio.sctp.SctpSocketOption;
-
-public class SctpStdSocketOption<T>
- implements SctpSocketOption<T>
-{
- /* for native mapping of int options */
- public static final int SCTP_DISABLE_FRAGMENTS = 1;
- public static final int SCTP_EXPLICIT_COMPLETE = 2;
- public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
- public static final int SCTP_NODELAY = 4;
- public static final int SO_SNDBUF = 5;
- public static final int SO_RCVBUF = 6;
- public static final int SO_LINGER = 7;
-
- private final String name;
- private final Class<T> type;
-
- /* for native mapping of int options */
- private int constValue;
-
- public SctpStdSocketOption(String name, Class<T> type) {
- this.name = name;
- this.type = type;
- }
-
- public SctpStdSocketOption(String name, Class<T> type, int constValue) {
- this.name = name;
- this.type = type;
- this.constValue = constValue;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public Class<T> type() {
- return type;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- int constValue() {
- return constValue;
- }
-}
--- a/jdk/src/share/classes/sun/nio/ch/SelChImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/SelChImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -36,7 +36,7 @@
* @since 1.4
*/
-interface SelChImpl extends Channel {
+public interface SelChImpl extends Channel {
FileDescriptor getFD();
--- a/jdk/src/share/classes/sun/nio/ch/SelectionKeyImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/SelectionKeyImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -34,12 +34,12 @@
* An implementation of SelectionKey for Solaris.
*/
-class SelectionKeyImpl
+public class SelectionKeyImpl
extends AbstractSelectionKey
{
final SelChImpl channel; // package-private
- final SelectorImpl selector; // package-private
+ public final SelectorImpl selector;
// Index for a pollfd array in Selector that this key is registered with
private int index;
@@ -91,15 +91,15 @@
// The nio versions of these operations do not care if a key
// has been invalidated. They are for internal use by nio code.
- void nioReadyOps(int ops) { // package-private
+ public void nioReadyOps(int ops) {
readyOps = ops;
}
- int nioReadyOps() { // package-private
+ public int nioReadyOps() {
return readyOps;
}
- SelectionKey nioInterestOps(int ops) { // package-private
+ public SelectionKey nioInterestOps(int ops) {
if ((ops & ~channel().validOps()) != 0)
throw new IllegalArgumentException();
channel.translateAndSetInterestOps(ops, this);
@@ -107,7 +107,7 @@
return this;
}
- int nioInterestOps() { // package-private
+ public int nioInterestOps() {
return interestOps;
}
--- a/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -36,7 +36,7 @@
* Base Selector implementation class.
*/
-abstract class SelectorImpl
+public abstract class SelectorImpl
extends AbstractSelector
{
@@ -118,7 +118,7 @@
protected abstract void implClose() throws IOException;
- void putEventOps(SelectionKeyImpl sk, int ops) { }
+ public void putEventOps(SelectionKeyImpl sk, int ops) { }
protected final SelectionKey register(AbstractSelectableChannel ch,
int ops,
--- a/jdk/src/share/classes/sun/nio/ch/Util.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java Fri Mar 02 09:13:13 2012 -0800
@@ -40,7 +40,7 @@
import sun.security.action.GetPropertyAction;
-class Util {
+public class Util {
// -- Caches --
@@ -158,7 +158,7 @@
/**
* Returns a temporary buffer of at least the given size
*/
- static ByteBuffer getTemporaryDirectBuffer(int size) {
+ public static ByteBuffer getTemporaryDirectBuffer(int size) {
BufferCache cache = bufferCache.get();
ByteBuffer buf = cache.get(size);
if (buf != null) {
@@ -178,7 +178,7 @@
/**
* Releases a temporary buffer by returning to the cache or freeing it.
*/
- static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
+ public static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
offerFirstTemporaryDirectBuffer(buf);
}
@@ -467,7 +467,7 @@
private static boolean loaded = false;
- static void load() {
+ public static void load() {
synchronized (Util.class) {
if (loaded)
return;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/sctp/MessageInfoImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.Association;
+
+/**
+ * An implementation of a MessageInfo.
+ */
+public class MessageInfoImpl extends MessageInfo {
+ private final SocketAddress address;
+ private final int bytes; /* 0 */
+
+ private Association association;
+ private int assocId;
+ private int streamNumber;
+ private boolean complete = true;
+ private boolean unordered; /* false */
+ private long timeToLive; /* 0L */
+ private int ppid; /* 0 */
+
+ public MessageInfoImpl(Association association,
+ SocketAddress address,
+ int streamNumber) {
+ this.association = association;
+ this.address = address;
+ this.streamNumber = streamNumber;
+ bytes = 0;
+ }
+
+ /* Invoked from native */
+ private MessageInfoImpl(int assocId,
+ SocketAddress address,
+ int bytes,
+ int streamNumber,
+ boolean complete,
+ boolean unordered,
+ int ppid) {
+ this.assocId = assocId;
+ this.address = address;
+ this.bytes = bytes;
+ this.streamNumber = streamNumber;
+ this.complete = complete;
+ this.unordered = unordered;
+ this.ppid = ppid;
+ }
+
+ @Override
+ public Association association() {
+ return association;
+ }
+
+ /**
+ * MessageInfoImpl instances created from native will need to have their
+ * association set from the channel.
+ */
+ void setAssociation(Association association) {
+ this.association = association;
+ }
+
+ int associationID() {
+ return assocId;
+ }
+
+ @Override
+ public SocketAddress address() {
+ return address;
+ }
+
+ @Override
+ public int bytes() {
+ return bytes;
+ }
+
+ @Override
+ public int streamNumber() {
+ return streamNumber;
+ }
+
+ @Override
+ public MessageInfo streamNumber(int streamNumber) {
+ if (streamNumber < 0 || streamNumber > 65536)
+ throw new IllegalArgumentException("Invalid stream number");
+
+ this.streamNumber = streamNumber;
+ return this;
+ }
+
+ @Override
+ public int payloadProtocolID() {
+ return ppid;
+ }
+
+ @Override
+ public MessageInfo payloadProtocolID(int ppid) {
+ this.ppid = ppid;
+ return this;
+ }
+
+ @Override
+ public boolean isComplete() {
+ return complete;
+ }
+
+ @Override
+ public MessageInfo complete(boolean complete) {
+ this.complete = complete;
+ return this;
+ }
+
+ @Override
+ public boolean isUnordered() {
+ return unordered;
+ }
+
+ @Override
+ public MessageInfo unordered(boolean unordered) {
+ this.unordered = unordered;
+ return this;
+ }
+
+ @Override
+ public long timeToLive() {
+ return timeToLive;
+ }
+
+ @Override
+ public MessageInfo timeToLive(long millis) {
+ timeToLive = millis;
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString());
+ sb.append( "[Address: ").append(address)
+ .append(", Association: ").append(association)
+ .append(", Assoc ID: ").append(assocId)
+ .append(", Bytes: ").append(bytes)
+ .append(", Stream Number: ").append(streamNumber)
+ .append(", Complete: ").append(complete)
+ .append(", isUnordered: ").append(unordered)
+ .append("]");
+ return sb.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.SctpSocketOption;
+
+public class SctpStdSocketOption<T>
+ implements SctpSocketOption<T>
+{
+ /* for native mapping of int options */
+ public static final int SCTP_DISABLE_FRAGMENTS = 1;
+ public static final int SCTP_EXPLICIT_COMPLETE = 2;
+ public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
+ public static final int SCTP_NODELAY = 4;
+ public static final int SO_SNDBUF = 5;
+ public static final int SO_RCVBUF = 6;
+ public static final int SO_LINGER = 7;
+
+ private final String name;
+ private final Class<T> type;
+
+ /* for native mapping of int options */
+ private int constValue;
+
+ public SctpStdSocketOption(String name, Class<T> type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public SctpStdSocketOption(String name, Class<T> type, int constValue) {
+ this.name = name;
+ this.type = type;
+ this.constValue = constValue;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public Class<T> type() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ int constValue() {
+ return constValue;
+ }
+}
--- a/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java Fri Mar 02 09:13:13 2012 -0800
@@ -141,7 +141,7 @@
if (s == null) {
return getInstance();
} else {
- return getInstance0(s);
+ return getInstance0(parse(s));
}
}
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS7.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs/PKCS7.java Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2011, 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
@@ -72,16 +72,19 @@
/*
* Random number generator for creating nonce values
+ * (Lazy initialization)
*/
- private static final SecureRandom RANDOM;
- static {
- SecureRandom tmp = null;
- try {
- tmp = SecureRandom.getInstance("SHA1PRNG");
- } catch (NoSuchAlgorithmException e) {
- // should not happen
+ private static class SecureRandomHolder {
+ static final SecureRandom RANDOM;
+ static {
+ SecureRandom tmp = null;
+ try {
+ tmp = SecureRandom.getInstance("SHA1PRNG");
+ } catch (NoSuchAlgorithmException e) {
+ // should not happen
+ }
+ RANDOM = tmp;
}
- RANDOM = tmp;
}
/*
@@ -862,8 +865,8 @@
// Generate a nonce
BigInteger nonce = null;
- if (RANDOM != null) {
- nonce = new BigInteger(64, RANDOM);
+ if (SecureRandomHolder.RANDOM != null) {
+ nonce = new BigInteger(64, SecureRandomHolder.RANDOM);
tsQuery.setNonce(nonce);
}
tsQuery.requestCertificate(true);
--- a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java Fri Mar 02 09:13:13 2012 -0800
@@ -253,11 +253,25 @@
}
try {
- // Use JCE
- SecretKey skey = getPBEKey(password);
- Cipher cipher = Cipher.getInstance(algOid.toString());
- cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
- byte[] privateKeyInfo = cipher.doFinal(encryptedKey);
+ byte[] privateKeyInfo;
+ while (true) {
+ try {
+ // Use JCE
+ SecretKey skey = getPBEKey(password);
+ Cipher cipher = Cipher.getInstance(algOid.toString());
+ cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
+ privateKeyInfo = cipher.doFinal(encryptedKey);
+ break;
+ } catch (Exception e) {
+ if (password.length == 0) {
+ // Retry using an empty password
+ // without a NULL terminator.
+ password = new char[1];
+ continue;
+ }
+ throw e;
+ }
+ }
PKCS8EncodedKeySpec kspec = new PKCS8EncodedKeySpec(privateKeyInfo);
@@ -1251,16 +1265,24 @@
ObjectIdentifier algOid = in.getOID();
AlgorithmParameters algParams = parseAlgParameters(in);
- try {
- // Use JCE
- SecretKey skey = getPBEKey(password);
- Cipher cipher = Cipher.getInstance(algOid.toString());
- cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
- safeContentsData = cipher.doFinal(safeContentsData);
-
- } catch (Exception e) {
- throw new IOException("failed to decrypt safe"
- + " contents entry: " + e, e);
+ while (true) {
+ try {
+ // Use JCE
+ SecretKey skey = getPBEKey(password);
+ Cipher cipher = Cipher.getInstance(algOid.toString());
+ cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
+ safeContentsData = cipher.doFinal(safeContentsData);
+ break;
+ } catch (Exception e) {
+ if (password.length == 0) {
+ // Retry using an empty password
+ // without a NULL terminator.
+ password = new char[1];
+ continue;
+ }
+ throw new IOException(
+ "failed to decrypt safe contents entry: " + e, e);
+ }
}
} else {
throw new IOException("public key protected PKCS12" +
--- a/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java Fri Mar 02 09:13:13 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
@@ -661,7 +661,10 @@
+ "\n Subject: " + cert.getSubjectX500Principal() + ")");
}
- ForwardState currState = (ForwardState) currentState;
+ ForwardState currState = (ForwardState)currentState;
+
+ // Don't bother to verify untrusted certificate more.
+ currState.untrustedChecker.check(cert, Collections.<String>emptySet());
/*
* check for looping - abort a loop if
--- a/jdk/src/share/classes/sun/security/provider/certpath/ForwardState.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ForwardState.java Fri Mar 02 09:13:13 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
@@ -79,6 +79,9 @@
/* the checker used for revocation status */
public CrlRevocationChecker crlChecker;
+ /* the untrusted certificates checker */
+ UntrustedChecker untrustedChecker;
+
/* The list of user-defined checkers that support forward checking */
ArrayList<PKIXCertPathChecker> forwardCheckers;
--- a/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java Fri Mar 02 09:13:13 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
@@ -314,10 +314,12 @@
pkixParam.isAnyPolicyInhibited(),
pkixParam.getPolicyQualifiersRejected(),
rootNode);
+ UntrustedChecker untrustedChecker = new UntrustedChecker();
ArrayList<PKIXCertPathChecker> certPathCheckers =
new ArrayList<PKIXCertPathChecker>();
// add standard checkers that we will be using
+ certPathCheckers.add(untrustedChecker);
certPathCheckers.add(algorithmChecker);
certPathCheckers.add(keyChecker);
certPathCheckers.add(constraintsChecker);
--- a/jdk/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java Fri Mar 02 09:13:13 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
@@ -347,6 +347,10 @@
return;
}
+ // Don't bother to verify untrusted certificate more.
+ currentState.untrustedChecker.check(cert,
+ Collections.<String>emptySet());
+
/*
* check for looping - abort a loop if
* ((we encounter the same certificate twice) AND
--- a/jdk/src/share/classes/sun/security/provider/certpath/ReverseState.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ReverseState.java Fri Mar 02 09:13:13 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
@@ -99,6 +99,9 @@
/* the algorithm checker */
AlgorithmChecker algorithmChecker;
+ /* the untrusted certificates checker */
+ UntrustedChecker untrustedChecker;
+
/* the trust anchor used to validate the path */
TrustAnchor trustAnchor;
--- a/jdk/src/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java Fri Mar 02 09:13:13 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
@@ -284,6 +284,7 @@
Iterator<TrustAnchor> iter = buildParams.getTrustAnchors().iterator();
while (iter.hasNext()) {
TrustAnchor anchor = iter.next();
+
/* check if anchor satisfies target constraints */
if (anchorIsTarget(anchor, targetSel)) {
this.trustAnchor = anchor;
@@ -303,6 +304,7 @@
currentState.crlChecker =
new CrlRevocationChecker(null, buildParams, null, onlyEECert);
currentState.algorithmChecker = new AlgorithmChecker(anchor);
+ currentState.untrustedChecker = new UntrustedChecker();
try {
depthFirstSearchReverse(null, currentState,
new ReverseBuilder(buildParams, targetSubjectDN), adjacencyList,
@@ -349,6 +351,7 @@
// init the crl checker
currentState.crlChecker
= new CrlRevocationChecker(null, buildParams, null, onlyEECert);
+ currentState.untrustedChecker = new UntrustedChecker();
depthFirstSearchForward(targetSubjectDN, currentState,
new ForwardBuilder
@@ -645,8 +648,8 @@
vertex.setIndex(adjList.size() - 1);
/* recursively search for matching certs at next dN */
- depthFirstSearchForward(cert.getIssuerX500Principal(), nextState, builder,
- adjList, certPathList);
+ depthFirstSearchForward(cert.getIssuerX500Principal(),
+ nextState, builder, adjList, certPathList);
/*
* If path has been completed, return ASAP!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/security/provider/certpath/UntrustedChecker.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.provider.certpath;
+
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.PKIXCertPathChecker;
+import java.util.Set;
+import java.util.Collection;
+import sun.security.util.Debug;
+import sun.security.util.UntrustedCertificates;
+
+/**
+ * A <code>PKIXCertPathChecker</code> implementation to check whether a
+ * specified certificate is distrusted.
+ *
+ * @see PKIXCertPathChecker
+ * @see PKIXParameters
+ */
+final public class UntrustedChecker extends PKIXCertPathChecker {
+
+ private static final Debug debug = Debug.getInstance("certpath");
+
+ /**
+ * Default Constructor
+ */
+ public UntrustedChecker() {
+ // blank
+ }
+
+ @Override
+ public void init(boolean forward) throws CertPathValidatorException {
+ // Note that this class supports both forward and reverse modes.
+ }
+
+ @Override
+ public boolean isForwardCheckingSupported() {
+ // Note that this class supports both forward and reverse modes.
+ return true;
+ }
+
+ @Override
+ public Set<String> getSupportedExtensions() {
+ return null;
+ }
+
+ @Override
+ public void check(Certificate cert,
+ Collection<String> unresolvedCritExts)
+ throws CertPathValidatorException {
+
+ X509Certificate currCert = (X509Certificate)cert;
+
+ if (UntrustedCertificates.isUntrusted(currCert)) {
+ if (debug != null) {
+ debug.println("UntrustedChecker: untrusted certificate " +
+ currCert.getSubjectX500Principal());
+ }
+
+ throw new CertPathValidatorException(
+ "Untrusted certificate: " + currCert.getSubjectX500Principal());
+ }
+ }
+}
+
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Fri Mar 02 09:13:13 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
@@ -31,6 +31,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyException;
import java.security.SecureRandom;
+import java.security.KeyManagementException;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
@@ -423,6 +424,17 @@
// Is the cipher algorithm of Cipher Block Chaining (CBC) mode?
final boolean isCBCMode;
+ // The secure random used to detect the cipher availability.
+ private final static SecureRandom secureRandom;
+
+ static {
+ try {
+ secureRandom = JsseJce.getSecureRandom();
+ } catch (KeyManagementException kme) {
+ throw new RuntimeException(kme);
+ }
+ }
+
BulkCipher(String transformation, int keySize,
int expandedKeySize, int ivSize, boolean allowed) {
this.transformation = transformation;
@@ -505,7 +517,7 @@
IvParameterSpec iv =
new IvParameterSpec(new byte[cipher.ivSize]);
cipher.newCipher(ProtocolVersion.DEFAULT,
- key, iv, null, true);
+ key, iv, secureRandom, true);
b = Boolean.TRUE;
} catch (NoSuchAlgorithmException e) {
b = Boolean.FALSE;
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java Fri Mar 02 09:13:13 2012 -0800
@@ -2117,19 +2117,24 @@
if (caks != null) {
issuer = verifyCRL(caks, crl);
if (issuer != null) {
- System.out.println("Verified by " + issuer + " in cacerts");
+ out.printf(rb.getString(
+ "verified.by.s.in.s"), issuer, "cacerts");
+ out.println();
}
}
if (issuer == null && keyStore != null) {
issuer = verifyCRL(keyStore, crl);
if (issuer != null) {
- System.out.println("Verified by " + issuer + " in keystore");
+ out.printf(rb.getString(
+ "verified.by.s.in.s"), issuer, "keystore");
+ out.println();
}
}
if (issuer == null) {
out.println(rb.getString
("STAR"));
- out.println("WARNING: not verified. Make sure -keystore and -alias are correct.");
+ out.println(rb.getString
+ ("warning.not.verified.make.sure.keystore.is.correct"));
out.println(rb.getString
("STARNN"));
}
--- a/jdk/src/share/classes/sun/security/util/Resources.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/util/Resources.java Fri Mar 02 09:13:13 2012 -0800
@@ -409,6 +409,10 @@
{"Please.provide.keysize.for.secret.key.generation",
"Please provide -keysize for secret key generation"},
+ {"verified.by.s.in.s", "Verified by %s in %s"},
+ {"warning.not.verified.make.sure.keystore.is.correct",
+ "WARNING: not verified. Make sure -keystore is correct."},
+
{"Extensions.", "Extensions: "},
{".Empty.value.", "(Empty value)"},
{"Extension.Request.", "Extension Request:"},
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/security/util/UntrustedCertificates.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,741 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.security.util;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.security.cert.X509Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.CertificateException;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * A utility class to check if a certificate is untrusted. This is an internal
+ * mechanism that explicitly marks a certificate as untrusted, normally in the
+ * case that a certificate is known to be used for malicious reasons.
+ *
+ * <b>Attention</b>: This check is NOT meant to replace the standard PKI-defined
+ * validation check, neither is it used as an alternative to CRL.
+ */
+public final class UntrustedCertificates {
+
+ private final static Set<X509Certificate> untrustedCerts = new HashSet<>();
+
+ /**
+ * Checks if a certificate is untrusted.
+ *
+ * @param cert the certificate to check
+ * @return true if the certificate is untrusted.
+ */
+ public static boolean isUntrusted(X509Certificate cert) {
+ return untrustedCerts.contains(cert);
+ }
+
+ private static void add(String alias, String pemCert) {
+ // generate certificate from PEM certificate
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(pemCert.getBytes())) {
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate)cf.generateCertificate(is);
+
+ if (!untrustedCerts.add(cert)) {
+ throw new RuntimeException("Duplicate untrusted certificate: " +
+ cert.getSubjectX500Principal());
+ }
+ } catch (CertificateException | IOException e) {
+ throw new RuntimeException(
+ "Incorrect untrusted certificate: " + alias, e);
+ }
+ }
+
+ static {
+ // -----------------------------------------------------------------
+ // Compromised CAs of Digicert Malaysia
+ //
+ // Reported by Digicert in its announcement on November 05, 2011.
+ //
+
+ // Digicert Malaysia intermediate, cross-signed by CyberTrust
+ //
+ // Subject: CN=Digisign Server ID (Enrich),
+ // OU=457608-K,
+ // O=Digicert Sdn. Bhd.,
+ // C=MY
+ // Issuer: CN=GTE CyberTrust Global Root,
+ // OU=GTE CyberTrust Solutions, Inc.,
+ // O=GTE Corporation,
+ // C=US
+ // Serial: 120001705 (07:27:14:a9)
+ add("digicert-server-cross-to-cybertrust-4C0E636A",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIDyzCCAzSgAwIBAgIEBycUqTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJV\n" +
+ "UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU\n" +
+ "cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds\n" +
+ "b2JhbCBSb290MB4XDTA3MDcxNzE1MTc0OFoXDTEyMDcxNzE1MTY1NFowYzELMAkG\n" +
+ "A1UEBhMCTVkxGzAZBgNVBAoTEkRpZ2ljZXJ0IFNkbi4gQmhkLjERMA8GA1UECxMI\n" +
+ "NDU3NjA4LUsxJDAiBgNVBAMTG0RpZ2lzaWduIFNlcnZlciBJRCAoRW5yaWNoKTCB\n" +
+ "nzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEArahkS02Hx4RZufuQRqCmicDx/tXa\n" +
+ "VII3DZkrRSYK6Fawf8qo9I5HhAGCKeOzarWR8/uVhbxyqGToCkCcxfRxrnt7agfq\n" +
+ "kBRPjYmvlKuyBtQCanuYH1m5Os1U+iDfsioK6bjdaZDAKdNO0JftZszFGUkGf/pe\n" +
+ "LHx7hRsyQt97lSUCAwEAAaOCAXgwggF0MBIGA1UdEwEB/wQIMAYBAf8CAQAwXAYD\n" +
+ "VR0gBFUwUzBIBgkrBgEEAbE+AQAwOzA5BggrBgEFBQcCARYtaHR0cDovL2N5YmVy\n" +
+ "dHJ1c3Qub21uaXJvb3QuY29tL3JlcG9zaXRvcnkuY2ZtMAcGBWCDSgEBMA4GA1Ud\n" +
+ "DwEB/wQEAwIB5jCBiQYDVR0jBIGBMH+heaR3MHUxCzAJBgNVBAYTAlVTMRgwFgYD\n" +
+ "VQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdURSBDeWJlclRydXN0IFNv\n" +
+ "bHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVyVHJ1c3QgR2xvYmFsIFJv\n" +
+ "b3SCAgGlMEUGA1UdHwQ+MDwwOqA4oDaGNGh0dHA6Ly93d3cucHVibGljLXRydXN0\n" +
+ "LmNvbS9jZ2ktYmluL0NSTC8yMDE4L2NkcC5jcmwwHQYDVR0OBBYEFMYWk04WF+wW\n" +
+ "royUdvOGbcV0boR3MA0GCSqGSIb3DQEBBQUAA4GBAHYAe6Z4K2Ydjl42xqSOBfIj\n" +
+ "knyTZ9P0wAp9iy3Z6tVvGvPhSilaIoRNUC9LDPL/hcJ7VdREgr5trGeOvLQfkpxR\n" +
+ "gBoU9m6rYYgLrRx/90tQUdZlG6ZHcRVesHHzNRTyN71jyNXwk1o0X9g96F33xR7A\n" +
+ "5c8fhiSpPAdmzcHSNmNZ\n" +
+ "-----END CERTIFICATE-----");
+
+ // Digicert Malaysia intermediate, cross-signed by Entrust
+ //
+ // Subject: CN=Digisign Server ID - (Enrich),
+ // OU=457608-K,
+ // O=Digicert Sdn. Bhd.,
+ // C=MY
+ // Issuer: CN=Entrust.net Certification Authority (2048)
+ // OU=(c) 1999 Entrust.net Limited,
+ // OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.),
+ // O=Entrust.net
+ // Serial: 1184644297 (4c:0e:63:6a)
+ add("digicert-server-cross-to-entrust-ca-4C0E636A",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIEzjCCA7agAwIBAgIETA5jajANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChML\n" +
+ "RW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBp\n" +
+ "bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5\n" +
+ "IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENlcnRp\n" +
+ "ZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw0xMDA3MTYxNzIzMzdaFw0xNTA3\n" +
+ "MTYxNzUzMzdaMGUxCzAJBgNVBAYTAk1ZMRswGQYDVQQKExJEaWdpY2VydCBTZG4u\n" +
+ "IEJoZC4xETAPBgNVBAsTCDQ1NzYwOC1LMSYwJAYDVQQDEx1EaWdpc2lnbiBTZXJ2\n" +
+ "ZXIgSUQgLSAoRW5yaWNoKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" +
+ "AMWJ5PQNBkCSWccaszXRDkwqM/n4r8qef+65p21g9FTob9Wb8xtjMQRoctE0Foy0\n" +
+ "FyyX3nPF2JAVoBor9cuzSIZE8B2ITM5BQhrv9Qze/kDaOSD3BlU6ap1GwdJvpbLI\n" +
+ "Vz4po5zg6YV3ZuiYpyR+vsBZIOVEb7ZX2L7OwmV3WMZhQdF0BMh/SULFcqlyFu6M\n" +
+ "3RJdtErU0a9Qt9iqdXZorT5dqjBtYairEFs+E78z4K9EnTgiW+9ML6ZxJhUmyiiM\n" +
+ "2fqOjqmiFDXimySItPR/hZ2DTwehthSQNsQ0HI0mYW0Tb3i+6I8nx0uElqOGaAwj\n" +
+ "vgvsjJQAqQSKE5D334VsDLECAwEAAaOCATQwggEwMA4GA1UdDwEB/wQEAwIBBjAS\n" +
+ "BgNVHRMBAf8ECDAGAQH/AgEAMCcGA1UdJQQgMB4GCCsGAQUFBwMBBggrBgEFBQcD\n" +
+ "AgYIKwYBBQUHAwQwMwYIKwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdodHRwOi8v\n" +
+ "b2NzcC5lbnRydXN0Lm5ldDBEBgNVHSAEPTA7MDkGBWCDSgEBMDAwLgYIKwYBBQUH\n" +
+ "AgEWImh0dHA6Ly93d3cuZGlnaWNlcnQuY29tLm15L2Nwcy5odG0wMgYDVR0fBCsw\n" +
+ "KTAnoCWgI4YhaHR0cDovL2NybC5lbnRydXN0Lm5ldC8yMDQ4Y2EuY3JsMBEGA1Ud\n" +
+ "DgQKBAhMTswlKAMpgTAfBgNVHSMEGDAWgBRV5IHREYC+2Im5CKMx+aEkCRa5cDAN\n" +
+ "BgkqhkiG9w0BAQUFAAOCAQEAl0zvSjpJrHL8MCBrtClbp8WVBJD5MtXChWreA6E3\n" +
+ "+YkAsFqsVX7bQzX/yQH4Ub7MJsrIaqTEVD4mHucMo82XZ5TdpkLrXM2POXlrM3kh\n" +
+ "Bnn6gkQVmczBtznTRmJ8snDrb84gqj4Zt+l0gpy0pUtNYQA35IfS8hQ6ZHy4qXth\n" +
+ "4JMi59WfPkfmNnagU9gAAzoPtTP+lsrT0oI6Lt3XSOHkp2nMHOmZSufKcEXXCwcO\n" +
+ "mnUb0C+Sb/akB8O9HEumhLZ9qJqp0qcp8QtXaR6XVybsK0Os1EWDBQDp4/BGQAf6\n" +
+ "6rFRc5Mcpd1TETfIKqcVJx20qsx/qjEw/LhFn0gJ7RDixQ==\n" +
+ "-----END CERTIFICATE-----");
+
+
+ // -----------------------------------------------------------------
+ //
+ // No longer used certificates
+ //
+
+ // Subject: CN=Java Media APIs,
+ // OU=Java Signed Extensions,
+ // OU=Corporate Object Signing,
+ // O=Sun Microsystems Inc
+ // Issuer: CN=Object Signing CA,
+ // OU=Class 2 OnSite Subscriber CA,
+ // OU=VeriSign Trust Network,
+ // O=Sun Microsystems Inc
+ // Serial: 6a:8b:99:91:37:59:4f:89:53:e2:97:18:9f:19:1e:4e
+ add("java-media-pretrusted-9F191E4E",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFdzCCBF+gAwIBAgIQaouZkTdZT4lT4pcYnxkeTjANBgkqhkiG9w0BAQUFADCB\n" +
+ "gzEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJbmMxHzAdBgNVBAsTFlZlcmlT\n" +
+ "aWduIFRydXN0IE5ldHdvcmsxJTAjBgNVBAsTHENsYXNzIDIgT25TaXRlIFN1YnNj\n" +
+ "cmliZXIgQ0ExGjAYBgNVBAMTEU9iamVjdCBTaWduaW5nIENBMB4XDTA5MDUxMjAw\n" +
+ "MDAwMFoXDTEyMDUxMTIzNTk1OVowfTEdMBsGA1UEChQUU3VuIE1pY3Jvc3lzdGVt\n" +
+ "cyBJbmMxITAfBgNVBAsUGENvcnBvcmF0ZSBPYmplY3QgU2lnbmluZzEfMB0GA1UE\n" +
+ "CxQWSmF2YSBTaWduZWQgRXh0ZW5zaW9uczEYMBYGA1UEAxQPSmF2YSBNZWRpYSBB\n" +
+ "UElzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAl5blzoKTVE8y4Hpz\n" +
+ "q6E15RZz1bF5HnYEyYqgHkZXnAKedmYCoMzm1XK8s+gQWShLEvGEAvs5yqarx9gE\n" +
+ "nnC21N28aEZgIJMa2/arKxCUkS4pxdGPYGexL9UzSRkUpoBShCZKEGdmX7gfJE2K\n" +
+ "/sd9MFvGV5/yZtWXrADzvm0Kd/9mg1KRv1gfrZIq0TJbupoXPYYqb73AkI9eT2ZD\n" +
+ "q9MdwD4E5+oojsDFXt8GU/D00fUhtXpYwuplU7D667WHYdJhIah0ST6JywyqcLXG\n" +
+ "XSuFTXOgITT2idSHluZVmx3dqJ72u9kPkO4JdJTMDfaK8zgNLaRkiU8Qcj+qhLYH\n" +
+ "ytaqcwIDAQABo4IB6jCCAeYwCQYDVR0TBAIwADAOBgNVHQ8BAf8EBAMCB4AwfwYD\n" +
+ "VR0fBHgwdjB0oHKgcIZuaHR0cDovL29uc2l0ZWNybC52ZXJpc2lnbi5jb20vU3Vu\n" +
+ "TWljcm9zeXN0ZW1zSW5jQ29ycG9yYXRlT2JqZWN0U2lnbmluZ0phdmFTaWduZWRF\n" +
+ "eHRlbnNpb25zQ2xhc3NCL0xhdGVzdENSTC5jcmwwHwYDVR0jBBgwFoAUs0crgn5T\n" +
+ "tHPKuLsZt76BTQeVx+0wHQYDVR0OBBYEFKS32mVx0gNWTeS4ProHEaeSpvvIMDsG\n" +
+ "CCsGAQUFBwEBBC8wLTArBggrBgEFBQcwAYYfaHR0cDovL29uc2l0ZS1vY3NwLnZl\n" +
+ "cmlzaWduLmNvbTCBtQYDVR0gBIGtMIGqMDkGC2CGSAGG+EUBBxcCMCowKAYIKwYB\n" +
+ "BQUHAgEWHGh0dHBzOi8vd3d3LnZlcmlzaWduLmNvbS9ycGEwbQYLYIZIAYb3AIN9\n" +
+ "nD8wXjAnBggrBgEFBQcCARYbaHR0cHM6Ly93d3cuc3VuLmNvbS9wa2kvY3BzMDMG\n" +
+ "CCsGAQUFBwICMCcaJVZhbGlkYXRlZCBGb3IgU3VuIEJ1c2luZXNzIE9wZXJhdGlv\n" +
+ "bnMwEwYDVR0lBAwwCgYIKwYBBQUHAwMwDQYJKoZIhvcNAQEFBQADggEBAAe6BO4W\n" +
+ "3TSNWfezyelJs6kE3HfulT6Bdyz4UUoh9ykXcV8nRwT+kh25I5MdyG2GfkJoADPR\n" +
+ "VhC5DYo13UFpIsTNVjq+hGYe2hML93bN7ad9SxCCyjHUo3yMz2qgBbHZI3VA9ZHA\n" +
+ "aWM4Tx0saMwbcnVvlbuGh+PXvStfypJqYT6lzcdFfjNVX4FI/QQNGhBswMY51tC8\n" +
+ "GTBCL2qhJon0gSCU4zaawDOf7+XxJWirLamYL1Aal1/h2z2sFrvA/1ftxtU3kZ6I\n" +
+ "7De8DyoHeZg7pYGdrj7g+lPhCga/WvEhN152I+aP08YbFcJHYmK05ngl/Ye4c6Bd\n" +
+ "cdrdfbw6QzEUIYY=\n" +
+ "-----END CERTIFICATE-----");
+
+ // Subject: CN=JavaFX 1.0 Runtime,
+ // OU=Java Signed Extensions,
+ // OU=Corporate Object Signing,
+ // O=Sun Microsystems Inc
+ // Issuer: CN=Object Signing CA,
+ // OU=Class 2 OnSite Subscriber CA,
+ // OU=VeriSign Trust Network,
+ // O=Sun Microsystems Inc
+ // Serial: 55:c0:e6:44:59:59:79:9e:d9:26:f1:b0:4a:1e:f0:27
+ add("java-fx10-pretrusted-4A1EF027",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFezCCBGOgAwIBAgIQVcDmRFlZeZ7ZJvGwSh7wJzANBgkqhkiG9w0BAQUFADCB\n" +
+ "gzEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJbmMxHzAdBgNVBAsTFlZlcmlT\n" +
+ "aWduIFRydXN0IE5ldHdvcmsxJTAjBgNVBAsTHENsYXNzIDIgT25TaXRlIFN1YnNj\n" +
+ "cmliZXIgQ0ExGjAYBgNVBAMTEU9iamVjdCBTaWduaW5nIENBMB4XDTA4MTAwOTAw\n" +
+ "MDAwMFoXDTExMTAwOTIzNTk1OVowgYAxHTAbBgNVBAoUFFN1biBNaWNyb3N5c3Rl\n" +
+ "bXMgSW5jMSEwHwYDVQQLFBhDb3Jwb3JhdGUgT2JqZWN0IFNpZ25pbmcxHzAdBgNV\n" +
+ "BAsUFkphdmEgU2lnbmVkIEV4dGVuc2lvbnMxGzAZBgNVBAMUEkphdmFGWCAxLjAg\n" +
+ "UnVudGltZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM+WDc6+bu+4\n" +
+ "tmAcS/lBtUc02WOt9QZpVsXg9cG2pu/8bUtmDELa8iiYBVFpIs8DU58HLrGQtCUY\n" +
+ "SIAGOVPsOJoN29UKCDWfY9j5JeVhfhMGqk9DwrWhzgsjy4cpZ1pIp+k/fJ8zT8Ul\n" +
+ "aYLpow1vg3UNddsmwz02tN7cOrMw9WYIG4CRYnY1OrtJSfe2pYzheC4zyvR+aiVl\n" +
+ "nang2OtqikSQsNFOFHsLOJFxngy9LrO8evDSu25VTKI6zlWU6/bMeqtztJPN0VOn\n" +
+ "NyUrJZvkxZ207Jg0T693BGSxNC1n+ihztXogql8950M/pEuUbDjylv5FFvlp6DSB\n" +
+ "dDT2MkutmyMCAwEAAaOCAeowggHmMAkGA1UdEwQCMAAwDgYDVR0PAQH/BAQDAgeA\n" +
+ "MH8GA1UdHwR4MHYwdKByoHCGbmh0dHA6Ly9vbnNpdGVjcmwudmVyaXNpZ24uY29t\n" +
+ "L1N1bk1pY3Jvc3lzdGVtc0luY0NvcnBvcmF0ZU9iamVjdFNpZ25pbmdKYXZhU2ln\n" +
+ "bmVkRXh0ZW5zaW9uc0NsYXNzQi9MYXRlc3RDUkwuY3JsMB8GA1UdIwQYMBaAFLNH\n" +
+ "K4J+U7Rzyri7Gbe+gU0HlcftMB0GA1UdDgQWBBTjgufVi3XJ3gx1ewsA6Rr7BR4Z\n" +
+ "zjA7BggrBgEFBQcBAQQvMC0wKwYIKwYBBQUHMAGGH2h0dHA6Ly9vbnNpdGUtb2Nz\n" +
+ "cC52ZXJpc2lnbi5jb20wgbUGA1UdIASBrTCBqjA5BgtghkgBhvhFAQcXAjAqMCgG\n" +
+ "CCsGAQUFBwIBFhxodHRwczovL3d3dy52ZXJpc2lnbi5jb20vcnBhMG0GC2CGSAGG\n" +
+ "9wCDfZw/MF4wJwYIKwYBBQUHAgEWG2h0dHBzOi8vd3d3LnN1bi5jb20vcGtpL2Nw\n" +
+ "czAzBggrBgEFBQcCAjAnGiVWYWxpZGF0ZWQgRm9yIFN1biBCdXNpbmVzcyBPcGVy\n" +
+ "YXRpb25zMBMGA1UdJQQMMAoGCCsGAQUFBwMDMA0GCSqGSIb3DQEBBQUAA4IBAQAB\n" +
+ "YVJTTVe7rzyTO4jc3zajErOT/COkdQTfNo0eIX1QbNynFieJvwY/jRzUZwjktIFR\n" +
+ "2p4JtbpHGAtKtjOAOTieQ8xdDOoC1djzpE7/AbMvuvlTavtUKT+F7tPdhfXgWXJV\n" +
+ "6Wbt8jryKyk3zZGiEhauIwZUkfjRkEtffEmZWLUd8c8rURJjfC/XHH2oyurscoxc\n" +
+ "CjX29c9ynxSiS/VvQp1an0HvErGh69N48wj7cj8mtZ1yHzd2XCzSSR1OfTPfk0Pt\n" +
+ "yg51p7yJaFiH21PTZegEL6zyVNOYBTKwwIi2OzpwYalD3uvK6e3OKDrfFCOxu17u\n" +
+ "4PveESbrdyrmvLe7IVez\n" +
+ "-----END CERTIFICATE-----");
+
+ // Subject: CN=JavaFX Runtime,
+ // OU=Java Signed Extensions,
+ // OU=Corporate Object Signing,
+ // O=Sun Microsystems Inc
+ // Issuer: CN=Object Signing CA,
+ // OU=Class 2 OnSite Subscriber CA,
+ // OU=VeriSign Trust Network,
+ // O=Sun Microsystems Inc
+ // Serial: 47:f4:55:f1:da:4a:5e:f9:e3:f7:a8:03:62:17:c0:ff
+ add("javafx-runtime-pretrusted-6217C0FF",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFdjCCBF6gAwIBAgIQR/RV8dpKXvnj96gDYhfA/zANBgkqhkiG9w0BAQUFADCB\n" +
+ "gzEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJbmMxHzAdBgNVBAsTFlZlcmlT\n" +
+ "aWduIFRydXN0IE5ldHdvcmsxJTAjBgNVBAsTHENsYXNzIDIgT25TaXRlIFN1YnNj\n" +
+ "cmliZXIgQ0ExGjAYBgNVBAMTEU9iamVjdCBTaWduaW5nIENBMB4XDTA5MDEyOTAw\n" +
+ "MDAwMFoXDTEyMDEyOTIzNTk1OVowfDEdMBsGA1UEChQUU3VuIE1pY3Jvc3lzdGVt\n" +
+ "cyBJbmMxITAfBgNVBAsUGENvcnBvcmF0ZSBPYmplY3QgU2lnbmluZzEfMB0GA1UE\n" +
+ "CxQWSmF2YSBTaWduZWQgRXh0ZW5zaW9uczEXMBUGA1UEAxQOSmF2YUZYIFJ1bnRp\n" +
+ "bWUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCIzd0fAk8mI9ONc6RJ\n" +
+ "aGieioK2FLdXEwj8zL3vdGDVmBwyR1zwYkaOIFFgF9IW/8qc4iAYA5sGUY+0g8q3\n" +
+ "5DuYAxfTzBB5KdaYvbuq6GGnoHIWmTirXY+1friFp8lyXSvtuEaGB1VHaBoZchEg\n" +
+ "k+UgeVDA43dHwcT1Ov3DePczJRUes8T/QHzLX+BxUDG43vjyncCEO/AjqLZxXEz2\n" +
+ "xrNbKLcH3lGMJK7hdbfssUfF5BjC38Hn71HauYlA43b2no+2y0Sjulwzez2YPbDC\n" +
+ "0GLR3TnKtA8dqOrnl5t3DniDbfOBNtBE3VOydJO0XW57Ng1HRXD023nm9ECPY2xp\n" +
+ "0N/pAgMBAAGjggHqMIIB5jAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIHgDB/BgNV\n" +
+ "HR8EeDB2MHSgcqBwhm5odHRwOi8vb25zaXRlY3JsLnZlcmlzaWduLmNvbS9TdW5N\n" +
+ "aWNyb3N5c3RlbXNJbmNDb3Jwb3JhdGVPYmplY3RTaWduaW5nSmF2YVNpZ25lZEV4\n" +
+ "dGVuc2lvbnNDbGFzc0IvTGF0ZXN0Q1JMLmNybDAfBgNVHSMEGDAWgBSzRyuCflO0\n" +
+ "c8q4uxm3voFNB5XH7TAdBgNVHQ4EFgQUvOdd0cKPj+Yik/iOBwTdphh5A+gwOwYI\n" +
+ "KwYBBQUHAQEELzAtMCsGCCsGAQUFBzABhh9odHRwOi8vb25zaXRlLW9jc3AudmVy\n" +
+ "aXNpZ24uY29tMIG1BgNVHSAEga0wgaowOQYLYIZIAYb4RQEHFwIwKjAoBggrBgEF\n" +
+ "BQcCARYcaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYTBtBgtghkgBhvcAg32c\n" +
+ "PzBeMCcGCCsGAQUFBwIBFhtodHRwczovL3d3dy5zdW4uY29tL3BraS9jcHMwMwYI\n" +
+ "KwYBBQUHAgIwJxolVmFsaWRhdGVkIEZvciBTdW4gQnVzaW5lc3MgT3BlcmF0aW9u\n" +
+ "czATBgNVHSUEDDAKBggrBgEFBQcDAzANBgkqhkiG9w0BAQUFAAOCAQEAbGcf2NjL\n" +
+ "AI93HG6ny2BbepaZA1a8xa/R6uUc7xV+Qw6MgLwFD4Q4i6LWUztQDvg9l68MM2/i\n" +
+ "Y9LEi1KM4lcNbK5+D+t9x98wXBiuojXhVdp5ZmC03EyEBbriopdBsmXVLDSu/Y3+\n" +
+ "zowOO5xwpMK3dbgsSDs2Vt0UosD3FTcRaD3GNfOhXMp+o1grHNiXF9YgkmdQbPPZ\n" +
+ "DQ2KBhFPCRJXBGvyKOqno/DTg0sQ3crGH/C4/4t7mnQXWldZotmJUZ0ONc9oD+Q1\n" +
+ "JAaguUKqIwn9yZ093ie+JWHbYNid9IIIPXYgtRxmf9a376WBhqhu56uJftBJ7x9g\n" +
+ "eQ7Lot6CSWCiFw==\n" +
+ "-----END CERTIFICATE-----");
+
+ //
+ // Compromised Solaris INTERNAL DEVELOPMENT USE ONLY certificate
+ //
+
+ // Subject: CN=Solaris INTERNAL DEVELOPMENT USE ONLY,
+ // OU=Solaris Cryptographic Framework,
+ // OU=Corporate Object Signing,
+ // O=Sun Microsystems Inc
+ // Issuer: CN=Object Signing CA,
+ // OU=Class 2 OnSite Subscriber CA,
+ // OU=VeriSign Trust Network,
+ // O=Sun Microsystems Inc
+ // Serial: 77:29:77:52:6a:19:7b:9a:a6:a2:c7:99:a0:e1:cd:8c
+ add("solaris-internal-dev-A0E1CD8C",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFHjCCBAagAwIBAgIQdyl3UmoZe5qmoseZoOHNjDANBgkqhkiG9w0BAQUFADCB\n" +
+ "gzEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJbmMxHzAdBgNVBAsTFlZlcmlT\n" +
+ "aWduIFRydXN0IE5ldHdvcmsxJTAjBgNVBAsTHENsYXNzIDIgT25TaXRlIFN1YnNj\n" +
+ "cmliZXIgQ0ExGjAYBgNVBAMTEU9iamVjdCBTaWduaW5nIENBMB4XDTA3MDEwNDAw\n" +
+ "MDAwMFoXDTEwMDEwMzIzNTk1OVowgZwxHTAbBgNVBAoUFFN1biBNaWNyb3N5c3Rl\n" +
+ "bXMgSW5jMSEwHwYDVQQLFBhDb3Jwb3JhdGUgT2JqZWN0IFNpZ25pbmcxKDAmBgNV\n" +
+ "BAsUH1NvbGFyaXMgQ3J5cHRvZ3JhcGhpYyBGcmFtZXdvcmsxLjAsBgNVBAMUJVNv\n" +
+ "bGFyaXMgSU5URVJOQUwgREVWRUxPUE1FTlQgVVNFIE9OTFkwgZ8wDQYJKoZIhvcN\n" +
+ "AQEBBQADgY0AMIGJAoGBALbNU4hf3mD5ArDI9pjgioAyvV3bjMPRQdCZniIeGJBp\n" +
+ "odFlSEH+Mh64W1DsY8coeZ7FvvGJkx9IpTMJW9k8w1oJK9UNqHyAQfaYjQyXi3xQ\n" +
+ "LJp62EvYdGfDlwOZejEcR/MbzZG+GOPMMvQj5+xyFDvLXNGfQNTnxw2qnBgCJXjj\n" +
+ "AgMBAAGjggH1MIIB8TAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIHgDCBiQYDVR0f\n" +
+ "BIGBMH8wfaB7oHmGd2h0dHA6Ly9vbnNpdGVjcmwudmVyaXNpZ24uY29tL1N1bk1p\n" +
+ "Y3Jvc3lzdGVtc0luY0NvcnBvcmF0ZU9iamVjdFNpZ25pbmdTb2xhcmlzQ3J5cHRv\n" +
+ "Z3JhcGhpY0ZyYW1ld29ya0NsYXNzQi9MYXRlc3RDUkwuY3JsMB8GA1UdIwQYMBaA\n" +
+ "FLNHK4J+U7Rzyri7Gbe+gU0HlcftMB0GA1UdDgQWBBRpfiGYkehTnsIzuN2H6AFb\n" +
+ "VCZG8jA7BggrBgEFBQcBAQQvMC0wKwYIKwYBBQUHMAGGH2h0dHA6Ly9vbnNpdGUt\n" +
+ "b2NzcC52ZXJpc2lnbi5jb20wgbUGA1UdIASBrTCBqjA5BgtghkgBhvhFAQcXAjAq\n" +
+ "MCgGCCsGAQUFBwIBFhxodHRwczovL3d3dy52ZXJpc2lnbi5jb20vcnBhMG0GC2CG\n" +
+ "SAGG9wCDfZw/MF4wJwYIKwYBBQUHAgEWG2h0dHBzOi8vd3d3LnN1bi5jb20vcGtp\n" +
+ "L2NwczAzBggrBgEFBQcCAjAnFiVWYWxpZGF0ZWQgRm9yIFN1biBCdXNpbmVzcyBP\n" +
+ "cGVyYXRpb25zMBMGA1UdJQQMMAoGCCsGAQUFBwMDMA0GCSqGSIb3DQEBBQUAA4IB\n" +
+ "AQCG5soy3LFHTFbA8/5SzDRhQoJkHUnOP0t3b6nvX6vZYRp649fje7TQOPRm1pFd\n" +
+ "CZ17J+tggdZwgzTqY4aYpJ00jZaK6pV37q/vgFC/ia6jDs8Q+ly9cEcadBZ5loYg\n" +
+ "cmxp9p57W2MNWx8VA8oFdNtKfF0jUNXbLNtvwGHmgR6YcwLrGN1b6/9Lt9bO3ODl\n" +
+ "FO+ZDwkfQz5ClUVrTx2dGBvKRYFqSG5S8JAfsgYhPvcacUQkA7ExyKvfRXLWVrce\n" +
+ "ZiPpcElbx+819H2sAPvVvparVeAruZGMAtejHZp9NFoowKen5drJp9VxePS4eM49\n" +
+ "3DepB6lKRrNRw66LNQol4ZBz\n" +
+ "-----END CERTIFICATE-----");
+
+
+ // -----------------------------------------------------------------
+ // Compromised CAs of DigiNotar
+ //
+ // Reported by Fox-IT in its interim report on September 5, 2011,
+ // "DigiNotar Certificate Authority breach 'Operation Black Tulip'".
+ //
+
+ //
+ // Compromised DigiNotar Cyber CA
+ //
+
+ // DigiNotar intermediate, cross-signed by CyberTrust
+ //
+ // Subject: EMAILADDRESS=info@diginotar.nl, CN=DigiNotar Cyber CA,
+ // O=DigiNotar, C=NL
+ // Issuer: CN=GTE CyberTrust Global Root,
+ // OU=GTE CyberTrust Solutions, Inc.,
+ // O=GTE Corporation,
+ // C=US
+ // Serial: 120000525 (07:27:10:0D)
+ add("info-at-diginotar-cyber-ca-cross-to-gte-cybertrust-0727100D",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFWjCCBMOgAwIBAgIEBycQDTANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJV\n" +
+ "UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU\n" +
+ "cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds\n" +
+ "b2JhbCBSb290MB4XDTA2MTAwNDEwNTQxMVoXDTExMTAwNDEwNTMxMVowYDELMAkG\n" +
+ "A1UEBhMCTkwxEjAQBgNVBAoTCURpZ2lOb3RhcjEbMBkGA1UEAxMSRGlnaU5vdGFy\n" +
+ "IEN5YmVyIENBMSAwHgYJKoZIhvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIw\n" +
+ "DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANLOFQotqF6EZ639vu9Gx8i5z3P8\n" +
+ "9DS5+SxD52ATPXrjss87Z2yQrcC5P4RS8DVC3HTcKDu9UrSnrHJFF8bwieu0qiXy\n" +
+ "XUte0dmHutZ9fPXOMp8QM8WxSrtekTHC0OlBwpFkfglBO9uLCDdqqspS3rU5HsCI\n" +
+ "A6U/i5kTYUO1m4Kz7iBvz6FEouova0CfjytXraFTwoUiaZ2gP1HfC0GRDaXhqKpc\n" +
+ "SQhdvd5wQbEPyWNr0380dAIvNFp4dRxoeoFnivPaQPBgY/SSINcDpj2jHmfEhBtB\n" +
+ "pcmM5r3qSLYFFgizNxJa92E89zhvLpfgb1Y4VNMota0Ubi5LZLUnZbd1JQm2Bz2V\n" +
+ "VgIKgmCyc0XgMyZRdJq51FAc9k1bW1JSE1qmf6cO4ehBVGeYjIfVydNsy9NUkgYJ\n" +
+ "NEH3gW8/nsl8dVWw58Gzd+jDxAA1lUBwEEoF3iW7n1mlZLxHYL9g43aLE1Xd4XR6\n" +
+ "uc8kpmp/3mQiRFhogmoQ+T3lPhu5vfwi9GAEibtVbShV+t6OjRshFNc3izR7Tfay\n" +
+ "shDPM7F9HGKZSMsrbHaWVb8ZDR0fu2WqG46ZtcYokOWCLXhQIJr9eS8kf/CJKWn0\n" +
+ "fc1zvrPtTsHR7VJej/e4142HrbLZG1ES/1az4a80fVykeIgQnp0DxqWqoiRR90kU\n" +
+ "xbHuWUOV36toKDA/AgMBAAGjggGGMIIBgjASBgNVHRMBAf8ECDAGAQH/AgEBMFMG\n" +
+ "A1UdIARMMEowSAYJKwYBBAGxPgEAMDswOQYIKwYBBQUHAgEWLWh0dHA6Ly93d3cu\n" +
+ "cHVibGljLXRydXN0LmNvbS9DUFMvT21uaVJvb3QuaHRtbDAOBgNVHQ8BAf8EBAMC\n" +
+ "AQYwgaAGA1UdIwSBmDCBlYAUpgwdn2H/Bxe1vzhG20Mw1Y6wUgaheaR3MHUxCzAJ\n" +
+ "BgNVBAYTAlVTMRgwFgYDVQQKEw9HVEUgQ29ycG9yYXRpb24xJzAlBgNVBAsTHkdU\n" +
+ "RSBDeWJlclRydXN0IFNvbHV0aW9ucywgSW5jLjEjMCEGA1UEAxMaR1RFIEN5YmVy\n" +
+ "VHJ1c3QgR2xvYmFsIFJvb3SCAgGlMEUGA1UdHwQ+MDwwOqA4oDaGNGh0dHA6Ly93\n" +
+ "d3cucHVibGljLXRydXN0LmNvbS9jZ2ktYmluL0NSTC8yMDE4L2NkcC5jcmwwHQYD\n" +
+ "VR0OBBYEFKv5aN/PSjfXe0WMX3LeQETDZbvCMA0GCSqGSIb3DQEBBQUAA4GBAI9o\n" +
+ "a6VbB7pEZg4cqFwwezPkCiYE/O+eGjjWLqEf0JlHwnVkJP2eOyh2uSYoYZEMbSz4\n" +
+ "BJ98UAHV42mv7xXSRZskCSpmBU8lgcpdvqrBWSeuM46C9990sFWzjvjnN8huqlZE\n" +
+ "9r1TgSOWPbT6MopTZkQloiXGpjwljPDgKAYityZB\n" +
+ "-----END CERTIFICATE-----");
+
+ // DigiNotar intermediate, cross-signed by CyberTrust
+ //
+ // Subject: CN=DigiNotar Cyber CA, O=DigiNotar, C=NL
+ // Issuer: CN=GTE CyberTrust Global Root,
+ // OU=GTE CyberTrust Solutions, Inc.,
+ // O=GTE Corporation,
+ // C=US
+ // Serial: 120000505 (07:27:0F:F9)
+ add("diginotar-cyber-ca-cross-to-gte-cybertrust-07270FF9",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFODCCBKGgAwIBAgIEBycP+TANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJV\n" +
+ "UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU\n" +
+ "cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds\n" +
+ "b2JhbCBSb290MB4XDTA2MDkyMDA5NDUzMloXDTEzMDkyMDA5NDQwNlowPjELMAkG\n" +
+ "A1UEBhMCTkwxEjAQBgNVBAoTCURpZ2lOb3RhcjEbMBkGA1UEAxMSRGlnaU5vdGFy\n" +
+ "IEN5YmVyIENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0s4VCi2o\n" +
+ "XoRnrf2+70bHyLnPc/z0NLn5LEPnYBM9euOyzztnbJCtwLk/hFLwNULcdNwoO71S\n" +
+ "tKesckUXxvCJ67SqJfJdS17R2Ye61n189c4ynxAzxbFKu16RMcLQ6UHCkWR+CUE7\n" +
+ "24sIN2qqylLetTkewIgDpT+LmRNhQ7WbgrPuIG/PoUSi6i9rQJ+PK1etoVPChSJp\n" +
+ "naA/Ud8LQZENpeGoqlxJCF293nBBsQ/JY2vTfzR0Ai80Wnh1HGh6gWeK89pA8GBj\n" +
+ "9JIg1wOmPaMeZ8SEG0GlyYzmvepItgUWCLM3Elr3YTz3OG8ul+BvVjhU0yi1rRRu\n" +
+ "LktktSdlt3UlCbYHPZVWAgqCYLJzReAzJlF0mrnUUBz2TVtbUlITWqZ/pw7h6EFU\n" +
+ "Z5iMh9XJ02zL01SSBgk0QfeBbz+eyXx1VbDnwbN36MPEADWVQHAQSgXeJbufWaVk\n" +
+ "vEdgv2DjdosTVd3hdHq5zySman/eZCJEWGiCahD5PeU+G7m9/CL0YASJu1VtKFX6\n" +
+ "3o6NGyEU1zeLNHtN9rKyEM8zsX0cYplIyytsdpZVvxkNHR+7Zaobjpm1xiiQ5YIt\n" +
+ "eFAgmv15LyR/8IkpafR9zXO+s+1OwdHtUl6P97jXjYetstkbURL/VrPhrzR9XKR4\n" +
+ "iBCenQPGpaqiJFH3SRTFse5ZQ5Xfq2goMD8CAwEAAaOCAYYwggGCMBIGA1UdEwEB\n" +
+ "/wQIMAYBAf8CAQEwUwYDVR0gBEwwSjBIBgkrBgEEAbE+AQAwOzA5BggrBgEFBQcC\n" +
+ "ARYtaHR0cDovL3d3dy5wdWJsaWMtdHJ1c3QuY29tL0NQUy9PbW5pUm9vdC5odG1s\n" +
+ "MA4GA1UdDwEB/wQEAwIBBjCBoAYDVR0jBIGYMIGVgBSmDB2fYf8HF7W/OEbbQzDV\n" +
+ "jrBSBqF5pHcwdTELMAkGA1UEBhMCVVMxGDAWBgNVBAoTD0dURSBDb3Jwb3JhdGlv\n" +
+ "bjEnMCUGA1UECxMeR1RFIEN5YmVyVHJ1c3QgU29sdXRpb25zLCBJbmMuMSMwIQYD\n" +
+ "VQQDExpHVEUgQ3liZXJUcnVzdCBHbG9iYWwgUm9vdIICAaUwRQYDVR0fBD4wPDA6\n" +
+ "oDigNoY0aHR0cDovL3d3dy5wdWJsaWMtdHJ1c3QuY29tL2NnaS1iaW4vQ1JMLzIw\n" +
+ "MTgvY2RwLmNybDAdBgNVHQ4EFgQUq/lo389KN9d7RYxfct5ARMNlu8IwDQYJKoZI\n" +
+ "hvcNAQEFBQADgYEACcpiD427SuDUejUrBi3RKGG2rAH7g0m8rtQvLYauGYOl1h0T\n" +
+ "4he+/jJ06XoUOMqUXvcpAWlxG5Ea/aO7qh3Ke+IW/aGjDvMMX7LhIDGUK16Sdu36\n" +
+ "6bUjpr8KOwOpb1JgVM1f6bcvfKIn/UGDdbYN+3gm87FF6TKVKho1IZXFonU=\n" +
+ "-----END CERTIFICATE-----");
+
+ // DigiNotar intermediate, cross-signed by CyberTrust
+ //
+ // Subject: CN=DigiNotar Cyber CA, O=DigiNotar, C=NL
+ // Issuer: CN=GTE CyberTrust Global Root,
+ // OU=GTE CyberTrust Solutions, Inc.,
+ // O=GTE Corporation,
+ // C=US
+ // Serial: 120000515 (07:27:10:03)
+ add("diginotar-cyber-ca-cross-to-gte-cybertrust-07271003",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFODCCBKGgAwIBAgIEBycQAzANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQGEwJV\n" +
+ "UzEYMBYGA1UEChMPR1RFIENvcnBvcmF0aW9uMScwJQYDVQQLEx5HVEUgQ3liZXJU\n" +
+ "cnVzdCBTb2x1dGlvbnMsIEluYy4xIzAhBgNVBAMTGkdURSBDeWJlclRydXN0IEds\n" +
+ "b2JhbCBSb290MB4XDTA2MDkyNzEwNTMzMloXDTExMDkyNzEwNTIzMFowPjELMAkG\n" +
+ "A1UEBhMCTkwxEjAQBgNVBAoTCURpZ2lOb3RhcjEbMBkGA1UEAxMSRGlnaU5vdGFy\n" +
+ "IEN5YmVyIENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0s4VCi2o\n" +
+ "XoRnrf2+70bHyLnPc/z0NLn5LEPnYBM9euOyzztnbJCtwLk/hFLwNULcdNwoO71S\n" +
+ "tKesckUXxvCJ67SqJfJdS17R2Ye61n189c4ynxAzxbFKu16RMcLQ6UHCkWR+CUE7\n" +
+ "24sIN2qqylLetTkewIgDpT+LmRNhQ7WbgrPuIG/PoUSi6i9rQJ+PK1etoVPChSJp\n" +
+ "naA/Ud8LQZENpeGoqlxJCF293nBBsQ/JY2vTfzR0Ai80Wnh1HGh6gWeK89pA8GBj\n" +
+ "9JIg1wOmPaMeZ8SEG0GlyYzmvepItgUWCLM3Elr3YTz3OG8ul+BvVjhU0yi1rRRu\n" +
+ "LktktSdlt3UlCbYHPZVWAgqCYLJzReAzJlF0mrnUUBz2TVtbUlITWqZ/pw7h6EFU\n" +
+ "Z5iMh9XJ02zL01SSBgk0QfeBbz+eyXx1VbDnwbN36MPEADWVQHAQSgXeJbufWaVk\n" +
+ "vEdgv2DjdosTVd3hdHq5zySman/eZCJEWGiCahD5PeU+G7m9/CL0YASJu1VtKFX6\n" +
+ "3o6NGyEU1zeLNHtN9rKyEM8zsX0cYplIyytsdpZVvxkNHR+7Zaobjpm1xiiQ5YIt\n" +
+ "eFAgmv15LyR/8IkpafR9zXO+s+1OwdHtUl6P97jXjYetstkbURL/VrPhrzR9XKR4\n" +
+ "iBCenQPGpaqiJFH3SRTFse5ZQ5Xfq2goMD8CAwEAAaOCAYYwggGCMBIGA1UdEwEB\n" +
+ "/wQIMAYBAf8CAQEwUwYDVR0gBEwwSjBIBgkrBgEEAbE+AQAwOzA5BggrBgEFBQcC\n" +
+ "ARYtaHR0cDovL3d3dy5wdWJsaWMtdHJ1c3QuY29tL0NQUy9PbW5pUm9vdC5odG1s\n" +
+ "MA4GA1UdDwEB/wQEAwIBBjCBoAYDVR0jBIGYMIGVgBSmDB2fYf8HF7W/OEbbQzDV\n" +
+ "jrBSBqF5pHcwdTELMAkGA1UEBhMCVVMxGDAWBgNVBAoTD0dURSBDb3Jwb3JhdGlv\n" +
+ "bjEnMCUGA1UECxMeR1RFIEN5YmVyVHJ1c3QgU29sdXRpb25zLCBJbmMuMSMwIQYD\n" +
+ "VQQDExpHVEUgQ3liZXJUcnVzdCBHbG9iYWwgUm9vdIICAaUwRQYDVR0fBD4wPDA6\n" +
+ "oDigNoY0aHR0cDovL3d3dy5wdWJsaWMtdHJ1c3QuY29tL2NnaS1iaW4vQ1JMLzIw\n" +
+ "MTgvY2RwLmNybDAdBgNVHQ4EFgQUq/lo389KN9d7RYxfct5ARMNlu8IwDQYJKoZI\n" +
+ "hvcNAQEFBQADgYEAWcyGZhizJlRP1jjNupZey+yZG6oMDW4Z11boriMHbYPCndBE\n" +
+ "bVh07zmPbZsihOw9w/vm5KbVX5CgxUv4Rhzh/20Faixf3P3bpWg0qgzHVVusNVR/\n" +
+ "P50aKkpdK3hp+QLl56e+lWOddSAINIpmcuyDI1hyuzB+GJEASm9tNU/6rs8=\n" +
+ "-----END CERTIFICATE-----");
+
+ //
+ // Compromised DigiNotar Root CA
+ //
+
+ // DigiNotar intermediate, cross-signed by Entrust
+ //
+ // Subject: EMAILADDRESS=info@diginotar.nl,
+ // CN=DigiNotar Root CA,
+ // O=DigiNotar, C=NL
+ // Issuer: CN=Entrust.net Secure Server Certification Authority
+ // OU=(c) 1999 Entrust.net Limited,
+ // OU=www.entrust.net/CPS incorp. by ref. (limits liab.),
+ // O=Entrust.net,
+ // C=US,
+ // Serial: 1184644297 (46:9C:3C:C9)
+ add("info-at-diginotar-root-ca-cross-to-entrust-secure-server-469C3CC9",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFSDCCBLGgAwIBAgIERpw8yTANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA0\n" +
+ "MjYwNTAwMDBaFw0xMzA4MTQyMDEyMzZaMF8xCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxGjAYBgNVBAMTEURpZ2lOb3RhciBSb290IENBMSAwHgYJKoZI\n" +
+ "hvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +
+ "ADCCAgoCggIBAKywWMEAvdghCAsrmv5uVjAFnxt3kBBBXMMNhxF3joHxynzpjGrt\n" +
+ "OHQ1u9rf+bvACTe0lnOBfTMamDn3k2+Vfz25sXWHulFI6ItwPpUExdi2wxbZiLCx\n" +
+ "hx1w2oa0DxSLes8Q0XQ2ohJ7d4ZKeeZ73wIRaKVOhq40WJskE3hWIiUeAYtLUXH7\n" +
+ "gsxZlmmIWmhTxbkNAjfLS7xmSpB+KgsFB+0WX1WQddhGyRuD4gi+8SPMmR3WKg+D\n" +
+ "IBVYJ4Iu+uIiwkmxuQGBap1tnUB3aHZOISpthECFTnaZfILz87cCWdQmARuO361T\n" +
+ "BtGuGN3isjrL14g4jqxbKbkZ05j5GAPPSIKGZgsbaQ/J6ziIeiYaBUyS1yTUlvKs\n" +
+ "Ui2jR9VS9j/+zoQGcKaqPqLytlY0GFei5IFt58rwatPHkWsCg0F8Fe9rmmRe49A8\n" +
+ "5bHre12G+8vmd0nNo2Xc97mcuOQLX5PPzDAaMhzOHGOVpfnq4XSLnukrqTB7oBgf\n" +
+ "DhgL5Vup09FsHgdnj5FLqYq80maqkwGIspH6MVzVpsFSCAnNCmOi0yKm6KHZOQaX\n" +
+ "9W6NApCMFHs/gM0bnLrEWHIjr7ZWn8Z6QjMpBz+CyeYfBQ3NTCg2i9PIPhzGiO9e\n" +
+ "7olk6R3r2ol+MqZp0d3MiJ/R0MlmIdwGZ8WUepptYkx9zOBkgLKeR46jAgMBAAGj\n" +
+ "ggEmMIIBIjASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMB\n" +
+ "BggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMDMGCCsGAQUF\n" +
+ "BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD\n" +
+ "VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9zZXJ2ZXIxLmNy\n" +
+ "bDAdBgNVHQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wCwYDVR0PBAQDAgEGMB8G\n" +
+ "A1UdIwQYMBaAFPAXYhNVPbP/CgBr+1CEl/PtYtAaMBkGCSqGSIb2fQdBAAQMMAob\n" +
+ "BFY3LjEDAgCBMA0GCSqGSIb3DQEBBQUAA4GBAI979rBep8tu3TeLunapgsZ0jtXp\n" +
+ "GDFjKWSk87dj1jCyYi+q/GyDyZ6ZQZNRP0sF+6twscq05lClWNy3TROMp7QeuoLO\n" +
+ "G7Utw3OJaswUtp4YglANMRTHEe3g9ltifUXRH5tSuy7u6yi4LD4WTm5ULP6r/g6l\n" +
+ "0CnjXYb0+b1Fmz6U\n" +
+ "-----END CERTIFICATE-----");
+
+ // DigiNotar intermediate, cross-signed by Entrust
+ //
+ // Subject: EMAILADDRESS=info@diginotar.nl,
+ // CN=DigiNotar Root CA,
+ // O=DigiNotar, C=NL
+ // Issuer: CN=Entrust.net Secure Server Certification Authority
+ // OU=(c) 1999 Entrust.net Limited,
+ // OU=www.entrust.net/CPS incorp. by ref. (limits liab.),
+ // O=Entrust.net,
+ // C=US,
+ // Serial: 1184640175 (46:9C:2C:AF)
+ add("info-at-diginotar-root-ca-cross-to-entrust-secure-server-469C2CAF",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFSDCCBLGgAwIBAgIERpwsrzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA3\n" +
+ "MjYxNTU3MzlaFw0xMzA4MjYxNjI3MzlaMF8xCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxGjAYBgNVBAMTEURpZ2lOb3RhciBSb290IENBMSAwHgYJKoZI\n" +
+ "hvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +
+ "ADCCAgoCggIBAKywWMEAvdghCAsrmv5uVjAFnxt3kBBBXMMNhxF3joHxynzpjGrt\n" +
+ "OHQ1u9rf+bvACTe0lnOBfTMamDn3k2+Vfz25sXWHulFI6ItwPpUExdi2wxbZiLCx\n" +
+ "hx1w2oa0DxSLes8Q0XQ2ohJ7d4ZKeeZ73wIRaKVOhq40WJskE3hWIiUeAYtLUXH7\n" +
+ "gsxZlmmIWmhTxbkNAjfLS7xmSpB+KgsFB+0WX1WQddhGyRuD4gi+8SPMmR3WKg+D\n" +
+ "IBVYJ4Iu+uIiwkmxuQGBap1tnUB3aHZOISpthECFTnaZfILz87cCWdQmARuO361T\n" +
+ "BtGuGN3isjrL14g4jqxbKbkZ05j5GAPPSIKGZgsbaQ/J6ziIeiYaBUyS1yTUlvKs\n" +
+ "Ui2jR9VS9j/+zoQGcKaqPqLytlY0GFei5IFt58rwatPHkWsCg0F8Fe9rmmRe49A8\n" +
+ "5bHre12G+8vmd0nNo2Xc97mcuOQLX5PPzDAaMhzOHGOVpfnq4XSLnukrqTB7oBgf\n" +
+ "DhgL5Vup09FsHgdnj5FLqYq80maqkwGIspH6MVzVpsFSCAnNCmOi0yKm6KHZOQaX\n" +
+ "9W6NApCMFHs/gM0bnLrEWHIjr7ZWn8Z6QjMpBz+CyeYfBQ3NTCg2i9PIPhzGiO9e\n" +
+ "7olk6R3r2ol+MqZp0d3MiJ/R0MlmIdwGZ8WUepptYkx9zOBkgLKeR46jAgMBAAGj\n" +
+ "ggEmMIIBIjASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMB\n" +
+ "BggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMDMGCCsGAQUF\n" +
+ "BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD\n" +
+ "VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9zZXJ2ZXIxLmNy\n" +
+ "bDAdBgNVHQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wCwYDVR0PBAQDAgEGMB8G\n" +
+ "A1UdIwQYMBaAFPAXYhNVPbP/CgBr+1CEl/PtYtAaMBkGCSqGSIb2fQdBAAQMMAob\n" +
+ "BFY3LjEDAgCBMA0GCSqGSIb3DQEBBQUAA4GBAEa6RcDNcEIGUlkDJUY/pWTds4zh\n" +
+ "xbVkp3wSmpwPFhx5fxTyF4HD2L60jl3aqjTB7gPpsL2Pk5QZlNsi3t4UkCV70UOd\n" +
+ "ueJRN3o/LOtk4+bjXY2lC0qTHbN80VMLqPjmaf9ghSA9hwhskdtMgRsgfd90q5QP\n" +
+ "ZFdYf+hthc3m6IcJ\n" +
+ "-----END CERTIFICATE-----");
+
+ //
+ // Compromised DigiNotar PKIoverheid CA Organisatie - G2
+ //
+
+ // DigiNotar intermediate, cross-signed by the Dutch government
+ //
+ // Subject: CN=DigiNotar PKIoverheid CA Organisatie - G2,
+ // O=DigiNotar B.V.,
+ // C=NL
+ // Issuer: CN=Staat der Nederlanden Organisatie CA - G2,
+ // O=Staat der Nederlanden,
+ // C=NL
+ // Serial: 20001983 (01:31:34:bf)
+ add("diginotar-pkioverheid-organisatie-cross-to-nederlanden-013134BF",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIGnDCCBISgAwIBAgIEATE0vzANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQGEwJO\n" +
+ "TDEeMBwGA1UECgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMTIwMAYDVQQDDClTdGFh\n" +
+ "dCBkZXIgTmVkZXJsYW5kZW4gT3JnYW5pc2F0aWUgQ0EgLSBHMjAeFw0xMDA1MTIw\n" +
+ "ODUxMzhaFw0yMDAzMjMwOTUwMDRaMFoxCzAJBgNVBAYTAk5MMRcwFQYDVQQKDA5E\n" +
+ "aWdpTm90YXIgQi5WLjEyMDAGA1UEAwwpRGlnaU5vdGFyIFBLSW92ZXJoZWlkIENB\n" +
+ "IE9yZ2FuaXNhdGllIC0gRzIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC\n" +
+ "AQCxExkPJ+Zs1FWGS9DsiYpFkXisR71HK+T8RetPtCZzWzfTw3/2497Xo/gtaMUI\n" +
+ "PkuU1uSHJTZrhLUYdPMoWHMvm2rPvAQe9t7dr/xLqvXbZmIlASWC3vKXWhBu3V2p\n" +
+ "IrEEqSNzOvhxrR3PhETrR9Gvbch8KKvH8jd6dF9fxQIUiqNa4xtsAeNdjtlo1vQJ\n" +
+ "GzLckbUs9SDrjANtJkm4k8SFXdjSm69WaswFM8ygQp40VUSca6DUEtArVM23iQ3l\n" +
+ "9uvo+4UBM096a/GdcjOWDveyhKWlJ8Qn8VFzKXe6Z27+TNy04qGhgS85SY1DOBPO\n" +
+ "0KVcwoc6AGdlQiPxNlkKHaNRyLyjlCox3+M88p0aPASw77EKMBNzttfzo0wBdRSF\n" +
+ "eMDXijlYhVD6LubFvs+LP6+PNtQlCS3SD6xyk/K/i9RQs/kVUJuZ9RTZ+4uRozIm\n" +
+ "JqD43ztggYaDeVsr6xM9KTrBbd29no6H1kquNJcF7hSm9tw4fkrpJFQHPZdoN0Zr\n" +
+ "DceoIa8TVOQJavFNRgrJXfubT73e+7dUy7g4nKc5+2otwHuNq6WnV+xKkoozxeEg\n" +
+ "XHPYkJIrgNUPhhhpfDlPhIa890xb89W0yqDC8DciynlSH1PmqvOQsDvd8ij9rOvF\n" +
+ "BiSgydQvD1j9tZ7sD8+yWdCiBHo4aq5y+73wJWKUCacFCwIDAQABo4IBYTCCAV0w\n" +
+ "SAYDVR0gBEEwPzA9BgRVHSAAMDUwMwYIKwYBBQUHAgEWJ2h0dHA6Ly93d3cuZGln\n" +
+ "aW5vdGFyLm5sL2Nwcy9wa2lvdmVyaGVpZDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud\n" +
+ "DwEB/wQEAwIBBjCBhQYDVR0jBH4wfIAUORCLSZJc22ESIM1JnRqO2pxnQLmhXqRc\n" +
+ "MFoxCzAJBgNVBAYTAk5MMR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4x\n" +
+ "KzApBgNVBAMMIlN0YWF0IGRlciBOZWRlcmxhbmRlbiBSb290IENBIC0gRzKCBACY\n" +
+ "lvQwSQYDVR0fBEIwQDA+oDygOoY4aHR0cDovL2NybC5wa2lvdmVyaGVpZC5ubC9E\n" +
+ "b21PcmdhbmlzYXRpZUxhdGVzdENSTC1HMi5jcmwwHQYDVR0OBBYEFLxdlDvZq3sD\n" +
+ "JXNhwtst7vyrj2WhMA0GCSqGSIb3DQEBCwUAA4ICAQCP/C1Mt9kt1R+978v0t2gX\n" +
+ "dZ1O1ffdnPEqJu2forYcA9VTs+wIzzTi48P0tRYvyMO+19NzqwA2+RpKftZj6V5G\n" +
+ "uqW2jhW3oyrYQx3vXcgfgYWzi/f/PPTZ9EYIP5y8HaDZqEzNJVJOCrEg9x/pQ9lU\n" +
+ "RoETmsBedGwqmDLq/He7DaWiMZgifnx859qkrey3LhoZcfhIUNpDjyyE3cFAJ+O1\n" +
+ "8BVOltT4XOOGKUYr1zsH6zh/yIZXl9PvKjPEF1DVZGlrK2tFXl0vF8paTs/D1zk8\n" +
+ "9TufRrmb5w5Jl53W1eMbD+qPAU6aE5RZCgIHSEsaYKt/T+0L2FUNaG9VnGllFULs\n" +
+ "wNzdbKzDFs4LHVabpMTE0i7gD+JEJytQaaTcYuiKISlCbMwAOpZ2m+9AwKRed4Qy\n" +
+ "bCYqOWauXeO5ubIsaB8empADOfCqs6TMSYsYNOk3yXspx4R8b0QVL+xhWQTJRcui\n" +
+ "1lKifH8pktZKxYtCqNT+6tjHhyMY5J16fXNAUpigrm7jBT8FD+Clxm1N7YM3iJzH\n" +
+ "89xCmmq21yFJNnfy7xhPxXDZnunetyuL9Lx+KN8NQMmFXK6dxTH/0FwOtah+8Okv\n" +
+ "uq+IruW10Vilr5xxpykBkINpN4IFuvwJwQhujHg7wzMCgD9EhQgd31VWCK0shS1d\n" +
+ "sQPhrqp0xaTzTro3mHuCuQ==\n" +
+ "-----END CERTIFICATE-----");
+
+ //
+ // Compromised DigiNotar PKIoverheid CA Overheid en Bedrijven
+ //
+
+ // DigiNotar intermediate, cross-signed by the Dutch government
+ //
+ // Subject: CN=DigiNotar PKIoverheid CA Overheid en Bedrijven,
+ // O=DigiNotar B.V.,
+ // C=NL
+ // Issuer: CN=Staat der Nederlanden Overheid CA
+ // O=Staat der Nederlanden,
+ // C=NL
+ // Serial: 20015536 (01:31:69:b0)
+ add("diginotar-pkioverheid-overheid-enb-cross-to-nederlanden-013169B0",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIEiDCCA3CgAwIBAgIEATFpsDANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQGEwJO\n" +
+ "TDEeMBwGA1UEChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSowKAYDVQQDEyFTdGFh\n" +
+ "dCBkZXIgTmVkZXJsYW5kZW4gT3ZlcmhlaWQgQ0EwHhcNMDcwNzA1MDg0MjA3WhcN\n" +
+ "MTUwNzI3MDgzOTQ2WjBfMQswCQYDVQQGEwJOTDEXMBUGA1UEChMORGlnaU5vdGFy\n" +
+ "IEIuVi4xNzA1BgNVBAMTLkRpZ2lOb3RhciBQS0lvdmVyaGVpZCBDQSBPdmVyaGVp\n" +
+ "ZCBlbiBCZWRyaWp2ZW4wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDc\n" +
+ "vdKnTmoKuzuiheF/AK2+tDBomAfNoHrElM9x+Yo35FPrV3bMi+Zs/u6HVcg+uwQ5\n" +
+ "AKeAeKxbT370vbhUuHE7BzFJOZNUfCA7eSuPu2GQfbGs5h+QLp1FAalkLU3DL7nn\n" +
+ "UNVOKlyrdnY3Rtd57EKZ96LspIlw3Dgrh6aqJOadkiQbvvb91C8ZF3rmMgeUVAVT\n" +
+ "Q+lsvK9Hy7zL/b07RBKB8WtLu+20z6slTxjSzAL8o0+1QjPLWc0J3NNQ/aB2jKx+\n" +
+ "ZopC9q0ckvO2+xRG603XLzDgbe5bNr5EdLcgBVeFTegAGaL2DOauocBC36esgl3H\n" +
+ "aLcY5olLmmv6znn58yynAgMBAAGjggFQMIIBTDBIBgNVHSAEQTA/MD0GBFUdIAAw\n" +
+ "NTAzBggrBgEFBQcCARYnaHR0cDovL3d3dy5kaWdpbm90YXIubmwvY3BzL3BraW92\n" +
+ "ZXJoZWlkMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMIGABgNVHSME\n" +
+ "eTB3gBQLhtYPd6NosftkCcOIblwEHFfpPaFZpFcwVTELMAkGA1UEBhMCTkwxHjAc\n" +
+ "BgNVBAoTFVN0YWF0IGRlciBOZWRlcmxhbmRlbjEmMCQGA1UEAxMdU3RhYXQgZGVy\n" +
+ "IE5lZGVybGFuZGVuIFJvb3QgQ0GCBACYmnkwPQYDVR0fBDYwNDAyoDCgLoYsaHR0\n" +
+ "cDovL2NybC5wa2lvdmVyaGVpZC5ubC9Eb21PdkxhdGVzdENSTC5jcmwwHQYDVR0O\n" +
+ "BBYEFEwIyY128ZjHPt881y91DbF2eZfMMA0GCSqGSIb3DQEBBQUAA4IBAQAMlIca\n" +
+ "v03jheLu19hjeQ5Q38aEW9K72fUxCho1l3TfFPoqDz7toOMI9tVOW6+mriXiRWsi\n" +
+ "D7dUKH6S3o0UbNEc5W50BJy37zRERd/Jgx0ZH8Apad+J1T/CsFNt5U4X5HNhIxMm\n" +
+ "cUP9TFnLw98iqiEr2b+VERqKpOKrp11Lbyn1UtHk0hWxi/7wA8+nfemZhzizDXMU\n" +
+ "5HIs4c71rQZIZPrTKbmi2Lv01QulQERDjqC/zlqlUkxk0xcxYczopIro5Ij76eUv\n" +
+ "BjMzm5RmZrGrUDqhCYF0U1onuabSJc/Tw6f/ltAv6uAejVLpGBwgCkegllYOQJBR\n" +
+ "RKwa/fHuhR/3Qlpl\n" +
+ "-----END CERTIFICATE-----");
+
+ //
+ // Compromised DigiNotar PKIoverheid CA Overheid
+ //
+
+ // DigiNotar intermediate, cross-signed by the Dutch government
+ //
+ // Subject: CN=DigiNotar PKIoverheid CA Overheid
+ // O=DigiNotar B.V.,
+ // C=NL
+ // Issuer: CN=Staat der Nederlanden Overheid CA
+ // O=Staat der Nederlanden,
+ // C=NL
+ // Serial: 20006006 (01:31:44:76)
+ add("diginotar-pkioverheid-overheid-cross-to-nederlanden-01314476",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIEezCCA2OgAwIBAgIEATFEdjANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQGEwJO\n" +
+ "TDEeMBwGA1UEChMVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSowKAYDVQQDEyFTdGFh\n" +
+ "dCBkZXIgTmVkZXJsYW5kZW4gT3ZlcmhlaWQgQ0EwHhcNMDQwNjI0MDgxOTMyWhcN\n" +
+ "MTAwNjIzMDgxNzM2WjBSMQswCQYDVQQGEwJOTDEXMBUGA1UEChMORGlnaU5vdGFy\n" +
+ "IEIuVi4xKjAoBgNVBAMTIURpZ2lOb3RhciBQS0lvdmVyaGVpZCBDQSBPdmVyaGVp\n" +
+ "ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANSlrubta5tlOjVCi/gb\n" +
+ "yLCvRqfBjxG8H594VcKHu0WAYc99SPZF9cycj5mw2GyfQvy/WIrGrL4iyNq1gSqR\n" +
+ "0QA/mTXKZIaPqzpDhdm+VvrKkmjrbZfaQxgMSs3ChtBsjcP9Lc0X1zXZ4Q8nBe3k\n" +
+ "BTp+zehINfmbjoEgXLxsMR5RQ6GxzKjuC04PQpbJQgTIakglKaqYcDDZbEscWgPV\n" +
+ "Hgj/2aoHlj6leW/ThHZ+O41jUguEmBLZA3mu3HrCfrHntb5dPt0ihzSx7GtD/SaX\n" +
+ "5HBLxnP189YuqMk5iRA95CtiSdKauvon/xRKRLNgG6XAz0ctSoY7xLDdiBVU5kJd\n" +
+ "FScCAwEAAaOCAVAwggFMMEgGA1UdIARBMD8wPQYEVR0gADA1MDMGCCsGAQUFBwIB\n" +
+ "FidodHRwOi8vd3d3LmRpZ2lub3Rhci5ubC9jcHMvcGtpb3ZlcmhlaWQwDwYDVR0T\n" +
+ "AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwgYAGA1UdIwR5MHeAFAuG1g93o2ix\n" +
+ "+2QJw4huXAQcV+k9oVmkVzBVMQswCQYDVQQGEwJOTDEeMBwGA1UEChMVU3RhYXQg\n" +
+ "ZGVyIE5lZGVybGFuZGVuMSYwJAYDVQQDEx1TdGFhdCBkZXIgTmVkZXJsYW5kZW4g\n" +
+ "Um9vdCBDQYIEAJiaeTA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3JsLnBraW92\n" +
+ "ZXJoZWlkLm5sL0RvbU92TGF0ZXN0Q1JMLmNybDAdBgNVHQ4EFgQUvRaYQh2+kdE9\n" +
+ "wpcl4CjXWOC1f+IwDQYJKoZIhvcNAQEFBQADggEBAGhQsCWLiaN2EOhPAW+JQP6o\n" +
+ "XBOrLv5w6joahzBFVn1BiefzmlMKjibqKYxURRvMAsMkh82/MfL8V0w6ugxl81lu\n" +
+ "i42dcxl9cKSVXKMw4bbBzJ2VQI5HTIABwefeNuy/eX6idVwYdt3ajAH7fUA8Q9Cq\n" +
+ "vr6H8B+8mwoEqTVTEVlCSsC/EXsokYEUr06PPzRudKjDmijgj7zFaIioZNc8hk7g\n" +
+ "ufEgrs/tmcNGylrwRHgCXjCRBt2NHlZ08l7A1AGU8HcHlSbG9Un/2q9kVHUkps0D\n" +
+ "gtUaEK+x6jpAu/R8Ojezu/+ZEcwwjI/KOhG+84+ejFmtyEkrUdsAdEdLf/2dKsw=\n" +
+ "-----END CERTIFICATE-----");
+
+ //
+ // Compromised DigiNotar Services 1024 CA
+ //
+
+ // DigiNotar intermediate, cross-signed by the Entrust
+ //
+ // Subject: EMAILADDRESS=info@diginotar.nl,
+ // CN=DigiNotar Services 1024 CA
+ // O=DigiNotar, C=NL
+ // Issuer: CN=Entrust.net Secure Server Certification Authority,
+ // OU=(c) 1999 Entrust.net Limited,
+ // OU=www.entrust.net/CPS incorp. by ref. (limits liab.),
+ // O=Entrust.net,
+ // C=US
+ // Serial: 1184640176 (46:9c:2c:b0)
+ add("diginotar-services-1024-ca-cross-to-entrust-469C2CB0",
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIDzTCCAzagAwIBAgIERpwssDANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA3\n" +
+ "MjYxNTU5MDBaFw0xMzA4MjYxNjI5MDBaMGgxCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxIzAhBgNVBAMTGkRpZ2lOb3RhciBTZXJ2aWNlcyAxMDI0IENB\n" +
+ "MSAwHgYJKoZIhvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCBnzANBgkqhkiG9w0B\n" +
+ "AQEFAAOBjQAwgYkCgYEA2ptNXTz50eKLxsYIIMXZHkjsZlhneWIrQWP0iY1o2q+4\n" +
+ "lDaLGSSkoJPSmQ+yrS01Tc0vauH5mxkrvAQafi09UmTN8T5nD4ku6PJPrqYIoYX+\n" +
+ "oakJ5sarPkP8r3oDkdqmOaZh7phPGKjTs69mgumfvN1y+QYEvRLZGCTnq5NTi1kC\n" +
+ "AwEAAaOCASYwggEiMBIGA1UdEwEB/wQIMAYBAf8CAQAwJwYDVR0lBCAwHgYIKwYB\n" +
+ "BQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDBDARBgNVHSAECjAIMAYGBFUdIAAwMwYI\n" +
+ "KwYBBQUHAQEEJzAlMCMGCCsGAQUFBzABhhdodHRwOi8vb2NzcC5lbnRydXN0Lm5l\n" +
+ "dDAzBgNVHR8ELDAqMCigJqAkhiJodHRwOi8vY3JsLmVudHJ1c3QubmV0L3NlcnZl\n" +
+ "cjEuY3JsMB0GA1UdDgQWBBT+3JRJDG/vXH/G8RKZTxZJrfuCZTALBgNVHQ8EBAMC\n" +
+ "AQYwHwYDVR0jBBgwFoAU8BdiE1U9s/8KAGv7UISX8+1i0BowGQYJKoZIhvZ9B0EA\n" +
+ "BAwwChsEVjcuMQMCAIEwDQYJKoZIhvcNAQEFBQADgYEAY3RqN6k/lpxmyFisCcnv\n" +
+ "9WWUf6MCxDgxvV0jh+zUVrLJsm7kBQb87PX6iHBZ1O7m3bV6oKNgLwIMq94SXa/w\n" +
+ "NUuqikeRGvWFLELHHe+VQ7NeuJWTpdrFKKqtci0xrZlrbP+MISevrZqRK8fdWMNu\n" +
+ "B8WfedLHjFW/TMcnXlEWKz4=\n" +
+ "-----END CERTIFICATE-----");
+
+ }
+}
--- a/jdk/src/share/classes/sun/security/validator/SimpleValidator.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/validator/SimpleValidator.java Fri Mar 02 09:13:13 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
@@ -40,6 +40,7 @@
import sun.security.util.ObjectIdentifier;
import sun.security.provider.certpath.AlgorithmChecker;
+import sun.security.provider.certpath.UntrustedChecker;
/**
* A simple validator implementation. It is based on code from the JSSE
@@ -137,6 +138,9 @@
date = new Date();
}
+ // create distrusted certificates checker
+ UntrustedChecker untrustedChecker = new UntrustedChecker();
+
// create default algorithm constraints checker
TrustAnchor anchor = new TrustAnchor(chain[chain.length - 1], null);
AlgorithmChecker defaultAlgChecker = new AlgorithmChecker(anchor);
@@ -154,6 +158,17 @@
X509Certificate issuerCert = chain[i + 1];
X509Certificate cert = chain[i];
+ // check untrusted certificate
+ try {
+ // Untrusted checker does not care about the unresolved
+ // critical extensions.
+ untrustedChecker.check(cert, Collections.<String>emptySet());
+ } catch (CertPathValidatorException cpve) {
+ throw new ValidatorException(
+ "Untrusted certificate: " + cert.getSubjectX500Principal(),
+ ValidatorException.T_UNTRUSTED_CERT, cert, cpve);
+ }
+
// check certificate algorithm
try {
// Algorithm checker does not care about the unresolved
--- a/jdk/src/share/classes/sun/security/validator/ValidatorException.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/security/validator/ValidatorException.java Fri Mar 02 09:13:13 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
@@ -58,6 +58,9 @@
public final static Object T_ALGORITHM_DISABLED =
"Certificate signature algorithm disabled";
+ public final static Object T_UNTRUSTED_CERT =
+ "Untrusted certificate";
+
private Object type;
private X509Certificate cert;
--- a/jdk/src/share/classes/sun/tools/jar/CommandLine.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/tools/jar/CommandLine.java Fri Mar 02 09:13:13 2012 -0800
@@ -55,7 +55,7 @@
public static String[] parse(String[] args)
throws IOException
{
- ArrayList newArgs = new ArrayList(args.length);
+ List<String> newArgs = new ArrayList<>(args.length);
for (int i = 0; i < args.length; i++) {
String arg = args[i];
if (arg.length() > 1 && arg.charAt(0) == '@') {
@@ -69,10 +69,10 @@
newArgs.add(arg);
}
}
- return (String[])newArgs.toArray(new String[newArgs.size()]);
+ return newArgs.toArray(new String[newArgs.size()]);
}
- private static void loadCmdFile(String name, List args)
+ private static void loadCmdFile(String name, List<String> args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
@@ -83,7 +83,7 @@
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
- while (st.nextToken() != st.TT_EOF) {
+ while (st.nextToken() != StreamTokenizer.TT_EOF) {
args.add(st.sval);
}
r.close();
--- a/jdk/src/share/classes/sun/tools/jar/Manifest.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/tools/jar/Manifest.java Fri Mar 02 09:13:13 2012 -0800
@@ -47,10 +47,10 @@
/* list of headers that all pertain to a particular
* file in the archive
*/
- private Vector entries = new Vector();
+ private Vector<MessageHeader> entries = new Vector<>();
private byte[] tmpbuf = new byte[512];
/* a hashtable of entries, for fast lookup */
- private Hashtable tableEntries = new Hashtable();
+ private Hashtable<String, MessageHeader> tableEntries = new Hashtable<>();
static final String[] hashes = {"SHA"};
static final byte[] EOL = {(byte)'\r', (byte)'\n'};
@@ -115,14 +115,14 @@
}
public MessageHeader getEntry(String name) {
- return (MessageHeader) tableEntries.get(name);
+ return tableEntries.get(name);
}
public MessageHeader entryAt(int i) {
- return (MessageHeader) entries.elementAt(i);
+ return entries.elementAt(i);
}
- public Enumeration entries() {
+ public Enumeration<MessageHeader> entries() {
return entries.elements();
}
@@ -214,7 +214,7 @@
/* the first header in the file should be the global one.
* It should say "Manifest-Version: x.x"; if not add it
*/
- MessageHeader globals = (MessageHeader) entries.elementAt(0);
+ MessageHeader globals = entries.elementAt(0);
if (globals.findValue("Manifest-Version") == null) {
/* Assume this is a user-defined manifest. If it has a Name: <..>
@@ -238,7 +238,7 @@
globals.print(ps);
for (int i = 1; i < entries.size(); ++i) {
- MessageHeader mh = (MessageHeader) entries.elementAt(i);
+ MessageHeader mh = entries.elementAt(i);
mh.print(ps);
}
}
--- a/jdk/src/share/classes/sun/tools/jar/SignatureFile.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/classes/sun/tools/jar/SignatureFile.java Fri Mar 02 09:13:13 2012 -0800
@@ -47,7 +47,7 @@
*
* <p>Each entry section contains the name of an entry (which must
* have a counterpart in the manifest). Like the manifest it contains
- * a hash, the hash of the manifest section correspondind to the
+ * a hash, the hash of the manifest section corresponding to the
* name. Since the manifest entry contains the hash of the data, this
* is equivalent to a signature of the data, plus the attributes of
* the manifest entry.
@@ -66,7 +66,7 @@
/* list of headers that all pertain to a particular file in the
* archive */
- private Vector entries = new Vector();
+ private Vector<MessageHeader> entries = new Vector<>();
/* Right now we only support SHA hashes */
static final String[] hashes = {"SHA"};
@@ -98,7 +98,7 @@
* character in length. */
private SignatureFile(String name) throws JarException {
- entries = new Vector();
+ entries = new Vector<>();
if (name != null) {
if (name.length() > 8 || name.indexOf('.') != -1) {
@@ -142,9 +142,9 @@
this(name, true);
this.manifest = manifest;
- Enumeration enum_ = manifest.entries();
+ Enumeration<MessageHeader> enum_ = manifest.entries();
while (enum_.hasMoreElements()) {
- MessageHeader mh = (MessageHeader)enum_.nextElement();
+ MessageHeader mh = enum_.nextElement();
String entryName = mh.findValue("Name");
if (entryName != null) {
add(entryName);
@@ -269,9 +269,9 @@
*the entry does not exist.
*/
public MessageHeader getEntry(String name) {
- Enumeration enum_ = entries();
+ Enumeration<MessageHeader> enum_ = entries();
while(enum_.hasMoreElements()) {
- MessageHeader mh = (MessageHeader)enum_.nextElement();
+ MessageHeader mh = enum_.nextElement();
if (name.equals(mh.findValue("Name"))) {
return mh;
}
@@ -282,13 +282,13 @@
/**
* Returns the n-th entry. The global header is a entry 0. */
public MessageHeader entryAt(int n) {
- return (MessageHeader) entries.elementAt(n);
+ return entries.elementAt(n);
}
/**
* Returns an enumeration of the entries.
*/
- public Enumeration entries() {
+ public Enumeration<MessageHeader> entries() {
return entries.elements();
}
@@ -322,11 +322,11 @@
}
}
- private Hashtable digests = new Hashtable();
+ private Hashtable<String, MessageDigest> digests = new Hashtable<>();
private MessageDigest getDigest(String algorithm)
throws NoSuchAlgorithmException {
- MessageDigest dig = (MessageDigest)digests.get(algorithm);
+ MessageDigest dig = digests.get(algorithm);
if (dig == null) {
dig = MessageDigest.getInstance(algorithm);
digests.put(algorithm, dig);
@@ -344,7 +344,7 @@
/* the first header in the file should be the global one.
* It should say "SignatureFile-Version: x.x"; barf if not
*/
- MessageHeader globals = (MessageHeader) entries.elementAt(0);
+ MessageHeader globals = entries.elementAt(0);
if (globals.findValue("Signature-Version") == null) {
throw new JarException("Signature file requires " +
"Signature-Version: 1.0 in 1st header");
@@ -354,7 +354,7 @@
globals.print(ps);
for (int i = 1; i < entries.size(); ++i) {
- MessageHeader mh = (MessageHeader) entries.elementAt(i);
+ MessageHeader mh = entries.elementAt(i);
mh.print(ps);
}
}
--- a/jdk/src/share/demo/management/MemoryMonitor/MemoryMonitor.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/demo/management/MemoryMonitor/MemoryMonitor.java Fri Mar 02 09:13:13 2012 -0800
@@ -213,10 +213,10 @@
// Calculate remaining size
float ssH = ascent + descent;
- float remainingHeight = (float) (y2 - (ssH*2) - 0.5f);
+ float remainingHeight = y2 - (ssH*2) - 0.5f;
float blockHeight = remainingHeight/10;
float blockWidth = 20.0f;
- float remainingWidth = (float) (x2 - blockWidth - 10);
+ float remainingWidth = x2 - blockWidth - 10;
// .. Memory Free ..
big.setColor(mfColor);
@@ -224,7 +224,7 @@
int i = 0;
for ( ; i < MemUsage ; i++) {
mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
- blockWidth,(float) blockHeight-1);
+ blockWidth, blockHeight-1);
big.fill(mfRect);
}
@@ -232,13 +232,13 @@
big.setColor(Color.green);
for ( ; i < 10; i++) {
muRect.setRect(x1+5,(float) y1 + ssH+i*blockHeight,
- blockWidth,(float) blockHeight-1);
+ blockWidth, blockHeight-1);
big.fill(muRect);
}
// .. Draw History Graph ..
if (remainingWidth <= 30) remainingWidth = (float)30;
- if (remainingHeight <= ssH) remainingHeight = (float)ssH;
+ if (remainingHeight <= ssH) remainingHeight = ssH;
big.setColor(graphColor);
int graphX = x1+30;
int graphY = y1 + (int) ssH;
@@ -347,8 +347,8 @@
big = bimg.createGraphics();
big.setFont(font);
FontMetrics fm = big.getFontMetrics(font);
- ascent = (int) fm.getAscent();
- descent = (int) fm.getDescent();
+ ascent = fm.getAscent();
+ descent = fm.getDescent();
}
repaint();
try {
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipConstants.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipConstants.java Fri Mar 02 09:13:13 2012 -0800
@@ -185,11 +185,11 @@
*/
///////////////////////////////////////////////////////
static final int CH(byte[] b, int n) {
- return b[n] & 0xff;
+ return Byte.toUnsignedInt(b[n]);
}
static final int SH(byte[] b, int n) {
- return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
+ return Byte.toUnsignedInt(b[n]) | (Byte.toUnsignedInt(b[n + 1]) << 8);
}
static final long LG(byte[] b, int n) {
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java Fri Mar 02 09:13:13 2012 -0800
@@ -61,7 +61,7 @@
private final ZipFileSystem zfs;
ZipFileStore(ZipPath zpath) {
- this.zfs = (ZipFileSystem)zpath.getFileSystem();
+ this.zfs = zpath.getFileSystem();
}
@Override
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java Fri Mar 02 09:13:13 2012 -0800
@@ -1609,7 +1609,7 @@
synchronized (inflaters) {
int size = inflaters.size();
if (size > 0) {
- Inflater inf = (Inflater)inflaters.remove(size - 1);
+ Inflater inf = inflaters.remove(size - 1);
return inf;
} else {
return new Inflater(true);
@@ -1638,7 +1638,7 @@
synchronized (deflaters) {
int size = deflaters.size();
if (size > 0) {
- Deflater def = (Deflater)deflaters.remove(size - 1);
+ Deflater def = deflaters.remove(size - 1);
return def;
} else {
return new Deflater(Deflater.DEFAULT_COMPRESSION, true);
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java Fri Mar 02 09:13:13 2012 -0800
@@ -211,7 +211,7 @@
public <V extends FileAttributeView> V
getFileAttributeView(Path path, Class<V> type, LinkOption... options)
{
- return (V)ZipFileAttributeView.get(toZipPath(path), type);
+ return ZipFileAttributeView.get(toZipPath(path), type);
}
@Override
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java Fri Mar 02 09:13:13 2012 -0800
@@ -78,12 +78,12 @@
// twice
long len = LOCHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENHDR;
if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
- zfs.zerror("read loc header failed");
+ ZipFileSystem.zerror("read loc header failed");
if (LOCEXT(buf) > CENEXT(cen, pos) + CENHDR) {
// have to read the second time;
len = LOCHDR + LOCNAM(buf) + LOCEXT(buf);
if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
- zfs.zerror("read loc header failed");
+ ZipFileSystem.zerror("read loc header failed");
}
printLOC(buf);
pos += CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos);
--- a/jdk/src/share/native/java/lang/System.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/native/java/lang/System.c Fri Mar 02 09:13:13 2012 -0800
@@ -235,7 +235,14 @@
}
PUTPROP(props, "file.encoding", sprops->encoding);
PUTPROP(props, "sun.jnu.encoding", sprops->sun_jnu_encoding);
+ if (sprops->sun_stdout_encoding != NULL) {
+ PUTPROP(props, "sun.stdout.encoding", sprops->sun_stdout_encoding);
+ }
+ if (sprops->sun_stderr_encoding != NULL) {
+ PUTPROP(props, "sun.stderr.encoding", sprops->sun_stderr_encoding);
+ }
PUTPROP(props, "file.encoding.pkg", "sun.io");
+
/* unicode_encoding specifies the default endianness */
PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
PUTPROP(props, "sun.cpu.isalist",
--- a/jdk/src/share/native/java/lang/java_props.h Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/native/java/lang/java_props.h Fri Mar 02 09:13:13 2012 -0800
@@ -66,6 +66,8 @@
char *display_variant;
char *encoding;
char *sun_jnu_encoding;
+ char *sun_stdout_encoding;
+ char *sun_stderr_encoding;
char *timezone;
char *printerJob;
--- a/jdk/src/share/native/java/util/zip/zip_util.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/native/java/util/zip/zip_util.c Fri Mar 02 09:13:13 2012 -0800
@@ -521,7 +521,7 @@
{
jint count = 0;
ptrdiff_t i;
- for (i = 0; i + CENHDR < end - beg; i += CENSIZE(beg + i))
+ for (i = 0; i + CENHDR <= end - beg; i += CENSIZE(beg + i))
count++;
return count;
}
--- a/jdk/src/share/native/sun/management/HotSpotDiagnostic.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/share/native/sun/management/HotSpotDiagnostic.c Fri Mar 02 09:13:13 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
@@ -34,141 +34,3 @@
{
jmm_interface->DumpHeap0(env, outputfile, live);
}
-
-JNIEXPORT jobjectArray JNICALL
-Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0
- (JNIEnv *env, jobject dummy)
-{
- if ((jmm_version > JMM_VERSION_1_2_1)
- || (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
- return jmm_interface->GetDiagnosticCommands(env);
- }
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "Diagnostic commands are not supported by this VM");
-}
-
-jobject getDiagnosticCommandArgumentInfoArray(JNIEnv *env, jstring command,
- int num_arg) {
- int i;
- jobject obj;
- jobjectArray result;
- dcmdArgInfo* dcmd_arg_info_array;
- jclass dcmdArgInfoCls;
- jclass arraysCls;
- jmethodID mid;
- jobject resultList;
-
- dcmd_arg_info_array = (dcmdArgInfo*) malloc(num_arg * sizeof(dcmdArgInfo));
- if (dcmd_arg_info_array == NULL) {
- return NULL;
- }
- jmm_interface->GetDiagnosticCommandArgumentsInfo(env, command,
- dcmd_arg_info_array);
- dcmdArgInfoCls = (*env)->FindClass(env,
- "com/sun/management/DiagnosticCommandArgumentInfo");
- result = (*env)->NewObjectArray(env, num_arg, dcmdArgInfoCls, NULL);
- if (result == NULL) {
- free(dcmd_arg_info_array);
- return NULL;
- }
- for (i=0; i<num_arg; i++) {
- obj = JNU_NewObjectByName(env,
- "com/sun/management/DiagnosticCommandArgumentInfo",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZI)V",
- (*env)->NewStringUTF(env,dcmd_arg_info_array[i].name),
- (*env)->NewStringUTF(env,dcmd_arg_info_array[i].description),
- (*env)->NewStringUTF(env,dcmd_arg_info_array[i].type),
- dcmd_arg_info_array[i].default_string == NULL ? NULL:
- (*env)->NewStringUTF(env, dcmd_arg_info_array[i].default_string),
- dcmd_arg_info_array[i].mandatory,
- dcmd_arg_info_array[i].option,
- dcmd_arg_info_array[i].position);
- if (obj == NULL) {
- free(dcmd_arg_info_array);
- return NULL;
- }
- (*env)->SetObjectArrayElement(env, result, i, obj);
- }
- free(dcmd_arg_info_array);
- arraysCls = (*env)->FindClass(env, "java/util/Arrays");
- mid = (*env)->GetStaticMethodID(env, arraysCls,
- "asList", "([Ljava/lang/Object;)Ljava/util/List;");
- resultList = (*env)->CallStaticObjectMethod(env, arraysCls, mid, result);
- return resultList;
-}
-
-/* Throws IllegalArgumentException if at least one the diagnostic command
- * passed in argument is not supported by the JVM
- */
-JNIEXPORT jobjectArray JNICALL
-Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0
-(JNIEnv *env, jobject dummy, jobjectArray commands)
-{
- int i;
- jclass dcmdInfoCls;
- jobject result;
- jobjectArray args;
- jobject obj;
-
- if (commands == NULL) {
- JNU_ThrowNullPointerException(env, "Invalid String Array");
- return NULL;
- }
- if ((jmm_version > JMM_VERSION_1_2_1)
- || (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
- jsize num_commands = (*env)->GetArrayLength(env, commands);
- dcmdInfo* dcmd_info_array = (dcmdInfo*) malloc(num_commands *
- sizeof(dcmdInfo));
- if (dcmd_info_array == NULL) {
- JNU_ThrowOutOfMemoryError(env, NULL);
- }
- jmm_interface->GetDiagnosticCommandInfo(env, commands, dcmd_info_array);
- dcmdInfoCls = (*env)->FindClass(env,
- "com/sun/management/DiagnosticCommandInfo");
- result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL);
- if (result == NULL) {
- free(dcmd_info_array);
- JNU_ThrowOutOfMemoryError(env, 0);
- }
- for (i=0; i<num_commands; i++) {
- args = getDiagnosticCommandArgumentInfoArray(env,
- (*env)->GetObjectArrayElement(env,commands,i),
- dcmd_info_array[i].num_arguments);
- if (args == NULL) {
- free(dcmd_info_array);
- JNU_ThrowOutOfMemoryError(env, 0);
- }
- obj = JNU_NewObjectByName(env,
- "com/sun/management/DiagnosticCommandInfo",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/util/List;)V",
- (*env)->NewStringUTF(env,dcmd_info_array[i].name),
- (*env)->NewStringUTF(env,dcmd_info_array[i].description),
- (*env)->NewStringUTF(env,dcmd_info_array[i].impact),
- dcmd_info_array[i].enabled,
- args);
- if (obj == NULL) {
- free(dcmd_info_array);
- JNU_ThrowOutOfMemoryError(env, 0);
- }
- (*env)->SetObjectArrayElement(env, result, i, obj);
- }
- free(dcmd_info_array);
- return result;
- }
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "Diagnostic commands are not supported by this VM");
-}
-
-/* Throws IllegalArgumentException if the diagnostic command
- * passed in argument is not supported by the JVM
- */
-JNIEXPORT jstring JNICALL
-Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0
-(JNIEnv *env, jobject dummy, jstring command) {
- if((jmm_version > JMM_VERSION_1_2_1 )
- || (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
- return jmm_interface->ExecuteDiagnosticCommand(env, command);
- }
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- "Diagnostic commands are not supported by this VM");
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -180,7 +180,7 @@
((SelChImpl)selch).kill();
}
- void putEventOps(SelectionKeyImpl sk, int ops) {
+ public void putEventOps(SelectionKeyImpl sk, int ops) {
if (closed)
throw new ClosedSelectorException();
int fd = IOUtil.fdVal(sk.channel.getFD());
--- a/jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -181,7 +181,7 @@
((SelChImpl)selch).kill();
}
- void putEventOps(SelectionKeyImpl sk, int ops) {
+ public void putEventOps(SelectionKeyImpl sk, int ops) {
if (closed)
throw new ClosedSelectorException();
pollWrapper.setInterest(sk.channel, ops);
--- a/jdk/src/solaris/classes/sun/nio/ch/NativeThread.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/NativeThread.java Fri Mar 02 09:13:13 2012 -0800
@@ -37,21 +37,21 @@
// always returns -1 and the signal(long) method has no effect.
-class NativeThread {
+public class NativeThread {
// Returns an opaque token representing the native thread underlying the
// invoking Java thread. On systems that do not require signalling, this
// method always returns -1.
//
- static native long current();
+ public static native long current();
// Signals the given native thread so as to release it from a blocking I/O
// operation. On systems that do not require signalling, this method has
// no effect.
//
- static native void signal(long nt);
+ public static native void signal(long nt);
- static native void init();
+ private static native void init();
static {
Util.load();
--- a/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java Fri Mar 02 09:13:13 2012 -0800
@@ -41,9 +41,9 @@
* @since 1.4
*/
-class PollArrayWrapper extends AbstractPollArrayWrapper {
+public class PollArrayWrapper extends AbstractPollArrayWrapper {
- static final short POLLCONN = POLLOUT;
+ public static final short POLLCONN = POLLOUT;
// File descriptor to write for interrupt
int interruptFD;
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpAssocChange.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.AssociationChangeNotification;
-
-/**
- * An implementation of AssociationChangeNotification
- */
-public class SctpAssocChange extends AssociationChangeNotification
- implements SctpNotification
-{
- /* static final ints so that they can be referenced from native */
- private final static int SCTP_COMM_UP = 1;
- private final static int SCTP_COMM_LOST = 2;
- private final static int SCTP_RESTART = 3;
- private final static int SCTP_SHUTDOWN = 4;
- private final static int SCTP_CANT_START = 5;
-
- private Association association;
-
- /* assocId is used to lookup the association before the notification is
- * returned to user code */
- private int assocId;
- private AssocChangeEvent event;
- private int maxOutStreams;
- private int maxInStreams;
-
- /* Invoked from native */
- private SctpAssocChange(int assocId,
- int intEvent,
- int maxOutStreams,
- int maxInStreams) {
- switch (intEvent) {
- case SCTP_COMM_UP :
- this.event = AssocChangeEvent.COMM_UP;
- break;
- case SCTP_COMM_LOST :
- this.event = AssocChangeEvent.COMM_LOST;
- break;
- case SCTP_RESTART :
- this.event = AssocChangeEvent.RESTART;
- break;
- case SCTP_SHUTDOWN :
- this.event = AssocChangeEvent.SHUTDOWN;
- break;
- case SCTP_CANT_START :
- this.event = AssocChangeEvent.CANT_START;
- break;
- default :
- throw new AssertionError(
- "Unknown Association Change Event type: " + intEvent);
- }
-
- this.assocId = assocId;
- this.maxOutStreams = maxOutStreams;
- this.maxInStreams = maxInStreams;
- }
-
- @Override
- public int assocId() {
- return assocId;
- }
-
- @Override
- public void setAssociation(Association association) {
- this.association = association;
- }
-
- @Override
- public Association association() {
- assert association != null;
- return association;
- }
-
- @Override
- public AssocChangeEvent event() {
- return event;
- }
-
- int maxOutStreams() {
- return maxOutStreams;
- }
-
- int maxInStreams() {
- return maxInStreams;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(super.toString()).append(" [");
- sb.append("Association:").append(association);
- sb.append(", Event: ").append(event).append("]");
- return sb.toString();
- }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpAssociationImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-
-/**
- * An implementation of Association
- */
-public class SctpAssociationImpl extends Association {
- public SctpAssociationImpl(int associationID,
- int maxInStreams,
- int maxOutStreams) {
- super(associationID, maxInStreams, maxOutStreams);
- }
-
- @Override
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- return sb.append("[associationID:")
- .append(associationID())
- .append(", maxIn:")
- .append(maxInboundStreams())
- .append(", maxOut:")
- .append(maxOutboundStreams())
- .append("]")
- .toString();
- }
-}
-
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1097 +0,0 @@
-/*
- * Copyright (c) 2009, 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 sun.nio.ch;
-
-import java.net.InetAddress;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.InetSocketAddress;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.ConnectionPendingException;
-import java.nio.channels.NoConnectionPendingException;
-import java.nio.channels.AlreadyConnectedException;
-import java.nio.channels.NotYetBoundException;
-import java.nio.channels.NotYetConnectedException;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.AbstractNotificationHandler;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.AssociationChangeNotification;
-import com.sun.nio.sctp.HandlerResult;
-import com.sun.nio.sctp.IllegalReceiveException;
-import com.sun.nio.sctp.InvalidStreamException;
-import com.sun.nio.sctp.IllegalUnbindException;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-import static sun.nio.ch.SctpResultContainer.SEND_FAILED;
-import static sun.nio.ch.SctpResultContainer.ASSOCIATION_CHANGED;
-import static sun.nio.ch.SctpResultContainer.PEER_ADDRESS_CHANGED;
-import static sun.nio.ch.SctpResultContainer.SHUTDOWN;
-
-/**
- * An implementation of an SctpChannel
- */
-public class SctpChannelImpl extends SctpChannel
- implements SelChImpl
-{
- private final FileDescriptor fd;
-
- private final int fdVal;
-
- /* IDs of native threads doing send and receivess, for signalling */
- private volatile long receiverThread = 0;
- private volatile long senderThread = 0;
-
- /* Lock held by current receiving or connecting thread */
- private final Object receiveLock = new Object();
-
- /* Lock held by current sending or connecting thread */
- private final Object sendLock = new Object();
-
- private final ThreadLocal<Boolean> receiveInvoked =
- new ThreadLocal<Boolean>() {
- @Override protected Boolean initialValue() {
- return Boolean.FALSE;
- }
- };
-
- /* Lock held by any thread that modifies the state fields declared below
- DO NOT invoke a blocking I/O operation while holding this lock! */
- private final Object stateLock = new Object();
-
- private enum ChannelState {
- UNINITIALIZED,
- UNCONNECTED,
- PENDING,
- CONNECTED,
- KILLPENDING,
- KILLED,
- }
- /* -- The following fields are protected by stateLock -- */
- private ChannelState state = ChannelState.UNINITIALIZED;
-
- /* Binding; Once bound the port will remain constant. */
- int port = -1;
- private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
- /* Has the channel been bound to the wildcard address */
- private boolean wildcard; /* false */
- //private InetSocketAddress remoteAddress = null;
-
- /* Input/Output open */
- private boolean readyToConnect;
-
- /* Shutdown */
- private boolean isShutdown;
-
- private Association association;
-
- private Set<SocketAddress> remoteAddresses = Collections.emptySet();
-
- /* -- End of fields protected by stateLock -- */
-
- /**
- * Constructor for normal connecting sockets
- */
- public SctpChannelImpl(SelectorProvider provider) throws IOException {
- //TODO: update provider remove public modifier
- super(provider);
- this.fd = SctpNet.socket(true);
- this.fdVal = IOUtil.fdVal(fd);
- this.state = ChannelState.UNCONNECTED;
- }
-
- /**
- * Constructor for sockets obtained from server sockets
- */
- public SctpChannelImpl(SelectorProvider provider, FileDescriptor fd)
- throws IOException {
- this(provider, fd, null);
- }
-
- /**
- * Constructor for sockets obtained from branching
- */
- public SctpChannelImpl(SelectorProvider provider,
- FileDescriptor fd,
- Association association)
- throws IOException {
- super(provider);
- this.fd = fd;
- this.fdVal = IOUtil.fdVal(fd);
- this.state = ChannelState.CONNECTED;
- port = (Net.localAddress(fd)).getPort();
-
- if (association != null) { /* branched */
- this.association = association;
- } else { /* obtained from server channel */
- /* Receive COMM_UP */
- ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
- try {
- receive(buf, null, null, true);
- } finally {
- Util.releaseTemporaryDirectBuffer(buf);
- }
- }
- }
-
- /**
- * Binds the channel's socket to a local address.
- */
- @Override
- public SctpChannel bind(SocketAddress local) throws IOException {
- synchronized (receiveLock) {
- synchronized (sendLock) {
- synchronized (stateLock) {
- ensureOpenAndUnconnected();
- if (isBound())
- SctpNet.throwAlreadyBoundException();
- InetSocketAddress isa = (local == null) ?
- new InetSocketAddress(0) : Net.checkAddress(local);
- Net.bind(fd, isa.getAddress(), isa.getPort());
- InetSocketAddress boundIsa = Net.localAddress(fd);
- port = boundIsa.getPort();
- localAddresses.add(isa);
- if (isa.getAddress().isAnyLocalAddress())
- wildcard = true;
- }
- }
- }
- return this;
- }
-
- @Override
- public SctpChannel bindAddress(InetAddress address)
- throws IOException {
- bindUnbindAddress(address, true);
- localAddresses.add(new InetSocketAddress(address, port));
- return this;
- }
-
- @Override
- public SctpChannel unbindAddress(InetAddress address)
- throws IOException {
- bindUnbindAddress(address, false);
- localAddresses.remove(new InetSocketAddress(address, port));
- return this;
- }
-
- private SctpChannel bindUnbindAddress(InetAddress address, boolean add)
- throws IOException {
- if (address == null)
- throw new IllegalArgumentException();
-
- synchronized (receiveLock) {
- synchronized (sendLock) {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- throw new NotYetBoundException();
- if (wildcard)
- throw new IllegalStateException(
- "Cannot add or remove addresses from a channel that is bound to the wildcard address");
- if (address.isAnyLocalAddress())
- throw new IllegalArgumentException(
- "Cannot add or remove the wildcard address");
- if (add) {
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- SctpNet.throwAlreadyBoundException();
- }
- }
- } else { /*removing */
- /* Verify that there is more than one address
- * and that address is already bound */
- if (localAddresses.size() <= 1)
- throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
- boolean foundAddress = false;
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- foundAddress = true;
- break;
- }
- }
- if (!foundAddress )
- throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
- }
-
- SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
-
- /* Update our internal Set to reflect the addition/removal */
- if (add)
- localAddresses.add(new InetSocketAddress(address, port));
- else {
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- localAddresses.remove(addr);
- break;
- }
- }
- }
- }
- }
- }
- return this;
- }
-
- private boolean isBound() {
- synchronized (stateLock) {
- return port == -1 ? false : true;
- }
- }
-
- private boolean isConnected() {
- synchronized (stateLock) {
- return (state == ChannelState.CONNECTED);
- }
- }
-
- private void ensureOpenAndUnconnected() throws IOException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (isConnected())
- throw new AlreadyConnectedException();
- if (state == ChannelState.PENDING)
- throw new ConnectionPendingException();
- }
- }
-
- private boolean ensureReceiveOpen() throws ClosedChannelException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isConnected())
- throw new NotYetConnectedException();
- else
- return true;
- }
- }
-
- private void ensureSendOpen() throws ClosedChannelException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (isShutdown)
- throw new ClosedChannelException();
- if (!isConnected())
- throw new NotYetConnectedException();
- }
- }
-
- private void receiverCleanup() throws IOException {
- synchronized (stateLock) {
- receiverThread = 0;
- if (state == ChannelState.KILLPENDING)
- kill();
- }
- }
-
- private void senderCleanup() throws IOException {
- synchronized (stateLock) {
- senderThread = 0;
- if (state == ChannelState.KILLPENDING)
- kill();
- }
- }
-
- @Override
- public Association association() throws ClosedChannelException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isConnected())
- return null;
-
- return association;
- }
- }
-
- @Override
- public boolean connect(SocketAddress endpoint) throws IOException {
- synchronized (receiveLock) {
- synchronized (sendLock) {
- ensureOpenAndUnconnected();
- InetSocketAddress isa = Net.checkAddress(endpoint);
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkConnect(isa.getAddress().getHostAddress(),
- isa.getPort());
- synchronized (blockingLock()) {
- int n = 0;
- try {
- try {
- begin();
- synchronized (stateLock) {
- if (!isOpen()) {
- return false;
- }
- receiverThread = NativeThread.current();
- }
- for (;;) {
- InetAddress ia = isa.getAddress();
- if (ia.isAnyLocalAddress())
- ia = InetAddress.getLocalHost();
- n = SctpNet.connect(fdVal, ia, isa.getPort());
- if ( (n == IOStatus.INTERRUPTED)
- && isOpen())
- continue;
- break;
- }
- } finally {
- receiverCleanup();
- end((n > 0) || (n == IOStatus.UNAVAILABLE));
- assert IOStatus.check(n);
- }
- } catch (IOException x) {
- /* If an exception was thrown, close the channel after
- * invoking end() so as to avoid bogus
- * AsynchronousCloseExceptions */
- close();
- throw x;
- }
-
- if (n > 0) {
- synchronized (stateLock) {
- /* Connection succeeded */
- state = ChannelState.CONNECTED;
- if (!isBound()) {
- InetSocketAddress boundIsa =
- Net.localAddress(fd);
- port = boundIsa.getPort();
- }
-
- /* Receive COMM_UP */
- ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
- try {
- receive(buf, null, null, true);
- } finally {
- Util.releaseTemporaryDirectBuffer(buf);
- }
-
- /* cache remote addresses */
- try {
- remoteAddresses = getRemoteAddresses();
- } catch (IOException unused) { /* swallow exception */ }
-
- return true;
- }
- } else {
- synchronized (stateLock) {
- /* If nonblocking and no exception then connection
- * pending; disallow another invocation */
- if (!isBlocking())
- state = ChannelState.PENDING;
- else
- assert false;
- }
- }
- }
- return false;
- }
- }
- }
-
- @Override
- public boolean connect(SocketAddress endpoint,
- int maxOutStreams,
- int maxInStreams)
- throws IOException {
- ensureOpenAndUnconnected();
- return setOption(SCTP_INIT_MAXSTREAMS, InitMaxStreams.
- create(maxInStreams, maxOutStreams)).connect(endpoint);
-
- }
-
- @Override
- public boolean isConnectionPending() {
- synchronized (stateLock) {
- return (state == ChannelState.PENDING);
- }
- }
-
- @Override
- public boolean finishConnect() throws IOException {
- synchronized (receiveLock) {
- synchronized (sendLock) {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (isConnected())
- return true;
- if (state != ChannelState.PENDING)
- throw new NoConnectionPendingException();
- }
- int n = 0;
- try {
- try {
- begin();
- synchronized (blockingLock()) {
- synchronized (stateLock) {
- if (!isOpen()) {
- return false;
- }
- receiverThread = NativeThread.current();
- }
- if (!isBlocking()) {
- for (;;) {
- n = checkConnect(fd, false, readyToConnect);
- if ( (n == IOStatus.INTERRUPTED)
- && isOpen())
- continue;
- break;
- }
- } else {
- for (;;) {
- n = checkConnect(fd, true, readyToConnect);
- if (n == 0) {
- // Loop in case of
- // spurious notifications
- continue;
- }
- if ( (n == IOStatus.INTERRUPTED)
- && isOpen())
- continue;
- break;
- }
- }
- }
- } finally {
- synchronized (stateLock) {
- receiverThread = 0;
- if (state == ChannelState.KILLPENDING) {
- kill();
- /* poll()/getsockopt() does not report
- * error (throws exception, with n = 0)
- * on Linux platform after dup2 and
- * signal-wakeup. Force n to 0 so the
- * end() can throw appropriate exception */
- n = 0;
- }
- }
- end((n > 0) || (n == IOStatus.UNAVAILABLE));
- assert IOStatus.check(n);
- }
- } catch (IOException x) {
- /* If an exception was thrown, close the channel after
- * invoking end() so as to avoid bogus
- * AsynchronousCloseExceptions */
- close();
- throw x;
- }
-
- if (n > 0) {
- synchronized (stateLock) {
- state = ChannelState.CONNECTED;
- if (!isBound()) {
- InetSocketAddress boundIsa =
- Net.localAddress(fd);
- port = boundIsa.getPort();
- }
-
- /* Receive COMM_UP */
- ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
- try {
- receive(buf, null, null, true);
- } finally {
- Util.releaseTemporaryDirectBuffer(buf);
- }
-
- /* cache remote addresses */
- try {
- remoteAddresses = getRemoteAddresses();
- } catch (IOException unused) { /* swallow exception */ }
-
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @Override
- protected void implConfigureBlocking(boolean block) throws IOException {
- IOUtil.configureBlocking(fd, block);
- }
-
- @Override
- public void implCloseSelectableChannel() throws IOException {
- synchronized (stateLock) {
- SctpNet.preClose(fdVal);
-
- if (receiverThread != 0)
- NativeThread.signal(receiverThread);
-
- if (senderThread != 0)
- NativeThread.signal(senderThread);
-
- if (!isRegistered())
- kill();
- }
- }
-
- @Override
- public FileDescriptor getFD() {
- return fd;
- }
-
- @Override
- public int getFDVal() {
- return fdVal;
- }
-
- /**
- * Translates native poll revent ops into a ready operation ops
- */
- private boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl sk) {
- int intOps = sk.nioInterestOps();
- int oldOps = sk.nioReadyOps();
- int newOps = initialOps;
-
- if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
- /* This should only happen if this channel is pre-closed while a
- * selection operation is in progress
- * ## Throw an error if this channel has not been pre-closed */
- return false;
- }
-
- if ((ops & (PollArrayWrapper.POLLERR
- | PollArrayWrapper.POLLHUP)) != 0) {
- newOps = intOps;
- sk.nioReadyOps(newOps);
- /* No need to poll again in checkConnect,
- * the error will be detected there */
- readyToConnect = true;
- return (newOps & ~oldOps) != 0;
- }
-
- if (((ops & PollArrayWrapper.POLLIN) != 0) &&
- ((intOps & SelectionKey.OP_READ) != 0) &&
- isConnected())
- newOps |= SelectionKey.OP_READ;
-
- if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
- ((intOps & SelectionKey.OP_CONNECT) != 0) &&
- ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
- newOps |= SelectionKey.OP_CONNECT;
- readyToConnect = true;
- }
-
- if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
- ((intOps & SelectionKey.OP_WRITE) != 0) &&
- isConnected())
- newOps |= SelectionKey.OP_WRITE;
-
- sk.nioReadyOps(newOps);
- return (newOps & ~oldOps) != 0;
- }
-
- @Override
- public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
- return translateReadyOps(ops, sk.nioReadyOps(), sk);
- }
-
- @Override
- @SuppressWarnings("all")
- public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
- return translateReadyOps(ops, 0, sk);
- }
-
- @Override
- public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
- int newOps = 0;
- if ((ops & SelectionKey.OP_READ) != 0)
- newOps |= PollArrayWrapper.POLLIN;
- if ((ops & SelectionKey.OP_WRITE) != 0)
- newOps |= PollArrayWrapper.POLLOUT;
- if ((ops & SelectionKey.OP_CONNECT) != 0)
- newOps |= PollArrayWrapper.POLLCONN;
- sk.selector.putEventOps(sk, newOps);
- }
-
- @Override
- public void kill() throws IOException {
- synchronized (stateLock) {
- if (state == ChannelState.KILLED)
- return;
- if (state == ChannelState.UNINITIALIZED) {
- state = ChannelState.KILLED;
- return;
- }
- assert !isOpen() && !isRegistered();
-
- /* Postpone the kill if there is a waiting reader
- * or writer thread. */
- if (receiverThread == 0 && senderThread == 0) {
- SctpNet.close(fdVal);
- state = ChannelState.KILLED;
- } else {
- state = ChannelState.KILLPENDING;
- }
- }
- }
-
- @Override
- public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
- throws IOException {
- if (name == null)
- throw new NullPointerException();
- if (!supportedOptions().contains(name))
- throw new UnsupportedOperationException("'" + name + "' not supported");
-
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
-
- SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
- }
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getOption(SctpSocketOption<T> name) throws IOException {
- if (name == null)
- throw new NullPointerException();
- if (!supportedOptions().contains(name))
- throw new UnsupportedOperationException("'" + name + "' not supported");
-
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
-
- return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
- }
- }
-
- private static class DefaultOptionsHolder {
- static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
-
- private static Set<SctpSocketOption<?>> defaultOptions() {
- HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
- set.add(SCTP_DISABLE_FRAGMENTS);
- set.add(SCTP_EXPLICIT_COMPLETE);
- set.add(SCTP_FRAGMENT_INTERLEAVE);
- set.add(SCTP_INIT_MAXSTREAMS);
- set.add(SCTP_NODELAY);
- set.add(SCTP_PRIMARY_ADDR);
- set.add(SCTP_SET_PEER_PRIMARY_ADDR);
- set.add(SO_SNDBUF);
- set.add(SO_RCVBUF);
- set.add(SO_LINGER);
- return Collections.unmodifiableSet(set);
- }
- }
-
- @Override
- public final Set<SctpSocketOption<?>> supportedOptions() {
- return DefaultOptionsHolder.defaultOptions;
- }
-
- @Override
- public <T> MessageInfo receive(ByteBuffer buffer,
- T attachment,
- NotificationHandler<T> handler)
- throws IOException {
- return receive(buffer, attachment, handler, false);
- }
-
- private <T> MessageInfo receive(ByteBuffer buffer,
- T attachment,
- NotificationHandler<T> handler,
- boolean fromConnect)
- throws IOException {
- if (buffer == null)
- throw new IllegalArgumentException("buffer cannot be null");
-
- if (buffer.isReadOnly())
- throw new IllegalArgumentException("Read-only buffer");
-
- if (receiveInvoked.get())
- throw new IllegalReceiveException(
- "cannot invoke receive from handler");
- receiveInvoked.set(Boolean.TRUE);
-
- try {
- SctpResultContainer resultContainer = new SctpResultContainer();
- do {
- resultContainer.clear();
- synchronized (receiveLock) {
- if (!ensureReceiveOpen())
- return null;
-
- int n = 0;
- try {
- begin();
-
- synchronized (stateLock) {
- if(!isOpen())
- return null;
- receiverThread = NativeThread.current();
- }
-
- do {
- n = receive(fdVal, buffer, resultContainer, fromConnect);
- } while ((n == IOStatus.INTERRUPTED) && isOpen());
- } finally {
- receiverCleanup();
- end((n > 0) || (n == IOStatus.UNAVAILABLE));
- assert IOStatus.check(n);
- }
-
- if (!resultContainer.isNotification()) {
- /* message or nothing */
- if (resultContainer.hasSomething()) {
- /* Set the association before returning */
- SctpMessageInfoImpl info =
- resultContainer.getMessageInfo();
- synchronized (stateLock) {
- assert association != null;
- info.setAssociation(association);
- }
- return info;
- } else
- /* Non-blocking may return null if nothing available*/
- return null;
- } else { /* notification */
- synchronized (stateLock) {
- handleNotificationInternal(
- resultContainer);
- }
- }
-
- if (fromConnect) {
- /* If we reach here, then it was connect that invoked
- * receive and received the COMM_UP. We have already
- * handled the COMM_UP with the internal notification
- * handler. Simply return. */
- return null;
- }
- } /* receiveLock */
- } while (handler == null ? true :
- (invokeNotificationHandler(resultContainer, handler, attachment)
- == HandlerResult.CONTINUE));
-
- return null;
- } finally {
- receiveInvoked.set(Boolean.FALSE);
- }
- }
-
- private int receive(int fd,
- ByteBuffer dst,
- SctpResultContainer resultContainer,
- boolean peek)
- throws IOException {
- int pos = dst.position();
- int lim = dst.limit();
- assert (pos <= lim);
- int rem = (pos <= lim ? lim - pos : 0);
- if (dst instanceof DirectBuffer && rem > 0)
- return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos, peek);
-
- /* Substitute a native buffer */
- int newSize = Math.max(rem, 1);
- ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
- try {
- int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0, peek);
- bb.flip();
- if (n > 0 && rem > 0)
- dst.put(bb);
- return n;
- } finally {
- Util.releaseTemporaryDirectBuffer(bb);
- }
- }
-
- private int receiveIntoNativeBuffer(int fd,
- SctpResultContainer resultContainer,
- ByteBuffer bb,
- int rem,
- int pos,
- boolean peek)
- throws IOException
- {
- int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem, peek);
-
- if (n > 0)
- bb.position(pos + n);
- return n;
- }
-
- private InternalNotificationHandler internalNotificationHandler =
- new InternalNotificationHandler();
-
- private void handleNotificationInternal(SctpResultContainer resultContainer)
- {
- invokeNotificationHandler(resultContainer,
- internalNotificationHandler, null);
- }
-
- private class InternalNotificationHandler
- extends AbstractNotificationHandler<Object>
- {
- @Override
- public HandlerResult handleNotification(
- AssociationChangeNotification not, Object unused) {
- if (not.event().equals(
- AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
- association == null) {
- SctpAssocChange sac = (SctpAssocChange) not;
- association = new SctpAssociationImpl
- (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
- }
- return HandlerResult.CONTINUE;
- }
- }
-
- private <T> HandlerResult invokeNotificationHandler
- (SctpResultContainer resultContainer,
- NotificationHandler<T> handler,
- T attachment) {
- SctpNotification notification = resultContainer.notification();
- synchronized (stateLock) {
- notification.setAssociation(association);
- }
-
- if (!(handler instanceof AbstractNotificationHandler)) {
- return handler.handleNotification(notification, attachment);
- }
-
- /* AbstractNotificationHandler */
- AbstractNotificationHandler<T> absHandler =
- (AbstractNotificationHandler<T>)handler;
- switch(resultContainer.type()) {
- case ASSOCIATION_CHANGED :
- return absHandler.handleNotification(
- resultContainer.getAssociationChanged(), attachment);
- case PEER_ADDRESS_CHANGED :
- return absHandler.handleNotification(
- resultContainer.getPeerAddressChanged(), attachment);
- case SEND_FAILED :
- return absHandler.handleNotification(
- resultContainer.getSendFailed(), attachment);
- case SHUTDOWN :
- return absHandler.handleNotification(
- resultContainer.getShutdown(), attachment);
- default :
- /* implementation specific handlers */
- return absHandler.handleNotification(
- resultContainer.notification(), attachment);
- }
- }
-
- private void checkAssociation(Association sendAssociation) {
- synchronized (stateLock) {
- if (sendAssociation != null && !sendAssociation.equals(association)) {
- throw new IllegalArgumentException(
- "Cannot send to another association");
- }
- }
- }
-
- private void checkStreamNumber(int streamNumber) {
- synchronized (stateLock) {
- if (association != null) {
- if (streamNumber < 0 ||
- streamNumber >= association.maxOutboundStreams())
- throw new InvalidStreamException();
- }
- }
- }
-
- /* TODO: Add support for ttl and isComplete to both 121 12M
- * SCTP_EOR not yet supported on reference platforms
- * TTL support limited...
- */
- @Override
- public int send(ByteBuffer buffer, MessageInfo messageInfo)
- throws IOException {
- if (buffer == null)
- throw new IllegalArgumentException("buffer cannot be null");
-
- if (messageInfo == null)
- throw new IllegalArgumentException("messageInfo cannot be null");
-
- checkAssociation(messageInfo.association());
- checkStreamNumber(messageInfo.streamNumber());
-
- synchronized (sendLock) {
- ensureSendOpen();
-
- int n = 0;
- try {
- begin();
-
- synchronized (stateLock) {
- if(!isOpen())
- return 0;
- senderThread = NativeThread.current();
- }
-
- do {
- n = send(fdVal, buffer, messageInfo);
- } while ((n == IOStatus.INTERRUPTED) && isOpen());
-
- return IOStatus.normalize(n);
- } finally {
- senderCleanup();
- end((n > 0) || (n == IOStatus.UNAVAILABLE));
- assert IOStatus.check(n);
- }
- }
- }
-
- private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
- throws IOException {
- int streamNumber = messageInfo.streamNumber();
- SocketAddress target = messageInfo.address();
- boolean unordered = messageInfo.isUnordered();
- int ppid = messageInfo.payloadProtocolID();
-
- if (src instanceof DirectBuffer)
- return sendFromNativeBuffer(fd, src, target, streamNumber,
- unordered, ppid);
-
- /* Substitute a native buffer */
- int pos = src.position();
- int lim = src.limit();
- assert (pos <= lim && streamNumber >= 0);
-
- int rem = (pos <= lim ? lim - pos : 0);
- ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
- try {
- bb.put(src);
- bb.flip();
- /* Do not update src until we see how many bytes were written */
- src.position(pos);
-
- int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
- unordered, ppid);
- if (n > 0) {
- /* now update src */
- src.position(pos + n);
- }
- return n;
- } finally {
- Util.releaseTemporaryDirectBuffer(bb);
- }
- }
-
- private int sendFromNativeBuffer(int fd,
- ByteBuffer bb,
- SocketAddress target,
- int streamNumber,
- boolean unordered,
- int ppid)
- throws IOException {
- int pos = bb.position();
- int lim = bb.limit();
- assert (pos <= lim);
- int rem = (pos <= lim ? lim - pos : 0);
-
- int written = send0(fd, ((DirectBuffer)bb).address() + pos,
- rem, target, -1 /*121*/, streamNumber, unordered, ppid);
- if (written > 0)
- bb.position(pos + written);
- return written;
- }
-
- @Override
- public SctpChannel shutdown() throws IOException {
- synchronized(stateLock) {
- if (isShutdown)
- return this;
-
- ensureSendOpen();
- SctpNet.shutdown(fdVal, -1);
- if (senderThread != 0)
- NativeThread.signal(senderThread);
- isShutdown = true;
- }
- return this;
- }
-
- @Override
- public Set<SocketAddress> getAllLocalAddresses()
- throws IOException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- return Collections.emptySet();
-
- return SctpNet.getLocalAddresses(fdVal);
- }
- }
-
- @Override
- public Set<SocketAddress> getRemoteAddresses()
- throws IOException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isConnected() || isShutdown)
- return Collections.emptySet();
-
- try {
- return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
- } catch (SocketException unused) {
- /* an open connected channel should always have remote addresses */
- return remoteAddresses;
- }
- }
- }
-
- /* Native */
- private static native void initIDs();
-
- static native int receive0(int fd, SctpResultContainer resultContainer,
- long address, int length, boolean peek) throws IOException;
-
- static native int send0(int fd, long address, int length,
- SocketAddress target, int assocId, int streamNumber,
- boolean unordered, int ppid) throws IOException;
-
- private static native int checkConnect(FileDescriptor fd, boolean block,
- boolean ready) throws IOException;
-
- static {
- Util.load(); /* loads nio & net native libraries */
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("sctp"));
- initIDs();
- }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,985 +0,0 @@
-/*
- * Copyright (c) 2009, 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 sun.nio.ch;
-
-import java.net.InetAddress;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.InetSocketAddress;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map.Entry;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.NotYetBoundException;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.AbstractNotificationHandler;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.AssociationChangeNotification;
-import com.sun.nio.sctp.HandlerResult;
-import com.sun.nio.sctp.IllegalReceiveException;
-import com.sun.nio.sctp.InvalidStreamException;
-import com.sun.nio.sctp.IllegalUnbindException;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpMultiChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-import static sun.nio.ch.SctpResultContainer.*;
-
-/**
- * An implementation of SctpMultiChannel
- */
-public class SctpMultiChannelImpl extends SctpMultiChannel
- implements SelChImpl
-{
- private final FileDescriptor fd;
-
- private final int fdVal;
-
- /* IDs of native threads doing send and receives, for signalling */
- private volatile long receiverThread = 0;
- private volatile long senderThread = 0;
-
- /* Lock held by current receiving thread */
- private final Object receiveLock = new Object();
-
- /* Lock held by current sending thread */
- private final Object sendLock = new Object();
-
- /* Lock held by any thread that modifies the state fields declared below
- * DO NOT invoke a blocking I/O operation while holding this lock! */
- private final Object stateLock = new Object();
-
- private enum ChannelState {
- UNINITIALIZED,
- KILLPENDING,
- KILLED,
- }
-
- /* -- The following fields are protected by stateLock -- */
- private ChannelState state = ChannelState.UNINITIALIZED;
-
- /* Binding: Once bound the port will remain constant. */
- int port = -1;
- private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
- /* Has the channel been bound to the wildcard address */
- private boolean wildcard; /* false */
-
- /* Keeps a map of addresses to association, and visa versa */
- private HashMap<SocketAddress, Association> addressMap =
- new HashMap<SocketAddress, Association>();
- private HashMap<Association, Set<SocketAddress>> associationMap =
- new HashMap<Association, Set<SocketAddress>>();
-
- /* -- End of fields protected by stateLock -- */
-
- /* If an association has been shutdown mark it for removal after
- * the user handler has been invoked */
- private final ThreadLocal<Association> associationToRemove =
- new ThreadLocal<Association>() {
- @Override protected Association initialValue() {
- return null;
- }
- };
-
- /* A notification handler cannot invoke receive */
- private final ThreadLocal<Boolean> receiveInvoked =
- new ThreadLocal<Boolean>() {
- @Override protected Boolean initialValue() {
- return Boolean.FALSE;
- }
- };
-
- public SctpMultiChannelImpl(SelectorProvider provider)
- throws IOException {
- //TODO: update provider, remove public modifier
- super(provider);
- this.fd = SctpNet.socket(false /*one-to-many*/);
- this.fdVal = IOUtil.fdVal(fd);
- }
-
- @Override
- public SctpMultiChannel bind(SocketAddress local, int backlog)
- throws IOException {
- synchronized (receiveLock) {
- synchronized (sendLock) {
- synchronized (stateLock) {
- ensureOpen();
- if (isBound())
- SctpNet.throwAlreadyBoundException();
- InetSocketAddress isa = (local == null) ?
- new InetSocketAddress(0) : Net.checkAddress(local);
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkListen(isa.getPort());
- Net.bind(fd, isa.getAddress(), isa.getPort());
-
- InetSocketAddress boundIsa = Net.localAddress(fd);
- port = boundIsa.getPort();
- localAddresses.add(isa);
- if (isa.getAddress().isAnyLocalAddress())
- wildcard = true;
-
- SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
- }
- }
- }
- return this;
- }
-
- @Override
- public SctpMultiChannel bindAddress(InetAddress address)
- throws IOException {
- return bindUnbindAddress(address, true);
- }
-
- @Override
- public SctpMultiChannel unbindAddress(InetAddress address)
- throws IOException {
- return bindUnbindAddress(address, false);
- }
-
- private SctpMultiChannel bindUnbindAddress(InetAddress address,
- boolean add)
- throws IOException {
- if (address == null)
- throw new IllegalArgumentException();
-
- synchronized (receiveLock) {
- synchronized (sendLock) {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- throw new NotYetBoundException();
- if (wildcard)
- throw new IllegalStateException(
- "Cannot add or remove addresses from a channel that is bound to the wildcard address");
- if (address.isAnyLocalAddress())
- throw new IllegalArgumentException(
- "Cannot add or remove the wildcard address");
- if (add) {
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- SctpNet.throwAlreadyBoundException();
- }
- }
- } else { /*removing */
- /* Verify that there is more than one address
- * and that address is already bound */
- if (localAddresses.size() <= 1)
- throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
- boolean foundAddress = false;
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- foundAddress = true;
- break;
- }
- }
- if (!foundAddress )
- throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
- }
-
- SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
-
- /* Update our internal Set to reflect the addition/removal */
- if (add)
- localAddresses.add(new InetSocketAddress(address, port));
- else {
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- localAddresses.remove(addr);
- break;
- }
- }
- }
- }
- }
- }
- return this;
- }
-
- @Override
- public Set<Association> associations()
- throws ClosedChannelException, NotYetBoundException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- throw new NotYetBoundException();
-
- return Collections.unmodifiableSet(associationMap.keySet());
- }
- }
-
- private boolean isBound() {
- synchronized (stateLock) {
- return port == -1 ? false : true;
- }
- }
-
- private void ensureOpen() throws IOException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- }
- }
-
- private void receiverCleanup() throws IOException {
- synchronized (stateLock) {
- receiverThread = 0;
- if (state == ChannelState.KILLPENDING)
- kill();
- }
- }
-
- private void senderCleanup() throws IOException {
- synchronized (stateLock) {
- senderThread = 0;
- if (state == ChannelState.KILLPENDING)
- kill();
- }
- }
-
- @Override
- protected void implConfigureBlocking(boolean block) throws IOException {
- IOUtil.configureBlocking(fd, block);
- }
-
- @Override
- public void implCloseSelectableChannel() throws IOException {
- synchronized (stateLock) {
- SctpNet.preClose(fdVal);
-
- if (receiverThread != 0)
- NativeThread.signal(receiverThread);
-
- if (senderThread != 0)
- NativeThread.signal(senderThread);
-
- if (!isRegistered())
- kill();
- }
- }
-
- @Override
- public FileDescriptor getFD() {
- return fd;
- }
-
- @Override
- public int getFDVal() {
- return fdVal;
- }
-
- /**
- * Translates native poll revent ops into a ready operation ops
- */
- private boolean translateReadyOps(int ops, int initialOps,
- SelectionKeyImpl sk) {
- int intOps = sk.nioInterestOps();
- int oldOps = sk.nioReadyOps();
- int newOps = initialOps;
-
- if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
- /* This should only happen if this channel is pre-closed while a
- * selection operation is in progress
- * ## Throw an error if this channel has not been pre-closed */
- return false;
- }
-
- if ((ops & (PollArrayWrapper.POLLERR
- | PollArrayWrapper.POLLHUP)) != 0) {
- newOps = intOps;
- sk.nioReadyOps(newOps);
- return (newOps & ~oldOps) != 0;
- }
-
- if (((ops & PollArrayWrapper.POLLIN) != 0) &&
- ((intOps & SelectionKey.OP_READ) != 0))
- newOps |= SelectionKey.OP_READ;
-
- if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
- ((intOps & SelectionKey.OP_WRITE) != 0))
- newOps |= SelectionKey.OP_WRITE;
-
- sk.nioReadyOps(newOps);
- return (newOps & ~oldOps) != 0;
- }
-
- @Override
- public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
- return translateReadyOps(ops, sk.nioReadyOps(), sk);
- }
-
- @Override
- public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
- return translateReadyOps(ops, 0, sk);
- }
-
- @Override
- public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
- int newOps = 0;
- if ((ops & SelectionKey.OP_READ) != 0)
- newOps |= PollArrayWrapper.POLLIN;
- if ((ops & SelectionKey.OP_WRITE) != 0)
- newOps |= PollArrayWrapper.POLLOUT;
- sk.selector.putEventOps(sk, newOps);
- }
-
- @Override
- public void kill() throws IOException {
- synchronized (stateLock) {
- if (state == ChannelState.KILLED)
- return;
- if (state == ChannelState.UNINITIALIZED) {
- state = ChannelState.KILLED;
- return;
- }
- assert !isOpen() && !isRegistered();
-
- /* Postpone the kill if there is a thread sending or receiving. */
- if (receiverThread == 0 && senderThread == 0) {
- SctpNet.close(fdVal);
- state = ChannelState.KILLED;
- } else {
- state = ChannelState.KILLPENDING;
- }
- }
- }
-
- @Override
- public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
- T value,
- Association association)
- throws IOException {
- if (name == null)
- throw new NullPointerException();
- if (!(supportedOptions().contains(name)))
- throw new UnsupportedOperationException("'" + name + "' not supported");
-
- synchronized (stateLock) {
- if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
- name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
- checkAssociation(association);
- }
- if (!isOpen())
- throw new ClosedChannelException();
-
- int assocId = association == null ? 0 : association.associationID();
- SctpNet.setSocketOption(fdVal, name, value, assocId);
- }
- return this;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getOption(SctpSocketOption<T> name, Association association)
- throws IOException {
- if (name == null)
- throw new NullPointerException();
- if (!supportedOptions().contains(name))
- throw new UnsupportedOperationException("'" + name + "' not supported");
-
- synchronized (stateLock) {
- if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
- name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
- checkAssociation(association);
- }
- if (!isOpen())
- throw new ClosedChannelException();
-
- int assocId = association == null ? 0 : association.associationID();
- return (T)SctpNet.getSocketOption(fdVal, name, assocId);
- }
- }
-
- private static class DefaultOptionsHolder {
- static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
-
- private static Set<SctpSocketOption<?>> defaultOptions() {
- HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
- set.add(SCTP_DISABLE_FRAGMENTS);
- set.add(SCTP_EXPLICIT_COMPLETE);
- set.add(SCTP_FRAGMENT_INTERLEAVE);
- set.add(SCTP_INIT_MAXSTREAMS);
- set.add(SCTP_NODELAY);
- set.add(SCTP_PRIMARY_ADDR);
- set.add(SCTP_SET_PEER_PRIMARY_ADDR);
- set.add(SO_SNDBUF);
- set.add(SO_RCVBUF);
- set.add(SO_LINGER);
- return Collections.unmodifiableSet(set);
- }
- }
-
- @Override
- public final Set<SctpSocketOption<?>> supportedOptions() {
- return DefaultOptionsHolder.defaultOptions;
- }
-
- @Override
- public <T> MessageInfo receive(ByteBuffer buffer,
- T attachment,
- NotificationHandler<T> handler)
- throws IOException {
- if (buffer == null)
- throw new IllegalArgumentException("buffer cannot be null");
-
- if (buffer.isReadOnly())
- throw new IllegalArgumentException("Read-only buffer");
-
- if (receiveInvoked.get())
- throw new IllegalReceiveException(
- "cannot invoke receive from handler");
- receiveInvoked.set(Boolean.TRUE);
-
- try {
- SctpResultContainer resultContainer = new SctpResultContainer();
- do {
- resultContainer.clear();
- synchronized (receiveLock) {
- ensureOpen();
- if (!isBound())
- throw new NotYetBoundException();
-
- int n = 0;
- try {
- begin();
-
- synchronized (stateLock) {
- if(!isOpen())
- return null;
- receiverThread = NativeThread.current();
- }
-
- do {
- n = receive(fdVal, buffer, resultContainer);
- } while ((n == IOStatus.INTERRUPTED) && isOpen());
-
- } finally {
- receiverCleanup();
- end((n > 0) || (n == IOStatus.UNAVAILABLE));
- assert IOStatus.check(n);
- }
-
- if (!resultContainer.isNotification()) {
- /* message or nothing */
- if (resultContainer.hasSomething()) {
- /* Set the association before returning */
- SctpMessageInfoImpl info =
- resultContainer.getMessageInfo();
- info.setAssociation(lookupAssociation(info.
- associationID()));
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- InetSocketAddress isa = (InetSocketAddress)info.address();
- if (!addressMap.containsKey(isa)) {
- /* must be a new association */
- try {
- sm.checkAccept(isa.getAddress().getHostAddress(),
- isa.getPort());
- } catch (SecurityException se) {
- buffer.clear();
- throw se;
- }
- }
- }
-
- assert info.association() != null;
- return info;
- } else {
- /* Non-blocking may return null if nothing available*/
- return null;
- }
- } else { /* notification */
- synchronized (stateLock) {
- handleNotificationInternal(
- resultContainer);
- }
- }
- } /* receiveLock */
- } while (handler == null ? true :
- (invokeNotificationHandler(resultContainer, handler, attachment)
- == HandlerResult.CONTINUE));
- } finally {
- receiveInvoked.set(Boolean.FALSE);
- }
-
- return null;
- }
-
- private int receive(int fd,
- ByteBuffer dst,
- SctpResultContainer resultContainer)
- throws IOException {
- int pos = dst.position();
- int lim = dst.limit();
- assert (pos <= lim);
- int rem = (pos <= lim ? lim - pos : 0);
- if (dst instanceof DirectBuffer && rem > 0)
- return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos);
-
- /* Substitute a native buffer. */
- int newSize = Math.max(rem, 1);
- ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
- try {
- int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0);
- bb.flip();
- if (n > 0 && rem > 0)
- dst.put(bb);
- return n;
- } finally {
- Util.releaseTemporaryDirectBuffer(bb);
- }
- }
-
- private int receiveIntoNativeBuffer(int fd,
- SctpResultContainer resultContainer,
- ByteBuffer bb,
- int rem,
- int pos)
- throws IOException {
- int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem);
- if (n > 0)
- bb.position(pos + n);
- return n;
- }
-
- private InternalNotificationHandler internalNotificationHandler =
- new InternalNotificationHandler();
-
- private void handleNotificationInternal(SctpResultContainer resultContainer)
- {
- invokeNotificationHandler(resultContainer,
- internalNotificationHandler, null);
- }
-
- private class InternalNotificationHandler
- extends AbstractNotificationHandler<Object>
- {
- @Override
- public HandlerResult handleNotification(
- AssociationChangeNotification not, Object unused) {
- SctpAssocChange sac = (SctpAssocChange) not;
-
- /* Update map to reflect change in association */
- switch (not.event()) {
- case COMM_UP :
- Association newAssociation = new SctpAssociationImpl
- (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
- addAssociation(newAssociation);
- break;
- case SHUTDOWN :
- case COMM_LOST :
- //case RESTART: ???
- /* mark association for removal after user handler invoked*/
- associationToRemove.set(lookupAssociation(sac.assocId()));
- }
- return HandlerResult.CONTINUE;
- }
- }
-
- private <T> HandlerResult invokeNotificationHandler(
- SctpResultContainer resultContainer,
- NotificationHandler<T> handler,
- T attachment) {
- HandlerResult result;
- SctpNotification notification = resultContainer.notification();
- notification.setAssociation(lookupAssociation(notification.assocId()));
-
- if (!(handler instanceof AbstractNotificationHandler)) {
- result = handler.handleNotification(notification, attachment);
- } else { /* AbstractNotificationHandler */
- AbstractNotificationHandler<T> absHandler =
- (AbstractNotificationHandler<T>)handler;
- switch(resultContainer.type()) {
- case ASSOCIATION_CHANGED :
- result = absHandler.handleNotification(
- resultContainer.getAssociationChanged(), attachment);
- break;
- case PEER_ADDRESS_CHANGED :
- result = absHandler.handleNotification(
- resultContainer.getPeerAddressChanged(), attachment);
- break;
- case SEND_FAILED :
- result = absHandler.handleNotification(
- resultContainer.getSendFailed(), attachment);
- break;
- case SHUTDOWN :
- result = absHandler.handleNotification(
- resultContainer.getShutdown(), attachment);
- break;
- default :
- /* implementation specific handlers */
- result = absHandler.handleNotification(
- resultContainer.notification(), attachment);
- }
- }
-
- if (!(handler instanceof InternalNotificationHandler)) {
- /* Only remove associations after user handler
- * has finished with them */
- Association assoc = associationToRemove.get();
- if (assoc != null) {
- removeAssociation(assoc);
- associationToRemove.set(null);
- }
-
- }
-
- return result;
- }
-
- private Association lookupAssociation(int assocId) {
- /* Lookup the association in our internal map */
- synchronized (stateLock) {
- Set<Association> assocs = associationMap.keySet();
- for (Association a : assocs) {
- if (a.associationID() == assocId) {
- return a;
- }
- }
- }
- return null;
- }
-
- private void addAssociation(Association association) {
- synchronized (stateLock) {
- int assocId = association.associationID();
- Set<SocketAddress> addresses = null;
-
- try {
- addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
- } catch (IOException unused) {
- /* OK, determining connected addresses may not be possible
- * shutdown, connection lost, etc */
- }
-
- associationMap.put(association, addresses);
- if (addresses != null) {
- for (SocketAddress addr : addresses)
- addressMap.put(addr, association);
- }
- }
- }
-
- private void removeAssociation(Association association) {
- synchronized (stateLock) {
- int assocId = association.associationID();
- Set<SocketAddress> addresses = null;
-
- try {
- addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
- } catch (IOException unused) {
- /* OK, determining connected addresses may not be possible
- * shutdown, connection lost, etc */
- }
-
- Set<Association> assocs = associationMap.keySet();
- for (Association a : assocs) {
- if (a.associationID() == assocId) {
- associationMap.remove(a);
- break;
- }
- }
- if (addresses != null) {
- for (SocketAddress addr : addresses)
- addressMap.remove(addr);
- } else {
- /* We cannot determine the connected addresses */
- Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
- addressMap.entrySet();
- Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
- while (iterator.hasNext()) {
- Entry<SocketAddress, Association> entry = iterator.next();
- if (entry.getValue().equals(association)) {
- iterator.remove();
- }
- }
- }
- }
- }
-
- /**
- * @throws IllegalArgumentException
- * If the given association is not controlled by this channel
- *
- * @return {@code true} if, and only if, the given association is one
- * of the current associations controlled by this channel
- */
- private boolean checkAssociation(Association messageAssoc) {
- synchronized (stateLock) {
- for (Association association : associationMap.keySet()) {
- if (messageAssoc.equals(association)) {
- return true;
- }
- }
- }
- throw new IllegalArgumentException(
- "Given Association is not controlled by this channel");
- }
-
- private void checkStreamNumber(Association assoc, int streamNumber) {
- synchronized (stateLock) {
- if (streamNumber < 0 || streamNumber >= assoc.maxOutboundStreams())
- throw new InvalidStreamException();
- }
- }
-
- /* TODO: Add support for ttl and isComplete to both 121 12M
- * SCTP_EOR not yet supported on reference platforms
- * TTL support limited...
- */
- @Override
- public int send(ByteBuffer buffer, MessageInfo messageInfo)
- throws IOException {
- if (buffer == null)
- throw new IllegalArgumentException("buffer cannot be null");
-
- if (messageInfo == null)
- throw new IllegalArgumentException("messageInfo cannot be null");
-
- synchronized (sendLock) {
- ensureOpen();
-
- if (!isBound())
- bind(null, 0);
-
- int n = 0;
- try {
- int assocId = -1;
- SocketAddress address = null;
- begin();
-
- synchronized (stateLock) {
- if(!isOpen())
- return 0;
- senderThread = NativeThread.current();
-
- /* Determine what address or association to send to */
- Association assoc = messageInfo.association();
- InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
- if (assoc != null) {
- checkAssociation(assoc);
- checkStreamNumber(assoc, messageInfo.streamNumber());
- assocId = assoc.associationID();
- /* have we also got a preferred address */
- if (addr != null) {
- if (!assoc.equals(addressMap.get(addr)))
- throw new IllegalArgumentException("given preferred address is not part of this association");
- address = addr;
- }
- } else if (addr != null) {
- address = addr;
- Association association = addressMap.get(addr);
- if (association != null) {
- checkStreamNumber(association, messageInfo.streamNumber());
- assocId = association.associationID();
-
- } else { /* must be new association */
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkConnect(addr.getAddress().getHostAddress(),
- addr.getPort());
- }
- } else {
- throw new AssertionError(
- "Both association and address cannot be null");
- }
- }
-
- do {
- n = send(fdVal, buffer, assocId, address, messageInfo);
- } while ((n == IOStatus.INTERRUPTED) && isOpen());
-
- return IOStatus.normalize(n);
- } finally {
- senderCleanup();
- end((n > 0) || (n == IOStatus.UNAVAILABLE));
- assert IOStatus.check(n);
- }
- }
- }
-
- private int send(int fd,
- ByteBuffer src,
- int assocId,
- SocketAddress target,
- MessageInfo messageInfo)
- throws IOException {
- int streamNumber = messageInfo.streamNumber();
- boolean unordered = messageInfo.isUnordered();
- int ppid = messageInfo.payloadProtocolID();
-
- if (src instanceof DirectBuffer)
- return sendFromNativeBuffer(fd, src, target, assocId,
- streamNumber, unordered, ppid);
-
- /* Substitute a native buffer */
- int pos = src.position();
- int lim = src.limit();
- assert (pos <= lim && streamNumber >= 0);
-
- int rem = (pos <= lim ? lim - pos : 0);
- ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
- try {
- bb.put(src);
- bb.flip();
- /* Do not update src until we see how many bytes were written */
- src.position(pos);
-
- int n = sendFromNativeBuffer(fd, bb, target, assocId,
- streamNumber, unordered, ppid);
- if (n > 0) {
- /* now update src */
- src.position(pos + n);
- }
- return n;
- } finally {
- Util.releaseTemporaryDirectBuffer(bb);
- }
- }
-
- private int sendFromNativeBuffer(int fd,
- ByteBuffer bb,
- SocketAddress target,
- int assocId,
- int streamNumber,
- boolean unordered,
- int ppid)
- throws IOException {
- int pos = bb.position();
- int lim = bb.limit();
- assert (pos <= lim);
- int rem = (pos <= lim ? lim - pos : 0);
-
- int written = send0(fd, ((DirectBuffer)bb).address() + pos,
- rem, target, assocId, streamNumber, unordered, ppid);
- if (written > 0)
- bb.position(pos + written);
- return written;
- }
-
- @Override
- public SctpMultiChannel shutdown(Association association)
- throws IOException {
- synchronized (stateLock) {
- checkAssociation(association);
- if (!isOpen())
- throw new ClosedChannelException();
-
- SctpNet.shutdown(fdVal, association.associationID());
- }
- return this;
- }
-
- @Override
- public Set<SocketAddress> getAllLocalAddresses()
- throws IOException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- return Collections.emptySet();
-
- return SctpNet.getLocalAddresses(fdVal);
- }
- }
-
- @Override
- public Set<SocketAddress> getRemoteAddresses(Association association)
- throws IOException {
- synchronized (stateLock) {
- checkAssociation(association);
- if (!isOpen())
- throw new ClosedChannelException();
-
- try {
- return SctpNet.getRemoteAddresses(fdVal, association.associationID());
- } catch (SocketException se) {
- /* a valid association should always have remote addresses */
- Set<SocketAddress> addrs = associationMap.get(association);
- return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
- }
- }
- }
-
- @Override
- public SctpChannel branch(Association association)
- throws IOException {
- synchronized (stateLock) {
- checkAssociation(association);
- if (!isOpen())
- throw new ClosedChannelException();
-
- FileDescriptor bFd = SctpNet.branch(fdVal,
- association.associationID());
- /* successfully branched, we can now remove it from assoc list */
- removeAssociation(association);
-
- return new SctpChannelImpl(provider(), bFd, association);
- }
- }
-
- /* Use common native implementation shared between
- * one-to-one and one-to-many */
- private static int receive0(int fd,
- SctpResultContainer resultContainer,
- long address,
- int length)
- throws IOException{
- return SctpChannelImpl.receive0(fd, resultContainer, address,
- length, false /*peek */);
- }
-
- private static int send0(int fd,
- long address,
- int length,
- SocketAddress target,
- int assocId,
- int streamNumber,
- boolean unordered,
- int ppid)
- throws IOException {
- return SctpChannelImpl.send0(fd, address, length, target, assocId,
- streamNumber, unordered, ppid);
- }
-
- static {
- Util.load(); /* loads nio & net native libraries */
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("sctp"));
- }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpNet.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2009, 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 sun.nio.ch;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.channels.AlreadyBoundException;
-import java.util.Set;
-import java.util.HashSet;
-import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
-import com.sun.nio.sctp.SctpSocketOption;
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-
-public class SctpNet {
- static final String osName = AccessController.doPrivileged(
- new GetPropertyAction("os.name"));
-
- /* -- Miscellaneous SCTP utilities -- */
-
- private static boolean IPv4MappedAddresses() {
- if ("SunOS".equals(osName)) {
- /* Solaris supports IPv4Mapped Addresses with bindx */
- return true;
- } /* else { //other OS/implementations */
-
- /* lksctp/linux requires Ipv4 addresses */
- return false;
- }
-
- static boolean throwAlreadyBoundException() throws IOException {
- throw new AlreadyBoundException();
- }
-
- static void listen(int fd, int backlog) throws IOException {
- listen0(fd, backlog);
- }
-
- static int connect(int fd, InetAddress remote, int remotePort)
- throws IOException {
- return connect0(fd, remote, remotePort);
- }
-
- static void close(int fd) throws IOException {
- close0(fd);
- }
-
- static void preClose(int fd) throws IOException {
- preClose0(fd);
- }
-
- /**
- * @param oneToOne
- * if {@code true} returns a one-to-one sctp socket, otherwise
- * returns a one-to-many sctp socket
- */
- static FileDescriptor socket(boolean oneToOne) throws IOException {
- int nativefd = socket0(oneToOne);
- return IOUtil.newFD(nativefd);
- }
-
- static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
- throws IOException {
- bindx(fd, addrs, port, addrs.length, add,
- IPv4MappedAddresses());
- }
-
- static Set<SocketAddress> getLocalAddresses(int fd)
- throws IOException {
- HashSet<SocketAddress> set = null;
- SocketAddress[] saa = getLocalAddresses0(fd);
-
- if (saa != null) {
- set = new HashSet<SocketAddress>(saa.length);
- for (SocketAddress sa : saa)
- set.add(sa);
- }
-
- return set;
- }
-
- static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
- throws IOException {
- HashSet<SocketAddress> set = null;
- SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
-
- if (saa != null) {
- set = new HashSet<SocketAddress>(saa.length);
- for (SocketAddress sa : saa)
- set.add(sa);
- }
-
- return set;
- }
-
- static <T> void setSocketOption(int fd,
- SctpSocketOption<T> name,
- T value,
- int assocId)
- throws IOException {
- if (value == null)
- throw new IllegalArgumentException("Invalid option value");
-
- if (name.equals(SCTP_INIT_MAXSTREAMS)) {
- InitMaxStreams maxStreamValue = (InitMaxStreams)value;
- SctpNet.setInitMsgOption0(fd,
- maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
- } else if (name.equals(SCTP_PRIMARY_ADDR) ||
- name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
-
- SocketAddress addr = (SocketAddress) value;
- if (addr == null)
- throw new IllegalArgumentException("Invalid option value");
-
- Net.checkAddress(addr);
- InetSocketAddress netAddr = (InetSocketAddress)addr;
-
- if (name.equals(SCTP_PRIMARY_ADDR)) {
- setPrimAddrOption0(fd,
- assocId,
- netAddr.getAddress(),
- netAddr.getPort());
- } else {
- setPeerPrimAddrOption0(fd,
- assocId,
- netAddr.getAddress(),
- netAddr.getPort(),
- IPv4MappedAddresses());
- }
- } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
- name.equals(SCTP_EXPLICIT_COMPLETE) ||
- name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
- name.equals(SCTP_NODELAY) ||
- name.equals(SO_SNDBUF) ||
- name.equals(SO_RCVBUF) ||
- name.equals(SO_LINGER)) {
- setIntOption(fd, name, value);
- } else {
- throw new AssertionError("Unknown socket option");
- }
- }
-
- static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
- throws IOException {
- if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
- throw new IllegalArgumentException(
- "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
- } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
- /* container for holding maxIn/Out streams */
- int[] values = new int[2];
- SctpNet.getInitMsgOption0(fd, values);
- return InitMaxStreams.create(values[0], values[1]);
- } else if (name.equals(SCTP_PRIMARY_ADDR)) {
- return getPrimAddrOption0(fd, assocId);
- } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
- name.equals(SCTP_EXPLICIT_COMPLETE) ||
- name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
- name.equals(SCTP_NODELAY) ||
- name.equals(SO_SNDBUF) ||
- name.equals(SO_RCVBUF) ||
- name.equals(SO_LINGER)) {
- return getIntOption(fd, name);
- } else {
- throw new AssertionError("Unknown socket option");
- }
- }
-
- static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
- throws IOException {
- if (value == null)
- throw new IllegalArgumentException("Invalid option value");
-
- Class<?> type = name.type();
- if (type != Integer.class && type != Boolean.class)
- throw new AssertionError("Should not reach here");
-
- if (name == SO_RCVBUF ||
- name == SO_SNDBUF)
- {
- int i = ((Integer)value).intValue();
- if (i < 0)
- throw new IllegalArgumentException(
- "Invalid send/receive buffer size");
- } else if (name == SO_LINGER) {
- int i = ((Integer)value).intValue();
- if (i < 0)
- value = Integer.valueOf(-1);
- if (i > 65535)
- value = Integer.valueOf(65535);
- } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
- int i = ((Integer)value).intValue();
- if (i < 0 || i > 2)
- throw new IllegalArgumentException(
- "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
- }
-
- int arg;
- if (type == Integer.class) {
- arg = ((Integer)value).intValue();
- } else {
- boolean b = ((Boolean)value).booleanValue();
- arg = (b) ? 1 : 0;
- }
-
- setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
- }
-
- static Object getIntOption(int fd, SctpSocketOption<?> name)
- throws IOException {
- Class<?> type = name.type();
-
- if (type != Integer.class && type != Boolean.class)
- throw new AssertionError("Should not reach here");
-
- if (!(name instanceof SctpStdSocketOption))
- throw new AssertionError("Should not reach here");
-
- int value = getIntOption0(fd,
- ((SctpStdSocketOption)name).constValue());
-
- if (type == Integer.class) {
- return Integer.valueOf(value);
- } else {
- return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
- }
- }
-
- static void shutdown(int fd, int assocId)
- throws IOException {
- shutdown0(fd, assocId);
- }
-
- static FileDescriptor branch(int fd, int assocId) throws IOException {
- int nativefd = branch0(fd, assocId);
- return IOUtil.newFD(nativefd);
- }
-
- /* Native Methods */
- static native int socket0(boolean oneToOne) throws IOException;
-
- static native void listen0(int fd, int backlog) throws IOException;
-
- static native int connect0(int fd, InetAddress remote, int remotePort)
- throws IOException;
-
- static native void close0(int fd) throws IOException;
-
- static native void preClose0(int fd) throws IOException;
-
- static native void bindx(int fd, InetAddress[] addrs, int port, int length,
- boolean add, boolean preferIPv6) throws IOException;
-
- static native int getIntOption0(int fd, int opt) throws IOException;
-
- static native void setIntOption0(int fd, int opt, int arg)
- throws IOException;
-
- static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
-
- static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
- throws IOException;
-
- static native int branch0(int fd, int assocId) throws IOException;
-
- static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
- int port) throws IOException;
-
- static native void setPeerPrimAddrOption0(int fd, int assocId,
- InetAddress ia, int port, boolean preferIPv6) throws IOException;
-
- static native SocketAddress getPrimAddrOption0(int fd, int assocId)
- throws IOException;
-
- /* retVals [0] maxInStreams, [1] maxOutStreams */
- static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
-
- static native void setInitMsgOption0(int fd, int arg1, int arg2)
- throws IOException;
-
- static native void shutdown0(int fd, int assocId);
-
- static native void init();
-
- static {
- init();
- }
-}
-
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpNotification.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.Notification;
-
-/**
- * All Notification implemenations MUST implement this interface to provide
- * access to the native association identidier.
- */
-interface SctpNotification extends Notification {
- int assocId();
- void setAssociation(Association association);
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpPeerAddrChange.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import java.net.SocketAddress;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.PeerAddressChangeNotification;
-
-/**
- * An implementation of PeerAddressChangeNotification
- */
-public class SctpPeerAddrChange extends PeerAddressChangeNotification
- implements SctpNotification
-{
- /* static final ints so that they can be referenced from native */
- private final static int SCTP_ADDR_AVAILABLE = 1;
- private final static int SCTP_ADDR_UNREACHABLE = 2;
- private final static int SCTP_ADDR_REMOVED = 3;
- private final static int SCTP_ADDR_ADDED = 4;
- private final static int SCTP_ADDR_MADE_PRIM = 5;
- private final static int SCTP_ADDR_CONFIRMED =6;
-
- private Association association;
-
- /* assocId is used to lookup the association before the notification is
- * returned to user code */
- private int assocId;
- private SocketAddress address;
- private AddressChangeEvent event;
-
- /* Invoked from native */
- private SctpPeerAddrChange(int assocId, SocketAddress address, int intEvent) {
- switch (intEvent) {
- case SCTP_ADDR_AVAILABLE :
- this.event = AddressChangeEvent.ADDR_AVAILABLE;
- break;
- case SCTP_ADDR_UNREACHABLE :
- this.event = AddressChangeEvent.ADDR_UNREACHABLE;
- break;
- case SCTP_ADDR_REMOVED :
- this.event = AddressChangeEvent.ADDR_REMOVED;
- break;
- case SCTP_ADDR_ADDED :
- this.event = AddressChangeEvent.ADDR_ADDED;
- break;
- case SCTP_ADDR_MADE_PRIM :
- this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
- break;
- case SCTP_ADDR_CONFIRMED :
- this.event = AddressChangeEvent.ADDR_CONFIRMED;
- break;
- default:
- throw new AssertionError("Unknown event type");
- }
- this.assocId = assocId;
- this.address = address;
- }
-
- @Override
- public int assocId() {
- return assocId;
- }
-
- @Override
- public void setAssociation(Association association) {
- this.association = association;
- }
-
- @Override
- public SocketAddress address() {
- assert address != null;
- return address;
- }
-
- @Override
- public Association association() {
- assert association != null;
- return association;
- }
-
- @Override
- public AddressChangeEvent event() {
- assert event != null;
- return event;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(super.toString()).append(" [");
- sb.append("Address: ").append(address);
- sb.append(", Association:").append(association);
- sb.append(", Event: ").append(event).append("]");
- return sb.toString();
- }
-}
-
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpResultContainer.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-/**
- * Wraps the actual message or notification so that it can be
- * set and returned from the native receive implementation.
- */
-public class SctpResultContainer {
- /* static final ints so that they can be referenced from native */
- static final int NOTHING = 0;
- static final int MESSAGE = 1;
- static final int SEND_FAILED = 2;
- static final int ASSOCIATION_CHANGED = 3;
- static final int PEER_ADDRESS_CHANGED = 4;
- static final int SHUTDOWN = 5;
-
- private Object value;
- private int type;
-
- int type() {
- return type;
- }
-
- boolean hasSomething() {
- return type() != NOTHING;
- }
-
- boolean isNotification() {
- return type() != MESSAGE && type() != NOTHING ? true : false;
- }
-
- void clear() {
- type = NOTHING;
- value = null;
- }
-
- SctpNotification notification() {
- assert type() != MESSAGE && type() != NOTHING;
-
- return (SctpNotification) value;
- }
-
- SctpMessageInfoImpl getMessageInfo() {
- assert type() == MESSAGE;
-
- if (value instanceof SctpMessageInfoImpl)
- return (SctpMessageInfoImpl) value;
-
- return null;
- }
-
- SctpSendFailed getSendFailed() {
- assert type() == SEND_FAILED;
-
- if (value instanceof SctpSendFailed)
- return (SctpSendFailed) value;
-
- return null;
- }
-
- SctpAssocChange getAssociationChanged() {
- assert type() == ASSOCIATION_CHANGED;
-
- if (value instanceof SctpAssocChange)
- return (SctpAssocChange) value;
-
- return null;
- }
-
- SctpPeerAddrChange getPeerAddressChanged() {
- assert type() == PEER_ADDRESS_CHANGED;
-
- if (value instanceof SctpPeerAddrChange)
- return (SctpPeerAddrChange) value;
-
- return null;
- }
-
- SctpShutdown getShutdown() {
- assert type() == SHUTDOWN;
-
- if (value instanceof SctpShutdown)
- return (SctpShutdown) value;
-
- return null;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("Type: ");
- switch (type) {
- case NOTHING: sb.append("NOTHING"); break;
- case MESSAGE: sb.append("MESSAGE"); break;
- case SEND_FAILED: sb.append("SEND FAILED"); break;
- case ASSOCIATION_CHANGED: sb.append("ASSOCIATION CHANGE"); break;
- case PEER_ADDRESS_CHANGED: sb.append("PEER ADDRESS CHANGE"); break;
- case SHUTDOWN: sb.append("SHUTDOWN"); break;
- default : sb.append("Unknown result type");
- }
- sb.append(", Value: ");
- sb.append((value == null) ? "null" : value.toString());
- return sb.toString();
- }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpSendFailed.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import java.nio.ByteBuffer;
-import java.net.SocketAddress;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.SendFailedNotification;
-
-/**
- * An implementation of SendFailedNotification
- */
-public class SctpSendFailed extends SendFailedNotification
- implements SctpNotification
-{
- private Association association;
- /* assocId is used to lookup the association before the notification is
- * returned to user code */
- private int assocId;
- private SocketAddress address;
- private ByteBuffer buffer;
- private int errorCode;
- private int streamNumber;
-
- /* Invoked from native */
- private SctpSendFailed(int assocId,
- SocketAddress address,
- ByteBuffer buffer,
- int errorCode,
- int streamNumber) {
- this.assocId = assocId;
- this.errorCode = errorCode;
- this.streamNumber = streamNumber;
- this.address = address;
- this.buffer = buffer;
- }
-
- @Override
- public int assocId() {
- return assocId;
- }
-
- @Override
- public void setAssociation(Association association) {
- this.association = association;
- }
-
- @Override
- public Association association() {
- /* may be null */
- return association;
- }
-
- @Override
- public SocketAddress address() {
- assert address != null;
- return address;
- }
-
- @Override
- public ByteBuffer buffer() {
- assert buffer != null;
- return buffer;
- }
-
- @Override
- public int errorCode() {
- return errorCode;
- }
-
- @Override
- public int streamNumber() {
- return streamNumber;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(super.toString()).append(" [");
- sb.append("Association:").append(association);
- sb.append(", Address: ").append(address);
- sb.append(", buffer: ").append(buffer);
- sb.append(", errorCode: ").append(errorCode);
- sb.append(", streamNumber: ").append(streamNumber);
- sb.append("]");
- return sb.toString();
- }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,425 +0,0 @@
-/*
- * Copyright (c) 2009, 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 sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetSocketAddress;
-import java.net.InetAddress;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.NotYetBoundException;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.IllegalUnbindException;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpServerChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-import com.sun.nio.sctp.SctpStandardSocketOptions;
-
-/**
- * An implementation of SctpServerChannel
- */
-public class SctpServerChannelImpl extends SctpServerChannel
- implements SelChImpl
-{
- private final FileDescriptor fd;
-
- private final int fdVal;
-
- /* IDs of native thread doing accept, for signalling */
- private volatile long thread = 0;
-
- /* Lock held by thread currently blocked in this channel */
- private final Object lock = new Object();
-
- /* Lock held by any thread that modifies the state fields declared below
- * DO NOT invoke a blocking I/O operation while holding this lock! */
- private final Object stateLock = new Object();
-
- private enum ChannelState {
- UNINITIALIZED,
- INUSE,
- KILLPENDING,
- KILLED,
- }
- /* -- The following fields are protected by stateLock -- */
- private ChannelState state = ChannelState.UNINITIALIZED;
-
- /* Binding: Once bound the port will remain constant. */
- int port = -1;
- private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
- /* Has the channel been bound to the wildcard address */
- private boolean wildcard; /* false */
-
- /* -- End of fields protected by stateLock -- */
-
- /**
- * Initializes a new instance of this class.
- */
- public SctpServerChannelImpl(SelectorProvider provider)
- throws IOException {
- //TODO: update provider remove public modifier
- super(provider);
- this.fd = SctpNet.socket(true);
- this.fdVal = IOUtil.fdVal(fd);
- this.state = ChannelState.INUSE;
- }
-
- @Override
- public SctpServerChannel bind(SocketAddress local, int backlog)
- throws IOException {
- synchronized (lock) {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (isBound())
- SctpNet.throwAlreadyBoundException();
-
- InetSocketAddress isa = (local == null) ?
- new InetSocketAddress(0) : Net.checkAddress(local);
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkListen(isa.getPort());
- Net.bind(fd, isa.getAddress(), isa.getPort());
-
- InetSocketAddress boundIsa = Net.localAddress(fd);
- port = boundIsa.getPort();
- localAddresses.add(isa);
- if (isa.getAddress().isAnyLocalAddress())
- wildcard = true;
-
- SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
- }
- }
- return this;
- }
-
- @Override
- public SctpServerChannel bindAddress(InetAddress address)
- throws IOException {
- return bindUnbindAddress(address, true);
- }
-
- @Override
- public SctpServerChannel unbindAddress(InetAddress address)
- throws IOException {
- return bindUnbindAddress(address, false);
- }
-
- private SctpServerChannel bindUnbindAddress(InetAddress address, boolean add)
- throws IOException {
- if (address == null)
- throw new IllegalArgumentException();
-
- synchronized (lock) {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- throw new NotYetBoundException();
- if (wildcard)
- throw new IllegalStateException(
- "Cannot add or remove addresses from a channel that is bound to the wildcard address");
- if (address.isAnyLocalAddress())
- throw new IllegalArgumentException(
- "Cannot add or remove the wildcard address");
- if (add) {
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- SctpNet.throwAlreadyBoundException();
- }
- }
- } else { /*removing */
- /* Verify that there is more than one address
- * and that address is already bound */
- if (localAddresses.size() <= 1)
- throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
- boolean foundAddress = false;
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- foundAddress = true;
- break;
- }
- }
- if (!foundAddress )
- throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
- }
-
- SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
-
- /* Update our internal Set to reflect the addition/removal */
- if (add)
- localAddresses.add(new InetSocketAddress(address, port));
- else {
- for (InetSocketAddress addr : localAddresses) {
- if (addr.getAddress().equals(address)) {
- localAddresses.remove(addr);
- break;
- }
- }
- }
- }
- }
- return this;
- }
-
- private boolean isBound() {
- synchronized (stateLock) {
- return port == -1 ? false : true;
- }
- }
-
- private void acceptCleanup() throws IOException {
- synchronized (stateLock) {
- thread = 0;
- if (state == ChannelState.KILLPENDING)
- kill();
- }
- }
-
- @Override
- public SctpChannel accept() throws IOException {
- synchronized (lock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- throw new NotYetBoundException();
- SctpChannel sc = null;
-
- int n = 0;
- FileDescriptor newfd = new FileDescriptor();
- InetSocketAddress[] isaa = new InetSocketAddress[1];
-
- try {
- begin();
- if (!isOpen())
- return null;
- thread = NativeThread.current();
- for (;;) {
- n = accept0(fd, newfd, isaa);
- if ((n == IOStatus.INTERRUPTED) && isOpen())
- continue;
- break;
- }
- } finally {
- acceptCleanup();
- end(n > 0);
- assert IOStatus.check(n);
- }
-
- if (n < 1)
- return null;
-
- IOUtil.configureBlocking(newfd, true);
- InetSocketAddress isa = isaa[0];
- sc = new SctpChannelImpl(provider(), newfd);
-
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkAccept(isa.getAddress().getHostAddress(),
- isa.getPort());
-
- return sc;
- }
- }
-
- @Override
- protected void implConfigureBlocking(boolean block) throws IOException {
- IOUtil.configureBlocking(fd, block);
- }
-
- @Override
- public void implCloseSelectableChannel() throws IOException {
- synchronized (stateLock) {
- SctpNet.preClose(fdVal);
- if (thread != 0)
- NativeThread.signal(thread);
- if (!isRegistered())
- kill();
- }
- }
-
- @Override
- public void kill() throws IOException {
- synchronized (stateLock) {
- if (state == ChannelState.KILLED)
- return;
- if (state == ChannelState.UNINITIALIZED) {
- state = ChannelState.KILLED;
- return;
- }
- assert !isOpen() && !isRegistered();
-
- // Postpone the kill if there is a thread in accept
- if (thread == 0) {
- SctpNet.close(fdVal);
- state = ChannelState.KILLED;
- } else {
- state = ChannelState.KILLPENDING;
- }
- }
- }
-
- @Override
- public FileDescriptor getFD() {
- return fd;
- }
-
- @Override
- public int getFDVal() {
- return fdVal;
- }
-
- /**
- * Translates native poll revent ops into a ready operation ops
- */
- private boolean translateReadyOps(int ops, int initialOps,
- SelectionKeyImpl sk) {
- int intOps = sk.nioInterestOps();
- int oldOps = sk.nioReadyOps();
- int newOps = initialOps;
-
- if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
- /* This should only happen if this channel is pre-closed while a
- * selection operation is in progress
- * ## Throw an error if this channel has not been pre-closed */
- return false;
- }
-
- if ((ops & (PollArrayWrapper.POLLERR
- | PollArrayWrapper.POLLHUP)) != 0) {
- newOps = intOps;
- sk.nioReadyOps(newOps);
- return (newOps & ~oldOps) != 0;
- }
-
- if (((ops & PollArrayWrapper.POLLIN) != 0) &&
- ((intOps & SelectionKey.OP_ACCEPT) != 0))
- newOps |= SelectionKey.OP_ACCEPT;
-
- sk.nioReadyOps(newOps);
- return (newOps & ~oldOps) != 0;
- }
-
- @Override
- public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
- return translateReadyOps(ops, sk.nioReadyOps(), sk);
- }
-
- @Override
- public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
- return translateReadyOps(ops, 0, sk);
- }
-
- @Override
- public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
- int newOps = 0;
-
- /* Translate ops */
- if ((ops & SelectionKey.OP_ACCEPT) != 0)
- newOps |= PollArrayWrapper.POLLIN;
- /* Place ops into pollfd array */
- sk.selector.putEventOps(sk, newOps);
-
- }
-
- @Override
- public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value)
- throws IOException {
- if (name == null)
- throw new NullPointerException();
- if (!supportedOptions().contains(name))
- throw new UnsupportedOperationException("'" + name + "' not supported");
-
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
-
- SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
- return this;
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getOption(SctpSocketOption<T> name) throws IOException {
- if (name == null)
- throw new NullPointerException();
- if (!supportedOptions().contains(name))
- throw new UnsupportedOperationException("'" + name + "' not supported");
-
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
-
- return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
- }
- }
-
- private static class DefaultOptionsHolder {
- static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
-
- private static Set<SctpSocketOption<?>> defaultOptions() {
- HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
- set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
- return Collections.unmodifiableSet(set);
- }
- }
-
- @Override
- public final Set<SctpSocketOption<?>> supportedOptions() {
- return DefaultOptionsHolder.defaultOptions;
- }
-
- @Override
- public Set<SocketAddress> getAllLocalAddresses()
- throws IOException {
- synchronized (stateLock) {
- if (!isOpen())
- throw new ClosedChannelException();
- if (!isBound())
- return Collections.emptySet();
-
- return SctpNet.getLocalAddresses(fdVal);
- }
- }
-
- /* Native */
- private static native void initIDs();
-
- private static native int accept0(FileDescriptor ssfd,
- FileDescriptor newfd, InetSocketAddress[] isaa) throws IOException;
-
- static {
- Util.load(); // loads nio & net native libraries
- java.security.AccessController.doPrivileged(
- new sun.security.action.LoadLibraryAction("sctp"));
- initIDs();
- }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpShutdown.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.ShutdownNotification;
-
-/**
- * An implementation of ShutdownNotification
- */
-public class SctpShutdown extends ShutdownNotification
- implements SctpNotification
-{
- private Association association;
- /* assocId is used to lookup the association before the notification is
- * returned to user code */
- private int assocId;
-
- /* Invoked from native */
- private SctpShutdown(int assocId) {
- this.assocId = assocId;
- }
-
- @Override
- public int assocId() {
- return assocId;
- }
-
- @Override
- public void setAssociation(Association association) {
- this.association = association;
- }
-
- @Override
- public Association association() {
- assert association != null;
- return association;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(super.toString()).append(" [");
- sb.append("Association:").append(association).append("]");
- return sb.toString();
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.AssociationChangeNotification;
+
+/**
+ * An implementation of AssociationChangeNotification
+ */
+public class AssociationChange extends AssociationChangeNotification
+ implements SctpNotification
+{
+ /* static final ints so that they can be referenced from native */
+ private final static int SCTP_COMM_UP = 1;
+ private final static int SCTP_COMM_LOST = 2;
+ private final static int SCTP_RESTART = 3;
+ private final static int SCTP_SHUTDOWN = 4;
+ private final static int SCTP_CANT_START = 5;
+
+ private Association association;
+
+ /* assocId is used to lookup the association before the notification is
+ * returned to user code */
+ private int assocId;
+ private AssocChangeEvent event;
+ private int maxOutStreams;
+ private int maxInStreams;
+
+ /* Invoked from native */
+ private AssociationChange(int assocId,
+ int intEvent,
+ int maxOutStreams,
+ int maxInStreams) {
+ switch (intEvent) {
+ case SCTP_COMM_UP :
+ this.event = AssocChangeEvent.COMM_UP;
+ break;
+ case SCTP_COMM_LOST :
+ this.event = AssocChangeEvent.COMM_LOST;
+ break;
+ case SCTP_RESTART :
+ this.event = AssocChangeEvent.RESTART;
+ break;
+ case SCTP_SHUTDOWN :
+ this.event = AssocChangeEvent.SHUTDOWN;
+ break;
+ case SCTP_CANT_START :
+ this.event = AssocChangeEvent.CANT_START;
+ break;
+ default :
+ throw new AssertionError(
+ "Unknown Association Change Event type: " + intEvent);
+ }
+
+ this.assocId = assocId;
+ this.maxOutStreams = maxOutStreams;
+ this.maxInStreams = maxInStreams;
+ }
+
+ @Override
+ public int assocId() {
+ return assocId;
+ }
+
+ @Override
+ public void setAssociation(Association association) {
+ this.association = association;
+ }
+
+ @Override
+ public Association association() {
+ assert association != null;
+ return association;
+ }
+
+ @Override
+ public AssocChangeEvent event() {
+ return event;
+ }
+
+ int maxOutStreams() {
+ return maxOutStreams;
+ }
+
+ int maxInStreams() {
+ return maxInStreams;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString()).append(" [");
+ sb.append("Association:").append(association);
+ sb.append(", Event: ").append(event).append("]");
+ return sb.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+
+/**
+ * An implementation of Association
+ */
+public class AssociationImpl extends Association {
+ public AssociationImpl(int associationID,
+ int maxInStreams,
+ int maxOutStreams) {
+ super(associationID, maxInStreams, maxOutStreams);
+ }
+
+ @Override
+ public String toString() {
+ StringBuffer sb = new StringBuffer(super.toString());
+ return sb.append("[associationID:")
+ .append(associationID())
+ .append(", maxIn:")
+ .append(maxInboundStreams())
+ .append(", maxOut:")
+ .append(maxOutboundStreams())
+ .append("]")
+ .toString();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.PeerAddressChangeNotification;
+
+/**
+ * An implementation of PeerAddressChangeNotification
+ */
+public class PeerAddrChange extends PeerAddressChangeNotification
+ implements SctpNotification
+{
+ /* static final ints so that they can be referenced from native */
+ private final static int SCTP_ADDR_AVAILABLE = 1;
+ private final static int SCTP_ADDR_UNREACHABLE = 2;
+ private final static int SCTP_ADDR_REMOVED = 3;
+ private final static int SCTP_ADDR_ADDED = 4;
+ private final static int SCTP_ADDR_MADE_PRIM = 5;
+ private final static int SCTP_ADDR_CONFIRMED =6;
+
+ private Association association;
+
+ /* assocId is used to lookup the association before the notification is
+ * returned to user code */
+ private int assocId;
+ private SocketAddress address;
+ private AddressChangeEvent event;
+
+ /* Invoked from native */
+ private PeerAddrChange(int assocId, SocketAddress address, int intEvent) {
+ switch (intEvent) {
+ case SCTP_ADDR_AVAILABLE :
+ this.event = AddressChangeEvent.ADDR_AVAILABLE;
+ break;
+ case SCTP_ADDR_UNREACHABLE :
+ this.event = AddressChangeEvent.ADDR_UNREACHABLE;
+ break;
+ case SCTP_ADDR_REMOVED :
+ this.event = AddressChangeEvent.ADDR_REMOVED;
+ break;
+ case SCTP_ADDR_ADDED :
+ this.event = AddressChangeEvent.ADDR_ADDED;
+ break;
+ case SCTP_ADDR_MADE_PRIM :
+ this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
+ break;
+ case SCTP_ADDR_CONFIRMED :
+ this.event = AddressChangeEvent.ADDR_CONFIRMED;
+ break;
+ default:
+ throw new AssertionError("Unknown event type");
+ }
+ this.assocId = assocId;
+ this.address = address;
+ }
+
+ @Override
+ public int assocId() {
+ return assocId;
+ }
+
+ @Override
+ public void setAssociation(Association association) {
+ this.association = association;
+ }
+
+ @Override
+ public SocketAddress address() {
+ assert address != null;
+ return address;
+ }
+
+ @Override
+ public Association association() {
+ assert association != null;
+ return association;
+ }
+
+ @Override
+ public AddressChangeEvent event() {
+ assert event != null;
+ return event;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString()).append(" [");
+ sb.append("Address: ").append(address);
+ sb.append(", Association:").append(association);
+ sb.append(", Event: ").append(event).append("]");
+ return sb.toString();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+/**
+ * Wraps the actual message or notification so that it can be
+ * set and returned from the native receive implementation.
+ */
+public class ResultContainer {
+ /* static final ints so that they can be referenced from native */
+ static final int NOTHING = 0;
+ static final int MESSAGE = 1;
+ static final int SEND_FAILED = 2;
+ static final int ASSOCIATION_CHANGED = 3;
+ static final int PEER_ADDRESS_CHANGED = 4;
+ static final int SHUTDOWN = 5;
+
+ private Object value;
+ private int type;
+
+ int type() {
+ return type;
+ }
+
+ boolean hasSomething() {
+ return type() != NOTHING;
+ }
+
+ boolean isNotification() {
+ return type() != MESSAGE && type() != NOTHING ? true : false;
+ }
+
+ void clear() {
+ type = NOTHING;
+ value = null;
+ }
+
+ SctpNotification notification() {
+ assert type() != MESSAGE && type() != NOTHING;
+
+ return (SctpNotification) value;
+ }
+
+ MessageInfoImpl getMessageInfo() {
+ assert type() == MESSAGE;
+
+ if (value instanceof MessageInfoImpl)
+ return (MessageInfoImpl) value;
+
+ return null;
+ }
+
+ SendFailed getSendFailed() {
+ assert type() == SEND_FAILED;
+
+ if (value instanceof SendFailed)
+ return (SendFailed) value;
+
+ return null;
+ }
+
+ AssociationChange getAssociationChanged() {
+ assert type() == ASSOCIATION_CHANGED;
+
+ if (value instanceof AssociationChange)
+ return (AssociationChange) value;
+
+ return null;
+ }
+
+ PeerAddrChange getPeerAddressChanged() {
+ assert type() == PEER_ADDRESS_CHANGED;
+
+ if (value instanceof PeerAddrChange)
+ return (PeerAddrChange) value;
+
+ return null;
+ }
+
+ Shutdown getShutdown() {
+ assert type() == SHUTDOWN;
+
+ if (value instanceof Shutdown)
+ return (Shutdown) value;
+
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Type: ");
+ switch (type) {
+ case NOTHING: sb.append("NOTHING"); break;
+ case MESSAGE: sb.append("MESSAGE"); break;
+ case SEND_FAILED: sb.append("SEND FAILED"); break;
+ case ASSOCIATION_CHANGED: sb.append("ASSOCIATION CHANGE"); break;
+ case PEER_ADDRESS_CHANGED: sb.append("PEER ADDRESS CHANGE"); break;
+ case SHUTDOWN: sb.append("SHUTDOWN"); break;
+ default : sb.append("Unknown result type");
+ }
+ sb.append(", Value: ");
+ sb.append((value == null) ? "null" : value.toString());
+ return sb.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,1106 @@
+/*
+ * Copyright (c) 2009, 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 sun.nio.ch.sctp;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.InetSocketAddress;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.ConnectionPendingException;
+import java.nio.channels.NoConnectionPendingException;
+import java.nio.channels.AlreadyConnectedException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.NotYetConnectedException;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.AbstractNotificationHandler;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.AssociationChangeNotification;
+import com.sun.nio.sctp.HandlerResult;
+import com.sun.nio.sctp.IllegalReceiveException;
+import com.sun.nio.sctp.InvalidStreamException;
+import com.sun.nio.sctp.IllegalUnbindException;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+import sun.nio.ch.DirectBuffer;
+import sun.nio.ch.IOStatus;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.NativeThread;
+import sun.nio.ch.Net;
+import sun.nio.ch.PollArrayWrapper;
+import sun.nio.ch.SelChImpl;
+import sun.nio.ch.SelectionKeyImpl;
+import sun.nio.ch.Util;
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+import static sun.nio.ch.sctp.ResultContainer.SEND_FAILED;
+import static sun.nio.ch.sctp.ResultContainer.ASSOCIATION_CHANGED;
+import static sun.nio.ch.sctp.ResultContainer.PEER_ADDRESS_CHANGED;
+import static sun.nio.ch.sctp.ResultContainer.SHUTDOWN;
+
+/**
+ * An implementation of an SctpChannel
+ */
+public class SctpChannelImpl extends SctpChannel
+ implements SelChImpl
+{
+ private final FileDescriptor fd;
+
+ private final int fdVal;
+
+ /* IDs of native threads doing send and receivess, for signalling */
+ private volatile long receiverThread = 0;
+ private volatile long senderThread = 0;
+
+ /* Lock held by current receiving or connecting thread */
+ private final Object receiveLock = new Object();
+
+ /* Lock held by current sending or connecting thread */
+ private final Object sendLock = new Object();
+
+ private final ThreadLocal<Boolean> receiveInvoked =
+ new ThreadLocal<Boolean>() {
+ @Override protected Boolean initialValue() {
+ return Boolean.FALSE;
+ }
+ };
+
+ /* Lock held by any thread that modifies the state fields declared below
+ DO NOT invoke a blocking I/O operation while holding this lock! */
+ private final Object stateLock = new Object();
+
+ private enum ChannelState {
+ UNINITIALIZED,
+ UNCONNECTED,
+ PENDING,
+ CONNECTED,
+ KILLPENDING,
+ KILLED,
+ }
+ /* -- The following fields are protected by stateLock -- */
+ private ChannelState state = ChannelState.UNINITIALIZED;
+
+ /* Binding; Once bound the port will remain constant. */
+ int port = -1;
+ private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
+ /* Has the channel been bound to the wildcard address */
+ private boolean wildcard; /* false */
+ //private InetSocketAddress remoteAddress = null;
+
+ /* Input/Output open */
+ private boolean readyToConnect;
+
+ /* Shutdown */
+ private boolean isShutdown;
+
+ private Association association;
+
+ private Set<SocketAddress> remoteAddresses = Collections.emptySet();
+
+ /* -- End of fields protected by stateLock -- */
+
+ /**
+ * Constructor for normal connecting sockets
+ */
+ public SctpChannelImpl(SelectorProvider provider) throws IOException {
+ //TODO: update provider remove public modifier
+ super(provider);
+ this.fd = SctpNet.socket(true);
+ this.fdVal = IOUtil.fdVal(fd);
+ this.state = ChannelState.UNCONNECTED;
+ }
+
+ /**
+ * Constructor for sockets obtained from server sockets
+ */
+ public SctpChannelImpl(SelectorProvider provider, FileDescriptor fd)
+ throws IOException {
+ this(provider, fd, null);
+ }
+
+ /**
+ * Constructor for sockets obtained from branching
+ */
+ public SctpChannelImpl(SelectorProvider provider,
+ FileDescriptor fd,
+ Association association)
+ throws IOException {
+ super(provider);
+ this.fd = fd;
+ this.fdVal = IOUtil.fdVal(fd);
+ this.state = ChannelState.CONNECTED;
+ port = (Net.localAddress(fd)).getPort();
+
+ if (association != null) { /* branched */
+ this.association = association;
+ } else { /* obtained from server channel */
+ /* Receive COMM_UP */
+ ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
+ try {
+ receive(buf, null, null, true);
+ } finally {
+ Util.releaseTemporaryDirectBuffer(buf);
+ }
+ }
+ }
+
+ /**
+ * Binds the channel's socket to a local address.
+ */
+ @Override
+ public SctpChannel bind(SocketAddress local) throws IOException {
+ synchronized (receiveLock) {
+ synchronized (sendLock) {
+ synchronized (stateLock) {
+ ensureOpenAndUnconnected();
+ if (isBound())
+ SctpNet.throwAlreadyBoundException();
+ InetSocketAddress isa = (local == null) ?
+ new InetSocketAddress(0) : Net.checkAddress(local);
+ Net.bind(fd, isa.getAddress(), isa.getPort());
+ InetSocketAddress boundIsa = Net.localAddress(fd);
+ port = boundIsa.getPort();
+ localAddresses.add(isa);
+ if (isa.getAddress().isAnyLocalAddress())
+ wildcard = true;
+ }
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public SctpChannel bindAddress(InetAddress address)
+ throws IOException {
+ bindUnbindAddress(address, true);
+ localAddresses.add(new InetSocketAddress(address, port));
+ return this;
+ }
+
+ @Override
+ public SctpChannel unbindAddress(InetAddress address)
+ throws IOException {
+ bindUnbindAddress(address, false);
+ localAddresses.remove(new InetSocketAddress(address, port));
+ return this;
+ }
+
+ private SctpChannel bindUnbindAddress(InetAddress address, boolean add)
+ throws IOException {
+ if (address == null)
+ throw new IllegalArgumentException();
+
+ synchronized (receiveLock) {
+ synchronized (sendLock) {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ throw new NotYetBoundException();
+ if (wildcard)
+ throw new IllegalStateException(
+ "Cannot add or remove addresses from a channel that is bound to the wildcard address");
+ if (address.isAnyLocalAddress())
+ throw new IllegalArgumentException(
+ "Cannot add or remove the wildcard address");
+ if (add) {
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ SctpNet.throwAlreadyBoundException();
+ }
+ }
+ } else { /*removing */
+ /* Verify that there is more than one address
+ * and that address is already bound */
+ if (localAddresses.size() <= 1)
+ throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
+ boolean foundAddress = false;
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ foundAddress = true;
+ break;
+ }
+ }
+ if (!foundAddress )
+ throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
+ }
+
+ SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
+
+ /* Update our internal Set to reflect the addition/removal */
+ if (add)
+ localAddresses.add(new InetSocketAddress(address, port));
+ else {
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ localAddresses.remove(addr);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+ private boolean isBound() {
+ synchronized (stateLock) {
+ return port == -1 ? false : true;
+ }
+ }
+
+ private boolean isConnected() {
+ synchronized (stateLock) {
+ return (state == ChannelState.CONNECTED);
+ }
+ }
+
+ private void ensureOpenAndUnconnected() throws IOException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (isConnected())
+ throw new AlreadyConnectedException();
+ if (state == ChannelState.PENDING)
+ throw new ConnectionPendingException();
+ }
+ }
+
+ private boolean ensureReceiveOpen() throws ClosedChannelException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isConnected())
+ throw new NotYetConnectedException();
+ else
+ return true;
+ }
+ }
+
+ private void ensureSendOpen() throws ClosedChannelException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (isShutdown)
+ throw new ClosedChannelException();
+ if (!isConnected())
+ throw new NotYetConnectedException();
+ }
+ }
+
+ private void receiverCleanup() throws IOException {
+ synchronized (stateLock) {
+ receiverThread = 0;
+ if (state == ChannelState.KILLPENDING)
+ kill();
+ }
+ }
+
+ private void senderCleanup() throws IOException {
+ synchronized (stateLock) {
+ senderThread = 0;
+ if (state == ChannelState.KILLPENDING)
+ kill();
+ }
+ }
+
+ @Override
+ public Association association() throws ClosedChannelException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isConnected())
+ return null;
+
+ return association;
+ }
+ }
+
+ @Override
+ public boolean connect(SocketAddress endpoint) throws IOException {
+ synchronized (receiveLock) {
+ synchronized (sendLock) {
+ ensureOpenAndUnconnected();
+ InetSocketAddress isa = Net.checkAddress(endpoint);
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkConnect(isa.getAddress().getHostAddress(),
+ isa.getPort());
+ synchronized (blockingLock()) {
+ int n = 0;
+ try {
+ try {
+ begin();
+ synchronized (stateLock) {
+ if (!isOpen()) {
+ return false;
+ }
+ receiverThread = NativeThread.current();
+ }
+ for (;;) {
+ InetAddress ia = isa.getAddress();
+ if (ia.isAnyLocalAddress())
+ ia = InetAddress.getLocalHost();
+ n = SctpNet.connect(fdVal, ia, isa.getPort());
+ if ( (n == IOStatus.INTERRUPTED)
+ && isOpen())
+ continue;
+ break;
+ }
+ } finally {
+ receiverCleanup();
+ end((n > 0) || (n == IOStatus.UNAVAILABLE));
+ assert IOStatus.check(n);
+ }
+ } catch (IOException x) {
+ /* If an exception was thrown, close the channel after
+ * invoking end() so as to avoid bogus
+ * AsynchronousCloseExceptions */
+ close();
+ throw x;
+ }
+
+ if (n > 0) {
+ synchronized (stateLock) {
+ /* Connection succeeded */
+ state = ChannelState.CONNECTED;
+ if (!isBound()) {
+ InetSocketAddress boundIsa =
+ Net.localAddress(fd);
+ port = boundIsa.getPort();
+ }
+
+ /* Receive COMM_UP */
+ ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
+ try {
+ receive(buf, null, null, true);
+ } finally {
+ Util.releaseTemporaryDirectBuffer(buf);
+ }
+
+ /* cache remote addresses */
+ try {
+ remoteAddresses = getRemoteAddresses();
+ } catch (IOException unused) { /* swallow exception */ }
+
+ return true;
+ }
+ } else {
+ synchronized (stateLock) {
+ /* If nonblocking and no exception then connection
+ * pending; disallow another invocation */
+ if (!isBlocking())
+ state = ChannelState.PENDING;
+ else
+ assert false;
+ }
+ }
+ }
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public boolean connect(SocketAddress endpoint,
+ int maxOutStreams,
+ int maxInStreams)
+ throws IOException {
+ ensureOpenAndUnconnected();
+ return setOption(SCTP_INIT_MAXSTREAMS, InitMaxStreams.
+ create(maxInStreams, maxOutStreams)).connect(endpoint);
+
+ }
+
+ @Override
+ public boolean isConnectionPending() {
+ synchronized (stateLock) {
+ return (state == ChannelState.PENDING);
+ }
+ }
+
+ @Override
+ public boolean finishConnect() throws IOException {
+ synchronized (receiveLock) {
+ synchronized (sendLock) {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (isConnected())
+ return true;
+ if (state != ChannelState.PENDING)
+ throw new NoConnectionPendingException();
+ }
+ int n = 0;
+ try {
+ try {
+ begin();
+ synchronized (blockingLock()) {
+ synchronized (stateLock) {
+ if (!isOpen()) {
+ return false;
+ }
+ receiverThread = NativeThread.current();
+ }
+ if (!isBlocking()) {
+ for (;;) {
+ n = checkConnect(fd, false, readyToConnect);
+ if ( (n == IOStatus.INTERRUPTED)
+ && isOpen())
+ continue;
+ break;
+ }
+ } else {
+ for (;;) {
+ n = checkConnect(fd, true, readyToConnect);
+ if (n == 0) {
+ // Loop in case of
+ // spurious notifications
+ continue;
+ }
+ if ( (n == IOStatus.INTERRUPTED)
+ && isOpen())
+ continue;
+ break;
+ }
+ }
+ }
+ } finally {
+ synchronized (stateLock) {
+ receiverThread = 0;
+ if (state == ChannelState.KILLPENDING) {
+ kill();
+ /* poll()/getsockopt() does not report
+ * error (throws exception, with n = 0)
+ * on Linux platform after dup2 and
+ * signal-wakeup. Force n to 0 so the
+ * end() can throw appropriate exception */
+ n = 0;
+ }
+ }
+ end((n > 0) || (n == IOStatus.UNAVAILABLE));
+ assert IOStatus.check(n);
+ }
+ } catch (IOException x) {
+ /* If an exception was thrown, close the channel after
+ * invoking end() so as to avoid bogus
+ * AsynchronousCloseExceptions */
+ close();
+ throw x;
+ }
+
+ if (n > 0) {
+ synchronized (stateLock) {
+ state = ChannelState.CONNECTED;
+ if (!isBound()) {
+ InetSocketAddress boundIsa =
+ Net.localAddress(fd);
+ port = boundIsa.getPort();
+ }
+
+ /* Receive COMM_UP */
+ ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
+ try {
+ receive(buf, null, null, true);
+ } finally {
+ Util.releaseTemporaryDirectBuffer(buf);
+ }
+
+ /* cache remote addresses */
+ try {
+ remoteAddresses = getRemoteAddresses();
+ } catch (IOException unused) { /* swallow exception */ }
+
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void implConfigureBlocking(boolean block) throws IOException {
+ IOUtil.configureBlocking(fd, block);
+ }
+
+ @Override
+ public void implCloseSelectableChannel() throws IOException {
+ synchronized (stateLock) {
+ SctpNet.preClose(fdVal);
+
+ if (receiverThread != 0)
+ NativeThread.signal(receiverThread);
+
+ if (senderThread != 0)
+ NativeThread.signal(senderThread);
+
+ if (!isRegistered())
+ kill();
+ }
+ }
+
+ @Override
+ public FileDescriptor getFD() {
+ return fd;
+ }
+
+ @Override
+ public int getFDVal() {
+ return fdVal;
+ }
+
+ /**
+ * Translates native poll revent ops into a ready operation ops
+ */
+ private boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl sk) {
+ int intOps = sk.nioInterestOps();
+ int oldOps = sk.nioReadyOps();
+ int newOps = initialOps;
+
+ if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+ /* This should only happen if this channel is pre-closed while a
+ * selection operation is in progress
+ * ## Throw an error if this channel has not been pre-closed */
+ return false;
+ }
+
+ if ((ops & (PollArrayWrapper.POLLERR
+ | PollArrayWrapper.POLLHUP)) != 0) {
+ newOps = intOps;
+ sk.nioReadyOps(newOps);
+ /* No need to poll again in checkConnect,
+ * the error will be detected there */
+ readyToConnect = true;
+ return (newOps & ~oldOps) != 0;
+ }
+
+ if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+ ((intOps & SelectionKey.OP_READ) != 0) &&
+ isConnected())
+ newOps |= SelectionKey.OP_READ;
+
+ if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
+ ((intOps & SelectionKey.OP_CONNECT) != 0) &&
+ ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
+ newOps |= SelectionKey.OP_CONNECT;
+ readyToConnect = true;
+ }
+
+ if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+ ((intOps & SelectionKey.OP_WRITE) != 0) &&
+ isConnected())
+ newOps |= SelectionKey.OP_WRITE;
+
+ sk.nioReadyOps(newOps);
+ return (newOps & ~oldOps) != 0;
+ }
+
+ @Override
+ public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
+ return translateReadyOps(ops, sk.nioReadyOps(), sk);
+ }
+
+ @Override
+ @SuppressWarnings("all")
+ public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
+ return translateReadyOps(ops, 0, sk);
+ }
+
+ @Override
+ public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
+ int newOps = 0;
+ if ((ops & SelectionKey.OP_READ) != 0)
+ newOps |= PollArrayWrapper.POLLIN;
+ if ((ops & SelectionKey.OP_WRITE) != 0)
+ newOps |= PollArrayWrapper.POLLOUT;
+ if ((ops & SelectionKey.OP_CONNECT) != 0)
+ newOps |= PollArrayWrapper.POLLCONN;
+ sk.selector.putEventOps(sk, newOps);
+ }
+
+ @Override
+ public void kill() throws IOException {
+ synchronized (stateLock) {
+ if (state == ChannelState.KILLED)
+ return;
+ if (state == ChannelState.UNINITIALIZED) {
+ state = ChannelState.KILLED;
+ return;
+ }
+ assert !isOpen() && !isRegistered();
+
+ /* Postpone the kill if there is a waiting reader
+ * or writer thread. */
+ if (receiverThread == 0 && senderThread == 0) {
+ SctpNet.close(fdVal);
+ state = ChannelState.KILLED;
+ } else {
+ state = ChannelState.KILLPENDING;
+ }
+ }
+ }
+
+ @Override
+ public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
+ throws IOException {
+ if (name == null)
+ throw new NullPointerException();
+ if (!supportedOptions().contains(name))
+ throw new UnsupportedOperationException("'" + name + "' not supported");
+
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
+ }
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getOption(SctpSocketOption<T> name) throws IOException {
+ if (name == null)
+ throw new NullPointerException();
+ if (!supportedOptions().contains(name))
+ throw new UnsupportedOperationException("'" + name + "' not supported");
+
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
+ }
+ }
+
+ private static class DefaultOptionsHolder {
+ static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
+
+ private static Set<SctpSocketOption<?>> defaultOptions() {
+ HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
+ set.add(SCTP_DISABLE_FRAGMENTS);
+ set.add(SCTP_EXPLICIT_COMPLETE);
+ set.add(SCTP_FRAGMENT_INTERLEAVE);
+ set.add(SCTP_INIT_MAXSTREAMS);
+ set.add(SCTP_NODELAY);
+ set.add(SCTP_PRIMARY_ADDR);
+ set.add(SCTP_SET_PEER_PRIMARY_ADDR);
+ set.add(SO_SNDBUF);
+ set.add(SO_RCVBUF);
+ set.add(SO_LINGER);
+ return Collections.unmodifiableSet(set);
+ }
+ }
+
+ @Override
+ public final Set<SctpSocketOption<?>> supportedOptions() {
+ return DefaultOptionsHolder.defaultOptions;
+ }
+
+ @Override
+ public <T> MessageInfo receive(ByteBuffer buffer,
+ T attachment,
+ NotificationHandler<T> handler)
+ throws IOException {
+ return receive(buffer, attachment, handler, false);
+ }
+
+ private <T> MessageInfo receive(ByteBuffer buffer,
+ T attachment,
+ NotificationHandler<T> handler,
+ boolean fromConnect)
+ throws IOException {
+ if (buffer == null)
+ throw new IllegalArgumentException("buffer cannot be null");
+
+ if (buffer.isReadOnly())
+ throw new IllegalArgumentException("Read-only buffer");
+
+ if (receiveInvoked.get())
+ throw new IllegalReceiveException(
+ "cannot invoke receive from handler");
+ receiveInvoked.set(Boolean.TRUE);
+
+ try {
+ ResultContainer resultContainer = new ResultContainer();
+ do {
+ resultContainer.clear();
+ synchronized (receiveLock) {
+ if (!ensureReceiveOpen())
+ return null;
+
+ int n = 0;
+ try {
+ begin();
+
+ synchronized (stateLock) {
+ if(!isOpen())
+ return null;
+ receiverThread = NativeThread.current();
+ }
+
+ do {
+ n = receive(fdVal, buffer, resultContainer, fromConnect);
+ } while ((n == IOStatus.INTERRUPTED) && isOpen());
+ } finally {
+ receiverCleanup();
+ end((n > 0) || (n == IOStatus.UNAVAILABLE));
+ assert IOStatus.check(n);
+ }
+
+ if (!resultContainer.isNotification()) {
+ /* message or nothing */
+ if (resultContainer.hasSomething()) {
+ /* Set the association before returning */
+ MessageInfoImpl info =
+ resultContainer.getMessageInfo();
+ synchronized (stateLock) {
+ assert association != null;
+ info.setAssociation(association);
+ }
+ return info;
+ } else
+ /* Non-blocking may return null if nothing available*/
+ return null;
+ } else { /* notification */
+ synchronized (stateLock) {
+ handleNotificationInternal(
+ resultContainer);
+ }
+ }
+
+ if (fromConnect) {
+ /* If we reach here, then it was connect that invoked
+ * receive and received the COMM_UP. We have already
+ * handled the COMM_UP with the internal notification
+ * handler. Simply return. */
+ return null;
+ }
+ } /* receiveLock */
+ } while (handler == null ? true :
+ (invokeNotificationHandler(resultContainer, handler, attachment)
+ == HandlerResult.CONTINUE));
+
+ return null;
+ } finally {
+ receiveInvoked.set(Boolean.FALSE);
+ }
+ }
+
+ private int receive(int fd,
+ ByteBuffer dst,
+ ResultContainer resultContainer,
+ boolean peek)
+ throws IOException {
+ int pos = dst.position();
+ int lim = dst.limit();
+ assert (pos <= lim);
+ int rem = (pos <= lim ? lim - pos : 0);
+ if (dst instanceof DirectBuffer && rem > 0)
+ return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos, peek);
+
+ /* Substitute a native buffer */
+ int newSize = Math.max(rem, 1);
+ ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
+ try {
+ int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0, peek);
+ bb.flip();
+ if (n > 0 && rem > 0)
+ dst.put(bb);
+ return n;
+ } finally {
+ Util.releaseTemporaryDirectBuffer(bb);
+ }
+ }
+
+ private int receiveIntoNativeBuffer(int fd,
+ ResultContainer resultContainer,
+ ByteBuffer bb,
+ int rem,
+ int pos,
+ boolean peek)
+ throws IOException
+ {
+ int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem, peek);
+
+ if (n > 0)
+ bb.position(pos + n);
+ return n;
+ }
+
+ private InternalNotificationHandler internalNotificationHandler =
+ new InternalNotificationHandler();
+
+ private void handleNotificationInternal(ResultContainer resultContainer)
+ {
+ invokeNotificationHandler(resultContainer,
+ internalNotificationHandler, null);
+ }
+
+ private class InternalNotificationHandler
+ extends AbstractNotificationHandler<Object>
+ {
+ @Override
+ public HandlerResult handleNotification(
+ AssociationChangeNotification not, Object unused) {
+ if (not.event().equals(
+ AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
+ association == null) {
+ AssociationChange sac = (AssociationChange) not;
+ association = new AssociationImpl
+ (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
+ }
+ return HandlerResult.CONTINUE;
+ }
+ }
+
+ private <T> HandlerResult invokeNotificationHandler
+ (ResultContainer resultContainer,
+ NotificationHandler<T> handler,
+ T attachment) {
+ SctpNotification notification = resultContainer.notification();
+ synchronized (stateLock) {
+ notification.setAssociation(association);
+ }
+
+ if (!(handler instanceof AbstractNotificationHandler)) {
+ return handler.handleNotification(notification, attachment);
+ }
+
+ /* AbstractNotificationHandler */
+ AbstractNotificationHandler<T> absHandler =
+ (AbstractNotificationHandler<T>)handler;
+ switch(resultContainer.type()) {
+ case ASSOCIATION_CHANGED :
+ return absHandler.handleNotification(
+ resultContainer.getAssociationChanged(), attachment);
+ case PEER_ADDRESS_CHANGED :
+ return absHandler.handleNotification(
+ resultContainer.getPeerAddressChanged(), attachment);
+ case SEND_FAILED :
+ return absHandler.handleNotification(
+ resultContainer.getSendFailed(), attachment);
+ case SHUTDOWN :
+ return absHandler.handleNotification(
+ resultContainer.getShutdown(), attachment);
+ default :
+ /* implementation specific handlers */
+ return absHandler.handleNotification(
+ resultContainer.notification(), attachment);
+ }
+ }
+
+ private void checkAssociation(Association sendAssociation) {
+ synchronized (stateLock) {
+ if (sendAssociation != null && !sendAssociation.equals(association)) {
+ throw new IllegalArgumentException(
+ "Cannot send to another association");
+ }
+ }
+ }
+
+ private void checkStreamNumber(int streamNumber) {
+ synchronized (stateLock) {
+ if (association != null) {
+ if (streamNumber < 0 ||
+ streamNumber >= association.maxOutboundStreams())
+ throw new InvalidStreamException();
+ }
+ }
+ }
+
+ /* TODO: Add support for ttl and isComplete to both 121 12M
+ * SCTP_EOR not yet supported on reference platforms
+ * TTL support limited...
+ */
+ @Override
+ public int send(ByteBuffer buffer, MessageInfo messageInfo)
+ throws IOException {
+ if (buffer == null)
+ throw new IllegalArgumentException("buffer cannot be null");
+
+ if (messageInfo == null)
+ throw new IllegalArgumentException("messageInfo cannot be null");
+
+ checkAssociation(messageInfo.association());
+ checkStreamNumber(messageInfo.streamNumber());
+
+ synchronized (sendLock) {
+ ensureSendOpen();
+
+ int n = 0;
+ try {
+ begin();
+
+ synchronized (stateLock) {
+ if(!isOpen())
+ return 0;
+ senderThread = NativeThread.current();
+ }
+
+ do {
+ n = send(fdVal, buffer, messageInfo);
+ } while ((n == IOStatus.INTERRUPTED) && isOpen());
+
+ return IOStatus.normalize(n);
+ } finally {
+ senderCleanup();
+ end((n > 0) || (n == IOStatus.UNAVAILABLE));
+ assert IOStatus.check(n);
+ }
+ }
+ }
+
+ private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
+ throws IOException {
+ int streamNumber = messageInfo.streamNumber();
+ SocketAddress target = messageInfo.address();
+ boolean unordered = messageInfo.isUnordered();
+ int ppid = messageInfo.payloadProtocolID();
+
+ if (src instanceof DirectBuffer)
+ return sendFromNativeBuffer(fd, src, target, streamNumber,
+ unordered, ppid);
+
+ /* Substitute a native buffer */
+ int pos = src.position();
+ int lim = src.limit();
+ assert (pos <= lim && streamNumber >= 0);
+
+ int rem = (pos <= lim ? lim - pos : 0);
+ ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
+ try {
+ bb.put(src);
+ bb.flip();
+ /* Do not update src until we see how many bytes were written */
+ src.position(pos);
+
+ int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
+ unordered, ppid);
+ if (n > 0) {
+ /* now update src */
+ src.position(pos + n);
+ }
+ return n;
+ } finally {
+ Util.releaseTemporaryDirectBuffer(bb);
+ }
+ }
+
+ private int sendFromNativeBuffer(int fd,
+ ByteBuffer bb,
+ SocketAddress target,
+ int streamNumber,
+ boolean unordered,
+ int ppid)
+ throws IOException {
+ int pos = bb.position();
+ int lim = bb.limit();
+ assert (pos <= lim);
+ int rem = (pos <= lim ? lim - pos : 0);
+
+ int written = send0(fd, ((DirectBuffer)bb).address() + pos,
+ rem, target, -1 /*121*/, streamNumber, unordered, ppid);
+ if (written > 0)
+ bb.position(pos + written);
+ return written;
+ }
+
+ @Override
+ public SctpChannel shutdown() throws IOException {
+ synchronized(stateLock) {
+ if (isShutdown)
+ return this;
+
+ ensureSendOpen();
+ SctpNet.shutdown(fdVal, -1);
+ if (senderThread != 0)
+ NativeThread.signal(senderThread);
+ isShutdown = true;
+ }
+ return this;
+ }
+
+ @Override
+ public Set<SocketAddress> getAllLocalAddresses()
+ throws IOException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ return Collections.emptySet();
+
+ return SctpNet.getLocalAddresses(fdVal);
+ }
+ }
+
+ @Override
+ public Set<SocketAddress> getRemoteAddresses()
+ throws IOException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isConnected() || isShutdown)
+ return Collections.emptySet();
+
+ try {
+ return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
+ } catch (SocketException unused) {
+ /* an open connected channel should always have remote addresses */
+ return remoteAddresses;
+ }
+ }
+ }
+
+ /* Native */
+ private static native void initIDs();
+
+ static native int receive0(int fd, ResultContainer resultContainer,
+ long address, int length, boolean peek) throws IOException;
+
+ static native int send0(int fd, long address, int length,
+ SocketAddress target, int assocId, int streamNumber,
+ boolean unordered, int ppid) throws IOException;
+
+ private static native int checkConnect(FileDescriptor fd, boolean block,
+ boolean ready) throws IOException;
+
+ static {
+ Util.load(); /* loads nio & net native libraries */
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.LoadLibraryAction("sctp"));
+ initIDs();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,994 @@
+/*
+ * Copyright (c) 2009, 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 sun.nio.ch.sctp;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.InetSocketAddress;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map.Entry;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.AbstractNotificationHandler;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.AssociationChangeNotification;
+import com.sun.nio.sctp.HandlerResult;
+import com.sun.nio.sctp.IllegalReceiveException;
+import com.sun.nio.sctp.InvalidStreamException;
+import com.sun.nio.sctp.IllegalUnbindException;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpMultiChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+import sun.nio.ch.DirectBuffer;
+import sun.nio.ch.NativeThread;
+import sun.nio.ch.IOStatus;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.Net;
+import sun.nio.ch.PollArrayWrapper;
+import sun.nio.ch.SelChImpl;
+import sun.nio.ch.SelectionKeyImpl;
+import sun.nio.ch.Util;
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+import static sun.nio.ch.sctp.ResultContainer.*;
+
+/**
+ * An implementation of SctpMultiChannel
+ */
+public class SctpMultiChannelImpl extends SctpMultiChannel
+ implements SelChImpl
+{
+ private final FileDescriptor fd;
+
+ private final int fdVal;
+
+ /* IDs of native threads doing send and receives, for signalling */
+ private volatile long receiverThread = 0;
+ private volatile long senderThread = 0;
+
+ /* Lock held by current receiving thread */
+ private final Object receiveLock = new Object();
+
+ /* Lock held by current sending thread */
+ private final Object sendLock = new Object();
+
+ /* Lock held by any thread that modifies the state fields declared below
+ * DO NOT invoke a blocking I/O operation while holding this lock! */
+ private final Object stateLock = new Object();
+
+ private enum ChannelState {
+ UNINITIALIZED,
+ KILLPENDING,
+ KILLED,
+ }
+
+ /* -- The following fields are protected by stateLock -- */
+ private ChannelState state = ChannelState.UNINITIALIZED;
+
+ /* Binding: Once bound the port will remain constant. */
+ int port = -1;
+ private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
+ /* Has the channel been bound to the wildcard address */
+ private boolean wildcard; /* false */
+
+ /* Keeps a map of addresses to association, and visa versa */
+ private HashMap<SocketAddress, Association> addressMap =
+ new HashMap<SocketAddress, Association>();
+ private HashMap<Association, Set<SocketAddress>> associationMap =
+ new HashMap<Association, Set<SocketAddress>>();
+
+ /* -- End of fields protected by stateLock -- */
+
+ /* If an association has been shutdown mark it for removal after
+ * the user handler has been invoked */
+ private final ThreadLocal<Association> associationToRemove =
+ new ThreadLocal<Association>() {
+ @Override protected Association initialValue() {
+ return null;
+ }
+ };
+
+ /* A notification handler cannot invoke receive */
+ private final ThreadLocal<Boolean> receiveInvoked =
+ new ThreadLocal<Boolean>() {
+ @Override protected Boolean initialValue() {
+ return Boolean.FALSE;
+ }
+ };
+
+ public SctpMultiChannelImpl(SelectorProvider provider)
+ throws IOException {
+ //TODO: update provider, remove public modifier
+ super(provider);
+ this.fd = SctpNet.socket(false /*one-to-many*/);
+ this.fdVal = IOUtil.fdVal(fd);
+ }
+
+ @Override
+ public SctpMultiChannel bind(SocketAddress local, int backlog)
+ throws IOException {
+ synchronized (receiveLock) {
+ synchronized (sendLock) {
+ synchronized (stateLock) {
+ ensureOpen();
+ if (isBound())
+ SctpNet.throwAlreadyBoundException();
+ InetSocketAddress isa = (local == null) ?
+ new InetSocketAddress(0) : Net.checkAddress(local);
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkListen(isa.getPort());
+ Net.bind(fd, isa.getAddress(), isa.getPort());
+
+ InetSocketAddress boundIsa = Net.localAddress(fd);
+ port = boundIsa.getPort();
+ localAddresses.add(isa);
+ if (isa.getAddress().isAnyLocalAddress())
+ wildcard = true;
+
+ SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
+ }
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public SctpMultiChannel bindAddress(InetAddress address)
+ throws IOException {
+ return bindUnbindAddress(address, true);
+ }
+
+ @Override
+ public SctpMultiChannel unbindAddress(InetAddress address)
+ throws IOException {
+ return bindUnbindAddress(address, false);
+ }
+
+ private SctpMultiChannel bindUnbindAddress(InetAddress address,
+ boolean add)
+ throws IOException {
+ if (address == null)
+ throw new IllegalArgumentException();
+
+ synchronized (receiveLock) {
+ synchronized (sendLock) {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ throw new NotYetBoundException();
+ if (wildcard)
+ throw new IllegalStateException(
+ "Cannot add or remove addresses from a channel that is bound to the wildcard address");
+ if (address.isAnyLocalAddress())
+ throw new IllegalArgumentException(
+ "Cannot add or remove the wildcard address");
+ if (add) {
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ SctpNet.throwAlreadyBoundException();
+ }
+ }
+ } else { /*removing */
+ /* Verify that there is more than one address
+ * and that address is already bound */
+ if (localAddresses.size() <= 1)
+ throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
+ boolean foundAddress = false;
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ foundAddress = true;
+ break;
+ }
+ }
+ if (!foundAddress )
+ throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
+ }
+
+ SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
+
+ /* Update our internal Set to reflect the addition/removal */
+ if (add)
+ localAddresses.add(new InetSocketAddress(address, port));
+ else {
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ localAddresses.remove(addr);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public Set<Association> associations()
+ throws ClosedChannelException, NotYetBoundException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ throw new NotYetBoundException();
+
+ return Collections.unmodifiableSet(associationMap.keySet());
+ }
+ }
+
+ private boolean isBound() {
+ synchronized (stateLock) {
+ return port == -1 ? false : true;
+ }
+ }
+
+ private void ensureOpen() throws IOException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ }
+ }
+
+ private void receiverCleanup() throws IOException {
+ synchronized (stateLock) {
+ receiverThread = 0;
+ if (state == ChannelState.KILLPENDING)
+ kill();
+ }
+ }
+
+ private void senderCleanup() throws IOException {
+ synchronized (stateLock) {
+ senderThread = 0;
+ if (state == ChannelState.KILLPENDING)
+ kill();
+ }
+ }
+
+ @Override
+ protected void implConfigureBlocking(boolean block) throws IOException {
+ IOUtil.configureBlocking(fd, block);
+ }
+
+ @Override
+ public void implCloseSelectableChannel() throws IOException {
+ synchronized (stateLock) {
+ SctpNet.preClose(fdVal);
+
+ if (receiverThread != 0)
+ NativeThread.signal(receiverThread);
+
+ if (senderThread != 0)
+ NativeThread.signal(senderThread);
+
+ if (!isRegistered())
+ kill();
+ }
+ }
+
+ @Override
+ public FileDescriptor getFD() {
+ return fd;
+ }
+
+ @Override
+ public int getFDVal() {
+ return fdVal;
+ }
+
+ /**
+ * Translates native poll revent ops into a ready operation ops
+ */
+ private boolean translateReadyOps(int ops, int initialOps,
+ SelectionKeyImpl sk) {
+ int intOps = sk.nioInterestOps();
+ int oldOps = sk.nioReadyOps();
+ int newOps = initialOps;
+
+ if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+ /* This should only happen if this channel is pre-closed while a
+ * selection operation is in progress
+ * ## Throw an error if this channel has not been pre-closed */
+ return false;
+ }
+
+ if ((ops & (PollArrayWrapper.POLLERR
+ | PollArrayWrapper.POLLHUP)) != 0) {
+ newOps = intOps;
+ sk.nioReadyOps(newOps);
+ return (newOps & ~oldOps) != 0;
+ }
+
+ if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+ ((intOps & SelectionKey.OP_READ) != 0))
+ newOps |= SelectionKey.OP_READ;
+
+ if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+ ((intOps & SelectionKey.OP_WRITE) != 0))
+ newOps |= SelectionKey.OP_WRITE;
+
+ sk.nioReadyOps(newOps);
+ return (newOps & ~oldOps) != 0;
+ }
+
+ @Override
+ public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
+ return translateReadyOps(ops, sk.nioReadyOps(), sk);
+ }
+
+ @Override
+ public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
+ return translateReadyOps(ops, 0, sk);
+ }
+
+ @Override
+ public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
+ int newOps = 0;
+ if ((ops & SelectionKey.OP_READ) != 0)
+ newOps |= PollArrayWrapper.POLLIN;
+ if ((ops & SelectionKey.OP_WRITE) != 0)
+ newOps |= PollArrayWrapper.POLLOUT;
+ sk.selector.putEventOps(sk, newOps);
+ }
+
+ @Override
+ public void kill() throws IOException {
+ synchronized (stateLock) {
+ if (state == ChannelState.KILLED)
+ return;
+ if (state == ChannelState.UNINITIALIZED) {
+ state = ChannelState.KILLED;
+ return;
+ }
+ assert !isOpen() && !isRegistered();
+
+ /* Postpone the kill if there is a thread sending or receiving. */
+ if (receiverThread == 0 && senderThread == 0) {
+ SctpNet.close(fdVal);
+ state = ChannelState.KILLED;
+ } else {
+ state = ChannelState.KILLPENDING;
+ }
+ }
+ }
+
+ @Override
+ public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
+ T value,
+ Association association)
+ throws IOException {
+ if (name == null)
+ throw new NullPointerException();
+ if (!(supportedOptions().contains(name)))
+ throw new UnsupportedOperationException("'" + name + "' not supported");
+
+ synchronized (stateLock) {
+ if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
+ name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
+ checkAssociation(association);
+ }
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ int assocId = association == null ? 0 : association.associationID();
+ SctpNet.setSocketOption(fdVal, name, value, assocId);
+ }
+ return this;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getOption(SctpSocketOption<T> name, Association association)
+ throws IOException {
+ if (name == null)
+ throw new NullPointerException();
+ if (!supportedOptions().contains(name))
+ throw new UnsupportedOperationException("'" + name + "' not supported");
+
+ synchronized (stateLock) {
+ if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
+ name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
+ checkAssociation(association);
+ }
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ int assocId = association == null ? 0 : association.associationID();
+ return (T)SctpNet.getSocketOption(fdVal, name, assocId);
+ }
+ }
+
+ private static class DefaultOptionsHolder {
+ static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
+
+ private static Set<SctpSocketOption<?>> defaultOptions() {
+ HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
+ set.add(SCTP_DISABLE_FRAGMENTS);
+ set.add(SCTP_EXPLICIT_COMPLETE);
+ set.add(SCTP_FRAGMENT_INTERLEAVE);
+ set.add(SCTP_INIT_MAXSTREAMS);
+ set.add(SCTP_NODELAY);
+ set.add(SCTP_PRIMARY_ADDR);
+ set.add(SCTP_SET_PEER_PRIMARY_ADDR);
+ set.add(SO_SNDBUF);
+ set.add(SO_RCVBUF);
+ set.add(SO_LINGER);
+ return Collections.unmodifiableSet(set);
+ }
+ }
+
+ @Override
+ public final Set<SctpSocketOption<?>> supportedOptions() {
+ return DefaultOptionsHolder.defaultOptions;
+ }
+
+ @Override
+ public <T> MessageInfo receive(ByteBuffer buffer,
+ T attachment,
+ NotificationHandler<T> handler)
+ throws IOException {
+ if (buffer == null)
+ throw new IllegalArgumentException("buffer cannot be null");
+
+ if (buffer.isReadOnly())
+ throw new IllegalArgumentException("Read-only buffer");
+
+ if (receiveInvoked.get())
+ throw new IllegalReceiveException(
+ "cannot invoke receive from handler");
+ receiveInvoked.set(Boolean.TRUE);
+
+ try {
+ ResultContainer resultContainer = new ResultContainer();
+ do {
+ resultContainer.clear();
+ synchronized (receiveLock) {
+ ensureOpen();
+ if (!isBound())
+ throw new NotYetBoundException();
+
+ int n = 0;
+ try {
+ begin();
+
+ synchronized (stateLock) {
+ if(!isOpen())
+ return null;
+ receiverThread = NativeThread.current();
+ }
+
+ do {
+ n = receive(fdVal, buffer, resultContainer);
+ } while ((n == IOStatus.INTERRUPTED) && isOpen());
+
+ } finally {
+ receiverCleanup();
+ end((n > 0) || (n == IOStatus.UNAVAILABLE));
+ assert IOStatus.check(n);
+ }
+
+ if (!resultContainer.isNotification()) {
+ /* message or nothing */
+ if (resultContainer.hasSomething()) {
+ /* Set the association before returning */
+ MessageInfoImpl info =
+ resultContainer.getMessageInfo();
+ info.setAssociation(lookupAssociation(info.
+ associationID()));
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ InetSocketAddress isa = (InetSocketAddress)info.address();
+ if (!addressMap.containsKey(isa)) {
+ /* must be a new association */
+ try {
+ sm.checkAccept(isa.getAddress().getHostAddress(),
+ isa.getPort());
+ } catch (SecurityException se) {
+ buffer.clear();
+ throw se;
+ }
+ }
+ }
+
+ assert info.association() != null;
+ return info;
+ } else {
+ /* Non-blocking may return null if nothing available*/
+ return null;
+ }
+ } else { /* notification */
+ synchronized (stateLock) {
+ handleNotificationInternal(
+ resultContainer);
+ }
+ }
+ } /* receiveLock */
+ } while (handler == null ? true :
+ (invokeNotificationHandler(resultContainer, handler, attachment)
+ == HandlerResult.CONTINUE));
+ } finally {
+ receiveInvoked.set(Boolean.FALSE);
+ }
+
+ return null;
+ }
+
+ private int receive(int fd,
+ ByteBuffer dst,
+ ResultContainer resultContainer)
+ throws IOException {
+ int pos = dst.position();
+ int lim = dst.limit();
+ assert (pos <= lim);
+ int rem = (pos <= lim ? lim - pos : 0);
+ if (dst instanceof DirectBuffer && rem > 0)
+ return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos);
+
+ /* Substitute a native buffer. */
+ int newSize = Math.max(rem, 1);
+ ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
+ try {
+ int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0);
+ bb.flip();
+ if (n > 0 && rem > 0)
+ dst.put(bb);
+ return n;
+ } finally {
+ Util.releaseTemporaryDirectBuffer(bb);
+ }
+ }
+
+ private int receiveIntoNativeBuffer(int fd,
+ ResultContainer resultContainer,
+ ByteBuffer bb,
+ int rem,
+ int pos)
+ throws IOException {
+ int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem);
+ if (n > 0)
+ bb.position(pos + n);
+ return n;
+ }
+
+ private InternalNotificationHandler internalNotificationHandler =
+ new InternalNotificationHandler();
+
+ private void handleNotificationInternal(ResultContainer resultContainer)
+ {
+ invokeNotificationHandler(resultContainer,
+ internalNotificationHandler, null);
+ }
+
+ private class InternalNotificationHandler
+ extends AbstractNotificationHandler<Object>
+ {
+ @Override
+ public HandlerResult handleNotification(
+ AssociationChangeNotification not, Object unused) {
+ AssociationChange sac = (AssociationChange) not;
+
+ /* Update map to reflect change in association */
+ switch (not.event()) {
+ case COMM_UP :
+ Association newAssociation = new AssociationImpl
+ (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
+ addAssociation(newAssociation);
+ break;
+ case SHUTDOWN :
+ case COMM_LOST :
+ //case RESTART: ???
+ /* mark association for removal after user handler invoked*/
+ associationToRemove.set(lookupAssociation(sac.assocId()));
+ }
+ return HandlerResult.CONTINUE;
+ }
+ }
+
+ private <T> HandlerResult invokeNotificationHandler(
+ ResultContainer resultContainer,
+ NotificationHandler<T> handler,
+ T attachment) {
+ HandlerResult result;
+ SctpNotification notification = resultContainer.notification();
+ notification.setAssociation(lookupAssociation(notification.assocId()));
+
+ if (!(handler instanceof AbstractNotificationHandler)) {
+ result = handler.handleNotification(notification, attachment);
+ } else { /* AbstractNotificationHandler */
+ AbstractNotificationHandler<T> absHandler =
+ (AbstractNotificationHandler<T>)handler;
+ switch(resultContainer.type()) {
+ case ASSOCIATION_CHANGED :
+ result = absHandler.handleNotification(
+ resultContainer.getAssociationChanged(), attachment);
+ break;
+ case PEER_ADDRESS_CHANGED :
+ result = absHandler.handleNotification(
+ resultContainer.getPeerAddressChanged(), attachment);
+ break;
+ case SEND_FAILED :
+ result = absHandler.handleNotification(
+ resultContainer.getSendFailed(), attachment);
+ break;
+ case SHUTDOWN :
+ result = absHandler.handleNotification(
+ resultContainer.getShutdown(), attachment);
+ break;
+ default :
+ /* implementation specific handlers */
+ result = absHandler.handleNotification(
+ resultContainer.notification(), attachment);
+ }
+ }
+
+ if (!(handler instanceof InternalNotificationHandler)) {
+ /* Only remove associations after user handler
+ * has finished with them */
+ Association assoc = associationToRemove.get();
+ if (assoc != null) {
+ removeAssociation(assoc);
+ associationToRemove.set(null);
+ }
+
+ }
+
+ return result;
+ }
+
+ private Association lookupAssociation(int assocId) {
+ /* Lookup the association in our internal map */
+ synchronized (stateLock) {
+ Set<Association> assocs = associationMap.keySet();
+ for (Association a : assocs) {
+ if (a.associationID() == assocId) {
+ return a;
+ }
+ }
+ }
+ return null;
+ }
+
+ private void addAssociation(Association association) {
+ synchronized (stateLock) {
+ int assocId = association.associationID();
+ Set<SocketAddress> addresses = null;
+
+ try {
+ addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
+ } catch (IOException unused) {
+ /* OK, determining connected addresses may not be possible
+ * shutdown, connection lost, etc */
+ }
+
+ associationMap.put(association, addresses);
+ if (addresses != null) {
+ for (SocketAddress addr : addresses)
+ addressMap.put(addr, association);
+ }
+ }
+ }
+
+ private void removeAssociation(Association association) {
+ synchronized (stateLock) {
+ int assocId = association.associationID();
+ Set<SocketAddress> addresses = null;
+
+ try {
+ addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
+ } catch (IOException unused) {
+ /* OK, determining connected addresses may not be possible
+ * shutdown, connection lost, etc */
+ }
+
+ Set<Association> assocs = associationMap.keySet();
+ for (Association a : assocs) {
+ if (a.associationID() == assocId) {
+ associationMap.remove(a);
+ break;
+ }
+ }
+ if (addresses != null) {
+ for (SocketAddress addr : addresses)
+ addressMap.remove(addr);
+ } else {
+ /* We cannot determine the connected addresses */
+ Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
+ addressMap.entrySet();
+ Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
+ while (iterator.hasNext()) {
+ Entry<SocketAddress, Association> entry = iterator.next();
+ if (entry.getValue().equals(association)) {
+ iterator.remove();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @throws IllegalArgumentException
+ * If the given association is not controlled by this channel
+ *
+ * @return {@code true} if, and only if, the given association is one
+ * of the current associations controlled by this channel
+ */
+ private boolean checkAssociation(Association messageAssoc) {
+ synchronized (stateLock) {
+ for (Association association : associationMap.keySet()) {
+ if (messageAssoc.equals(association)) {
+ return true;
+ }
+ }
+ }
+ throw new IllegalArgumentException(
+ "Given Association is not controlled by this channel");
+ }
+
+ private void checkStreamNumber(Association assoc, int streamNumber) {
+ synchronized (stateLock) {
+ if (streamNumber < 0 || streamNumber >= assoc.maxOutboundStreams())
+ throw new InvalidStreamException();
+ }
+ }
+
+ /* TODO: Add support for ttl and isComplete to both 121 12M
+ * SCTP_EOR not yet supported on reference platforms
+ * TTL support limited...
+ */
+ @Override
+ public int send(ByteBuffer buffer, MessageInfo messageInfo)
+ throws IOException {
+ if (buffer == null)
+ throw new IllegalArgumentException("buffer cannot be null");
+
+ if (messageInfo == null)
+ throw new IllegalArgumentException("messageInfo cannot be null");
+
+ synchronized (sendLock) {
+ ensureOpen();
+
+ if (!isBound())
+ bind(null, 0);
+
+ int n = 0;
+ try {
+ int assocId = -1;
+ SocketAddress address = null;
+ begin();
+
+ synchronized (stateLock) {
+ if(!isOpen())
+ return 0;
+ senderThread = NativeThread.current();
+
+ /* Determine what address or association to send to */
+ Association assoc = messageInfo.association();
+ InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
+ if (assoc != null) {
+ checkAssociation(assoc);
+ checkStreamNumber(assoc, messageInfo.streamNumber());
+ assocId = assoc.associationID();
+ /* have we also got a preferred address */
+ if (addr != null) {
+ if (!assoc.equals(addressMap.get(addr)))
+ throw new IllegalArgumentException("given preferred address is not part of this association");
+ address = addr;
+ }
+ } else if (addr != null) {
+ address = addr;
+ Association association = addressMap.get(addr);
+ if (association != null) {
+ checkStreamNumber(association, messageInfo.streamNumber());
+ assocId = association.associationID();
+
+ } else { /* must be new association */
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkConnect(addr.getAddress().getHostAddress(),
+ addr.getPort());
+ }
+ } else {
+ throw new AssertionError(
+ "Both association and address cannot be null");
+ }
+ }
+
+ do {
+ n = send(fdVal, buffer, assocId, address, messageInfo);
+ } while ((n == IOStatus.INTERRUPTED) && isOpen());
+
+ return IOStatus.normalize(n);
+ } finally {
+ senderCleanup();
+ end((n > 0) || (n == IOStatus.UNAVAILABLE));
+ assert IOStatus.check(n);
+ }
+ }
+ }
+
+ private int send(int fd,
+ ByteBuffer src,
+ int assocId,
+ SocketAddress target,
+ MessageInfo messageInfo)
+ throws IOException {
+ int streamNumber = messageInfo.streamNumber();
+ boolean unordered = messageInfo.isUnordered();
+ int ppid = messageInfo.payloadProtocolID();
+
+ if (src instanceof DirectBuffer)
+ return sendFromNativeBuffer(fd, src, target, assocId,
+ streamNumber, unordered, ppid);
+
+ /* Substitute a native buffer */
+ int pos = src.position();
+ int lim = src.limit();
+ assert (pos <= lim && streamNumber >= 0);
+
+ int rem = (pos <= lim ? lim - pos : 0);
+ ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
+ try {
+ bb.put(src);
+ bb.flip();
+ /* Do not update src until we see how many bytes were written */
+ src.position(pos);
+
+ int n = sendFromNativeBuffer(fd, bb, target, assocId,
+ streamNumber, unordered, ppid);
+ if (n > 0) {
+ /* now update src */
+ src.position(pos + n);
+ }
+ return n;
+ } finally {
+ Util.releaseTemporaryDirectBuffer(bb);
+ }
+ }
+
+ private int sendFromNativeBuffer(int fd,
+ ByteBuffer bb,
+ SocketAddress target,
+ int assocId,
+ int streamNumber,
+ boolean unordered,
+ int ppid)
+ throws IOException {
+ int pos = bb.position();
+ int lim = bb.limit();
+ assert (pos <= lim);
+ int rem = (pos <= lim ? lim - pos : 0);
+
+ int written = send0(fd, ((DirectBuffer)bb).address() + pos,
+ rem, target, assocId, streamNumber, unordered, ppid);
+ if (written > 0)
+ bb.position(pos + written);
+ return written;
+ }
+
+ @Override
+ public SctpMultiChannel shutdown(Association association)
+ throws IOException {
+ synchronized (stateLock) {
+ checkAssociation(association);
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ SctpNet.shutdown(fdVal, association.associationID());
+ }
+ return this;
+ }
+
+ @Override
+ public Set<SocketAddress> getAllLocalAddresses()
+ throws IOException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ return Collections.emptySet();
+
+ return SctpNet.getLocalAddresses(fdVal);
+ }
+ }
+
+ @Override
+ public Set<SocketAddress> getRemoteAddresses(Association association)
+ throws IOException {
+ synchronized (stateLock) {
+ checkAssociation(association);
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ try {
+ return SctpNet.getRemoteAddresses(fdVal, association.associationID());
+ } catch (SocketException se) {
+ /* a valid association should always have remote addresses */
+ Set<SocketAddress> addrs = associationMap.get(association);
+ return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
+ }
+ }
+ }
+
+ @Override
+ public SctpChannel branch(Association association)
+ throws IOException {
+ synchronized (stateLock) {
+ checkAssociation(association);
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ FileDescriptor bFd = SctpNet.branch(fdVal,
+ association.associationID());
+ /* successfully branched, we can now remove it from assoc list */
+ removeAssociation(association);
+
+ return new SctpChannelImpl(provider(), bFd, association);
+ }
+ }
+
+ /* Use common native implementation shared between
+ * one-to-one and one-to-many */
+ private static int receive0(int fd,
+ ResultContainer resultContainer,
+ long address,
+ int length)
+ throws IOException{
+ return SctpChannelImpl.receive0(fd, resultContainer, address,
+ length, false /*peek */);
+ }
+
+ private static int send0(int fd,
+ long address,
+ int length,
+ SocketAddress target,
+ int assocId,
+ int streamNumber,
+ boolean unordered,
+ int ppid)
+ throws IOException {
+ return SctpChannelImpl.send0(fd, address, length, target, assocId,
+ streamNumber, unordered, ppid);
+ }
+
+ static {
+ Util.load(); /* loads nio & net native libraries */
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.LoadLibraryAction("sctp"));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2009, 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 sun.nio.ch.sctp;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.channels.AlreadyBoundException;
+import java.util.Set;
+import java.util.HashSet;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.Net;
+import com.sun.nio.sctp.SctpSocketOption;
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+
+public class SctpNet {
+ static final String osName = AccessController.doPrivileged(
+ new GetPropertyAction("os.name"));
+
+ /* -- Miscellaneous SCTP utilities -- */
+
+ private static boolean IPv4MappedAddresses() {
+ if ("SunOS".equals(osName)) {
+ /* Solaris supports IPv4Mapped Addresses with bindx */
+ return true;
+ } /* else { //other OS/implementations */
+
+ /* lksctp/linux requires Ipv4 addresses */
+ return false;
+ }
+
+ static boolean throwAlreadyBoundException() throws IOException {
+ throw new AlreadyBoundException();
+ }
+
+ static void listen(int fd, int backlog) throws IOException {
+ listen0(fd, backlog);
+ }
+
+ static int connect(int fd, InetAddress remote, int remotePort)
+ throws IOException {
+ return connect0(fd, remote, remotePort);
+ }
+
+ static void close(int fd) throws IOException {
+ close0(fd);
+ }
+
+ static void preClose(int fd) throws IOException {
+ preClose0(fd);
+ }
+
+ /**
+ * @param oneToOne
+ * if {@code true} returns a one-to-one sctp socket, otherwise
+ * returns a one-to-many sctp socket
+ */
+ static FileDescriptor socket(boolean oneToOne) throws IOException {
+ int nativefd = socket0(oneToOne);
+ return IOUtil.newFD(nativefd);
+ }
+
+ static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
+ throws IOException {
+ bindx(fd, addrs, port, addrs.length, add,
+ IPv4MappedAddresses());
+ }
+
+ static Set<SocketAddress> getLocalAddresses(int fd)
+ throws IOException {
+ HashSet<SocketAddress> set = null;
+ SocketAddress[] saa = getLocalAddresses0(fd);
+
+ if (saa != null) {
+ set = new HashSet<SocketAddress>(saa.length);
+ for (SocketAddress sa : saa)
+ set.add(sa);
+ }
+
+ return set;
+ }
+
+ static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
+ throws IOException {
+ HashSet<SocketAddress> set = null;
+ SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
+
+ if (saa != null) {
+ set = new HashSet<SocketAddress>(saa.length);
+ for (SocketAddress sa : saa)
+ set.add(sa);
+ }
+
+ return set;
+ }
+
+ static <T> void setSocketOption(int fd,
+ SctpSocketOption<T> name,
+ T value,
+ int assocId)
+ throws IOException {
+ if (value == null)
+ throw new IllegalArgumentException("Invalid option value");
+
+ if (name.equals(SCTP_INIT_MAXSTREAMS)) {
+ InitMaxStreams maxStreamValue = (InitMaxStreams)value;
+ SctpNet.setInitMsgOption0(fd,
+ maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
+ } else if (name.equals(SCTP_PRIMARY_ADDR) ||
+ name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
+
+ SocketAddress addr = (SocketAddress) value;
+ if (addr == null)
+ throw new IllegalArgumentException("Invalid option value");
+
+ Net.checkAddress(addr);
+ InetSocketAddress netAddr = (InetSocketAddress)addr;
+
+ if (name.equals(SCTP_PRIMARY_ADDR)) {
+ setPrimAddrOption0(fd,
+ assocId,
+ netAddr.getAddress(),
+ netAddr.getPort());
+ } else {
+ setPeerPrimAddrOption0(fd,
+ assocId,
+ netAddr.getAddress(),
+ netAddr.getPort(),
+ IPv4MappedAddresses());
+ }
+ } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
+ name.equals(SCTP_EXPLICIT_COMPLETE) ||
+ name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
+ name.equals(SCTP_NODELAY) ||
+ name.equals(SO_SNDBUF) ||
+ name.equals(SO_RCVBUF) ||
+ name.equals(SO_LINGER)) {
+ setIntOption(fd, name, value);
+ } else {
+ throw new AssertionError("Unknown socket option");
+ }
+ }
+
+ static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
+ throws IOException {
+ if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
+ throw new IllegalArgumentException(
+ "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
+ } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
+ /* container for holding maxIn/Out streams */
+ int[] values = new int[2];
+ SctpNet.getInitMsgOption0(fd, values);
+ return InitMaxStreams.create(values[0], values[1]);
+ } else if (name.equals(SCTP_PRIMARY_ADDR)) {
+ return getPrimAddrOption0(fd, assocId);
+ } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
+ name.equals(SCTP_EXPLICIT_COMPLETE) ||
+ name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
+ name.equals(SCTP_NODELAY) ||
+ name.equals(SO_SNDBUF) ||
+ name.equals(SO_RCVBUF) ||
+ name.equals(SO_LINGER)) {
+ return getIntOption(fd, name);
+ } else {
+ throw new AssertionError("Unknown socket option");
+ }
+ }
+
+ static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
+ throws IOException {
+ if (value == null)
+ throw new IllegalArgumentException("Invalid option value");
+
+ Class<?> type = name.type();
+ if (type != Integer.class && type != Boolean.class)
+ throw new AssertionError("Should not reach here");
+
+ if (name == SO_RCVBUF ||
+ name == SO_SNDBUF)
+ {
+ int i = ((Integer)value).intValue();
+ if (i < 0)
+ throw new IllegalArgumentException(
+ "Invalid send/receive buffer size");
+ } else if (name == SO_LINGER) {
+ int i = ((Integer)value).intValue();
+ if (i < 0)
+ value = Integer.valueOf(-1);
+ if (i > 65535)
+ value = Integer.valueOf(65535);
+ } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
+ int i = ((Integer)value).intValue();
+ if (i < 0 || i > 2)
+ throw new IllegalArgumentException(
+ "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
+ }
+
+ int arg;
+ if (type == Integer.class) {
+ arg = ((Integer)value).intValue();
+ } else {
+ boolean b = ((Boolean)value).booleanValue();
+ arg = (b) ? 1 : 0;
+ }
+
+ setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
+ }
+
+ static Object getIntOption(int fd, SctpSocketOption<?> name)
+ throws IOException {
+ Class<?> type = name.type();
+
+ if (type != Integer.class && type != Boolean.class)
+ throw new AssertionError("Should not reach here");
+
+ if (!(name instanceof SctpStdSocketOption))
+ throw new AssertionError("Should not reach here");
+
+ int value = getIntOption0(fd,
+ ((SctpStdSocketOption)name).constValue());
+
+ if (type == Integer.class) {
+ return Integer.valueOf(value);
+ } else {
+ return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
+ }
+ }
+
+ static void shutdown(int fd, int assocId)
+ throws IOException {
+ shutdown0(fd, assocId);
+ }
+
+ static FileDescriptor branch(int fd, int assocId) throws IOException {
+ int nativefd = branch0(fd, assocId);
+ return IOUtil.newFD(nativefd);
+ }
+
+ /* Native Methods */
+ static native int socket0(boolean oneToOne) throws IOException;
+
+ static native void listen0(int fd, int backlog) throws IOException;
+
+ static native int connect0(int fd, InetAddress remote, int remotePort)
+ throws IOException;
+
+ static native void close0(int fd) throws IOException;
+
+ static native void preClose0(int fd) throws IOException;
+
+ static native void bindx(int fd, InetAddress[] addrs, int port, int length,
+ boolean add, boolean preferIPv6) throws IOException;
+
+ static native int getIntOption0(int fd, int opt) throws IOException;
+
+ static native void setIntOption0(int fd, int opt, int arg)
+ throws IOException;
+
+ static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
+
+ static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
+ throws IOException;
+
+ static native int branch0(int fd, int assocId) throws IOException;
+
+ static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
+ int port) throws IOException;
+
+ static native void setPeerPrimAddrOption0(int fd, int assocId,
+ InetAddress ia, int port, boolean preferIPv6) throws IOException;
+
+ static native SocketAddress getPrimAddrOption0(int fd, int assocId)
+ throws IOException;
+
+ /* retVals [0] maxInStreams, [1] maxOutStreams */
+ static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
+
+ static native void setInitMsgOption0(int fd, int arg1, int arg2)
+ throws IOException;
+
+ static native void shutdown0(int fd, int assocId);
+
+ static native void init();
+
+ static {
+ init();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNotification.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.Notification;
+
+/**
+ * All Notification implemenations MUST implement this interface to provide
+ * access to the native association identidier.
+ */
+interface SctpNotification extends Notification {
+ int assocId();
+ void setAssociation(Association association);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2009, 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 sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetSocketAddress;
+import java.net.InetAddress;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.IllegalUnbindException;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpServerChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+import com.sun.nio.sctp.SctpStandardSocketOptions;
+import sun.nio.ch.DirectBuffer;
+import sun.nio.ch.NativeThread;
+import sun.nio.ch.IOStatus;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.Net;
+import sun.nio.ch.PollArrayWrapper;
+import sun.nio.ch.SelChImpl;
+import sun.nio.ch.SelectionKeyImpl;
+import sun.nio.ch.Util;
+
+/**
+ * An implementation of SctpServerChannel
+ */
+public class SctpServerChannelImpl extends SctpServerChannel
+ implements SelChImpl
+{
+ private final FileDescriptor fd;
+
+ private final int fdVal;
+
+ /* IDs of native thread doing accept, for signalling */
+ private volatile long thread = 0;
+
+ /* Lock held by thread currently blocked in this channel */
+ private final Object lock = new Object();
+
+ /* Lock held by any thread that modifies the state fields declared below
+ * DO NOT invoke a blocking I/O operation while holding this lock! */
+ private final Object stateLock = new Object();
+
+ private enum ChannelState {
+ UNINITIALIZED,
+ INUSE,
+ KILLPENDING,
+ KILLED,
+ }
+ /* -- The following fields are protected by stateLock -- */
+ private ChannelState state = ChannelState.UNINITIALIZED;
+
+ /* Binding: Once bound the port will remain constant. */
+ int port = -1;
+ private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
+ /* Has the channel been bound to the wildcard address */
+ private boolean wildcard; /* false */
+
+ /* -- End of fields protected by stateLock -- */
+
+ /**
+ * Initializes a new instance of this class.
+ */
+ public SctpServerChannelImpl(SelectorProvider provider)
+ throws IOException {
+ //TODO: update provider remove public modifier
+ super(provider);
+ this.fd = SctpNet.socket(true);
+ this.fdVal = IOUtil.fdVal(fd);
+ this.state = ChannelState.INUSE;
+ }
+
+ @Override
+ public SctpServerChannel bind(SocketAddress local, int backlog)
+ throws IOException {
+ synchronized (lock) {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (isBound())
+ SctpNet.throwAlreadyBoundException();
+
+ InetSocketAddress isa = (local == null) ?
+ new InetSocketAddress(0) : Net.checkAddress(local);
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkListen(isa.getPort());
+ Net.bind(fd, isa.getAddress(), isa.getPort());
+
+ InetSocketAddress boundIsa = Net.localAddress(fd);
+ port = boundIsa.getPort();
+ localAddresses.add(isa);
+ if (isa.getAddress().isAnyLocalAddress())
+ wildcard = true;
+
+ SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
+ }
+ }
+ return this;
+ }
+
+ @Override
+ public SctpServerChannel bindAddress(InetAddress address)
+ throws IOException {
+ return bindUnbindAddress(address, true);
+ }
+
+ @Override
+ public SctpServerChannel unbindAddress(InetAddress address)
+ throws IOException {
+ return bindUnbindAddress(address, false);
+ }
+
+ private SctpServerChannel bindUnbindAddress(InetAddress address, boolean add)
+ throws IOException {
+ if (address == null)
+ throw new IllegalArgumentException();
+
+ synchronized (lock) {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ throw new NotYetBoundException();
+ if (wildcard)
+ throw new IllegalStateException(
+ "Cannot add or remove addresses from a channel that is bound to the wildcard address");
+ if (address.isAnyLocalAddress())
+ throw new IllegalArgumentException(
+ "Cannot add or remove the wildcard address");
+ if (add) {
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ SctpNet.throwAlreadyBoundException();
+ }
+ }
+ } else { /*removing */
+ /* Verify that there is more than one address
+ * and that address is already bound */
+ if (localAddresses.size() <= 1)
+ throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
+ boolean foundAddress = false;
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ foundAddress = true;
+ break;
+ }
+ }
+ if (!foundAddress )
+ throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
+ }
+
+ SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
+
+ /* Update our internal Set to reflect the addition/removal */
+ if (add)
+ localAddresses.add(new InetSocketAddress(address, port));
+ else {
+ for (InetSocketAddress addr : localAddresses) {
+ if (addr.getAddress().equals(address)) {
+ localAddresses.remove(addr);
+ break;
+ }
+ }
+ }
+ }
+ }
+ return this;
+ }
+
+ private boolean isBound() {
+ synchronized (stateLock) {
+ return port == -1 ? false : true;
+ }
+ }
+
+ private void acceptCleanup() throws IOException {
+ synchronized (stateLock) {
+ thread = 0;
+ if (state == ChannelState.KILLPENDING)
+ kill();
+ }
+ }
+
+ @Override
+ public SctpChannel accept() throws IOException {
+ synchronized (lock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ throw new NotYetBoundException();
+ SctpChannel sc = null;
+
+ int n = 0;
+ FileDescriptor newfd = new FileDescriptor();
+ InetSocketAddress[] isaa = new InetSocketAddress[1];
+
+ try {
+ begin();
+ if (!isOpen())
+ return null;
+ thread = NativeThread.current();
+ for (;;) {
+ n = accept0(fd, newfd, isaa);
+ if ((n == IOStatus.INTERRUPTED) && isOpen())
+ continue;
+ break;
+ }
+ } finally {
+ acceptCleanup();
+ end(n > 0);
+ assert IOStatus.check(n);
+ }
+
+ if (n < 1)
+ return null;
+
+ IOUtil.configureBlocking(newfd, true);
+ InetSocketAddress isa = isaa[0];
+ sc = new SctpChannelImpl(provider(), newfd);
+
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkAccept(isa.getAddress().getHostAddress(),
+ isa.getPort());
+
+ return sc;
+ }
+ }
+
+ @Override
+ protected void implConfigureBlocking(boolean block) throws IOException {
+ IOUtil.configureBlocking(fd, block);
+ }
+
+ @Override
+ public void implCloseSelectableChannel() throws IOException {
+ synchronized (stateLock) {
+ SctpNet.preClose(fdVal);
+ if (thread != 0)
+ NativeThread.signal(thread);
+ if (!isRegistered())
+ kill();
+ }
+ }
+
+ @Override
+ public void kill() throws IOException {
+ synchronized (stateLock) {
+ if (state == ChannelState.KILLED)
+ return;
+ if (state == ChannelState.UNINITIALIZED) {
+ state = ChannelState.KILLED;
+ return;
+ }
+ assert !isOpen() && !isRegistered();
+
+ // Postpone the kill if there is a thread in accept
+ if (thread == 0) {
+ SctpNet.close(fdVal);
+ state = ChannelState.KILLED;
+ } else {
+ state = ChannelState.KILLPENDING;
+ }
+ }
+ }
+
+ @Override
+ public FileDescriptor getFD() {
+ return fd;
+ }
+
+ @Override
+ public int getFDVal() {
+ return fdVal;
+ }
+
+ /**
+ * Translates native poll revent ops into a ready operation ops
+ */
+ private boolean translateReadyOps(int ops, int initialOps,
+ SelectionKeyImpl sk) {
+ int intOps = sk.nioInterestOps();
+ int oldOps = sk.nioReadyOps();
+ int newOps = initialOps;
+
+ if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+ /* This should only happen if this channel is pre-closed while a
+ * selection operation is in progress
+ * ## Throw an error if this channel has not been pre-closed */
+ return false;
+ }
+
+ if ((ops & (PollArrayWrapper.POLLERR
+ | PollArrayWrapper.POLLHUP)) != 0) {
+ newOps = intOps;
+ sk.nioReadyOps(newOps);
+ return (newOps & ~oldOps) != 0;
+ }
+
+ if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+ ((intOps & SelectionKey.OP_ACCEPT) != 0))
+ newOps |= SelectionKey.OP_ACCEPT;
+
+ sk.nioReadyOps(newOps);
+ return (newOps & ~oldOps) != 0;
+ }
+
+ @Override
+ public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
+ return translateReadyOps(ops, sk.nioReadyOps(), sk);
+ }
+
+ @Override
+ public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
+ return translateReadyOps(ops, 0, sk);
+ }
+
+ @Override
+ public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
+ int newOps = 0;
+
+ /* Translate ops */
+ if ((ops & SelectionKey.OP_ACCEPT) != 0)
+ newOps |= PollArrayWrapper.POLLIN;
+ /* Place ops into pollfd array */
+ sk.selector.putEventOps(sk, newOps);
+
+ }
+
+ @Override
+ public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value)
+ throws IOException {
+ if (name == null)
+ throw new NullPointerException();
+ if (!supportedOptions().contains(name))
+ throw new UnsupportedOperationException("'" + name + "' not supported");
+
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
+ return this;
+ }
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getOption(SctpSocketOption<T> name) throws IOException {
+ if (name == null)
+ throw new NullPointerException();
+ if (!supportedOptions().contains(name))
+ throw new UnsupportedOperationException("'" + name + "' not supported");
+
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+
+ return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
+ }
+ }
+
+ private static class DefaultOptionsHolder {
+ static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
+
+ private static Set<SctpSocketOption<?>> defaultOptions() {
+ HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
+ set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
+ return Collections.unmodifiableSet(set);
+ }
+ }
+
+ @Override
+ public final Set<SctpSocketOption<?>> supportedOptions() {
+ return DefaultOptionsHolder.defaultOptions;
+ }
+
+ @Override
+ public Set<SocketAddress> getAllLocalAddresses()
+ throws IOException {
+ synchronized (stateLock) {
+ if (!isOpen())
+ throw new ClosedChannelException();
+ if (!isBound())
+ return Collections.emptySet();
+
+ return SctpNet.getLocalAddresses(fdVal);
+ }
+ }
+
+ /* Native */
+ private static native void initIDs();
+
+ private static native int accept0(FileDescriptor ssfd,
+ FileDescriptor newfd, InetSocketAddress[] isaa) throws IOException;
+
+ static {
+ Util.load(); // loads nio & net native libraries
+ java.security.AccessController.doPrivileged(
+ new sun.security.action.LoadLibraryAction("sctp"));
+ initIDs();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SendFailed.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import java.nio.ByteBuffer;
+import java.net.SocketAddress;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.SendFailedNotification;
+
+/**
+ * An implementation of SendFailedNotification
+ */
+public class SendFailed extends SendFailedNotification
+ implements SctpNotification
+{
+ private Association association;
+ /* assocId is used to lookup the association before the notification is
+ * returned to user code */
+ private int assocId;
+ private SocketAddress address;
+ private ByteBuffer buffer;
+ private int errorCode;
+ private int streamNumber;
+
+ /* Invoked from native */
+ private SendFailed(int assocId,
+ SocketAddress address,
+ ByteBuffer buffer,
+ int errorCode,
+ int streamNumber) {
+ this.assocId = assocId;
+ this.errorCode = errorCode;
+ this.streamNumber = streamNumber;
+ this.address = address;
+ this.buffer = buffer;
+ }
+
+ @Override
+ public int assocId() {
+ return assocId;
+ }
+
+ @Override
+ public void setAssociation(Association association) {
+ this.association = association;
+ }
+
+ @Override
+ public Association association() {
+ /* may be null */
+ return association;
+ }
+
+ @Override
+ public SocketAddress address() {
+ assert address != null;
+ return address;
+ }
+
+ @Override
+ public ByteBuffer buffer() {
+ assert buffer != null;
+ return buffer;
+ }
+
+ @Override
+ public int errorCode() {
+ return errorCode;
+ }
+
+ @Override
+ public int streamNumber() {
+ return streamNumber;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString()).append(" [");
+ sb.append("Association:").append(association);
+ sb.append(", Address: ").append(address);
+ sb.append(", buffer: ").append(buffer);
+ sb.append(", errorCode: ").append(errorCode);
+ sb.append(", streamNumber: ").append(streamNumber);
+ sb.append("]");
+ return sb.toString();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/Shutdown.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.ShutdownNotification;
+
+/**
+ * An implementation of ShutdownNotification
+ */
+public class Shutdown extends ShutdownNotification
+ implements SctpNotification
+{
+ private Association association;
+ /* assocId is used to lookup the association before the notification is
+ * returned to user code */
+ private int assocId;
+
+ /* Invoked from native */
+ private Shutdown(int assocId) {
+ this.assocId = assocId;
+ }
+
+ @Override
+ public int assocId() {
+ return assocId;
+ }
+
+ @Override
+ public void setAssociation(Association association) {
+ this.association = association;
+ }
+
+ @Override
+ public Association association() {
+ assert association != null;
+ return association;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString()).append(" [");
+ sb.append("Association:").append(association).append("]");
+ return sb.toString();
+ }
+}
--- a/jdk/src/solaris/doc/sun/man/man1/apt.1 Thu Mar 01 15:31:33 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
-
--- a/jdk/src/solaris/doc/sun/man/man1/ja/apt.1 Thu Mar 01 15:31:33 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
-
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c Fri Mar 02 09:13:13 2012 -0800
@@ -171,6 +171,53 @@
return array;
}
+/**
+ * Convert a GSList to an array of filenames (with the parent folder)
+ */
+static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
+{
+ jstring str;
+ jclass stringCls;
+ GSList *iterator;
+ jobjectArray array;
+ int i;
+ char* entry;
+
+
+ if (list == NULL) {
+ return NULL;
+ }
+
+ stringCls = (*env)->FindClass(env, "java/lang/String");
+ if (stringCls == NULL) {
+ JNU_ThrowInternalError(env, "Could not get java.lang.String class");
+ return NULL;
+ }
+
+ array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
+ NULL);
+ if (array == NULL) {
+ JNU_ThrowInternalError(env, "Could not instantiate array files array");
+ return NULL;
+ }
+
+ i = 0;
+ for (iterator = list; iterator; iterator = iterator->next) {
+ entry = (char*) iterator->data;
+
+ //check for leading slash.
+ if (entry[0] == '/') {
+ entry++;
+ }
+
+ str = (*env)->NewStringUTF(env, entry);
+ (*env)->SetObjectArrayElement(env, array, i, str);
+ i++;
+ }
+
+ return array;
+}
+
static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
{
JNIEnv *env;
@@ -183,16 +230,25 @@
env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
current_folder = NULL;
filenames = NULL;
+ gboolean full_path_names = FALSE;
if (responseId == GTK_RESPONSE_ACCEPT) {
current_folder = fp_gtk_file_chooser_get_current_folder(
GTK_FILE_CHOOSER(aDialog));
+ if (current_folder == NULL) {
+ full_path_names = TRUE;
+ }
filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
}
-
- jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
- jfilenames = toFilenamesArray(env, filenames);
-
+ if (full_path_names) {
+ //This is a hack for use with "Recent Folders" in gtk where each
+ //file could have its own directory.
+ jcurrent_folder = (*env)->NewStringUTF(env, "/");
+ jfilenames = toPathAndFilenamesArray(env, filenames);
+ } else {
+ jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
+ jfilenames = toFilenamesArray(env, filenames);
+ }
(*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
jfilenames);
fp_g_free(current_folder);
--- a/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/native/sun/nio/ch/FileDispatcherImpl.c Fri Mar 02 09:13:13 2012 -0800
@@ -191,7 +191,7 @@
}
lockResult = fcntl(fd, cmd, &fl);
if (lockResult < 0) {
- if ((cmd == F_SETLK64) && (errno == EAGAIN))
+ if ((cmd == F_SETLK64) && (errno == EAGAIN || errno == EACCES))
return sun_nio_ch_FileDispatcherImpl_NO_LOCK;
if (errno == EINTR)
return sun_nio_ch_FileDispatcherImpl_INTERRUPTED;
--- a/jdk/src/solaris/native/sun/nio/ch/Sctp.h Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-#ifndef SUN_NIO_CH_SCTP_H
-#define SUN_NIO_CH_SCTP_H
-
-#ifdef __solaris__
-
-#define _XPG4_2
-#define __EXTENSIONS__
-#include <sys/socket.h>
-#include <netinet/sctp.h>
-#include "jni.h"
-
-/* Current Solaris headers don't comply with draft rfc */
-#ifndef SCTP_EOF
-#define SCTP_EOF MSG_EOF
-#endif
-
-#ifndef SCTP_UNORDERED
-#define SCTP_UNORDERED MSG_UNORDERED
-#endif
-
-/* The current version of the socket API extension shipped with Solaris does
- * not define the following options that the Java API (optionally) supports */
-#ifndef SCTP_EXPLICIT_EOR
-#define SCTP_EXPLICIT_EOR -1
-#endif
-#ifndef SCTP_FRAGMENT_INTERLEAVE
-#define SCTP_FRAGMENT_INTERLEAVE -1
-#endif
-#ifndef SCTP_SET_PEER_PRIMARY_ADDR
-#define SCTP_SET_PEER_PRIMARY_ADDR -1
-#endif
-
-/* Function types to support dynamic linking of socket API extension functions
- * for SCTP. This is so that there is no linkage depandancy during build or
- * runtime for libsctp.*/
-typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
-typedef int sctp_freeladdrs_func(void* addrs);
-typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
-typedef int sctp_freepaddrs_func(void *addrs);
-typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
-typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
-
-
-
-#else /* __linux__ */
-#include <stdint.h>
-#include <linux/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "jni.h"
-
-//Causes compiler error if not found, should make warning and uncomment
-/*#include <netinet/sctp.h>*/
-
-#ifndef IPPROTO_SCTP
-#define IPPROTO_SCTP 132
-#endif
-
-/* The current version of lksctp does
- * not define the following option that the Java API (optionally) supports */
-#ifndef SCTP_EXPLICIT_EOR
-#define SCTP_EXPLICIT_EOR -1
-#endif
-
-/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
-#ifndef SCTP_INITMSG
-
-enum sctp_optname {
- SCTP_RTOINFO,
-#define SCTP_RTOINFO SCTP_RTOINFO
- SCTP_ASSOCINFO,
-#define SCTP_ASSOCINFO SCTP_ASSOCINFO
- SCTP_INITMSG,
-#define SCTP_INITMSG SCTP_INITMSG
- SCTP_NODELAY, /* Get/set nodelay option. */
-#define SCTP_NODELAY SCTP_NODELAY
- SCTP_AUTOCLOSE,
-#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
- SCTP_SET_PEER_PRIMARY_ADDR,
-#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
- SCTP_PRIMARY_ADDR,
-#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
- SCTP_ADAPTATION_LAYER,
-#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER
- SCTP_DISABLE_FRAGMENTS,
-#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
- SCTP_PEER_ADDR_PARAMS,
-#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
- SCTP_DEFAULT_SEND_PARAM,
-#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
- SCTP_EVENTS,
-#define SCTP_EVENTS SCTP_EVENTS
- SCTP_I_WANT_MAPPED_V4_ADDR, /* Turn on/off mapped v4 addresses */
-#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
- SCTP_MAXSEG, /* Get/set maximum fragment. */
-#define SCTP_MAXSEG SCTP_MAXSEG
- SCTP_STATUS,
-#define SCTP_STATUS SCTP_STATUS
- SCTP_GET_PEER_ADDR_INFO,
-#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
- SCTP_DELAYED_ACK_TIME,
-#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
- SCTP_CONTEXT, /* Receive Context */
-#define SCTP_CONTEXT SCTP_CONTEXT
- SCTP_FRAGMENT_INTERLEAVE,
-#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE
- SCTP_PARTIAL_DELIVERY_POINT, /* Set/Get partial delivery point */
-#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
- SCTP_MAX_BURST, /* Set/Get max burst */
-#define SCTP_MAX_BURST SCTP_MAX_BURST
-};
-
-enum sctp_sac_state {
- SCTP_COMM_UP,
- SCTP_COMM_LOST,
- SCTP_RESTART,
- SCTP_SHUTDOWN_COMP,
- SCTP_CANT_STR_ASSOC,
-};
-
-enum sctp_spc_state {
- SCTP_ADDR_AVAILABLE,
- SCTP_ADDR_UNREACHABLE,
- SCTP_ADDR_REMOVED,
- SCTP_ADDR_ADDED,
- SCTP_ADDR_MADE_PRIM,
- SCTP_ADDR_CONFIRMED,
-};
-
-enum sctp_sinfo_flags {
- SCTP_UNORDERED = 1, /* Send/receive message unordered. */
- SCTP_ADDR_OVER = 2, /* Override the primary destination. */
- SCTP_ABORT=4, /* Send an ABORT message to the peer. */
- SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
-};
-
-enum sctp_sn_type {
- SCTP_SN_TYPE_BASE = (1<<15),
- SCTP_ASSOC_CHANGE,
- SCTP_PEER_ADDR_CHANGE,
- SCTP_SEND_FAILED,
- SCTP_REMOTE_ERROR,
- SCTP_SHUTDOWN_EVENT,
- SCTP_PARTIAL_DELIVERY_EVENT,
- SCTP_ADAPTATION_INDICATION,
-};
-
-typedef enum sctp_cmsg_type {
- SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
-#define SCTP_INIT SCTP_INIT
- SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
-#define SCTP_SNDRCV SCTP_SNDRCV
-} sctp_cmsg_t;
-
-enum sctp_msg_flags {
- MSG_NOTIFICATION = 0x8000,
-#define MSG_NOTIFICATION MSG_NOTIFICATION
-};
-
-#define SCTP_BINDX_ADD_ADDR 0x01
-#define SCTP_BINDX_REM_ADDR 0x02
-
-typedef __s32 sctp_assoc_t;
-
-struct sctp_initmsg {
- __u16 sinit_num_ostreams;
- __u16 sinit_max_instreams;
- __u16 sinit_max_attempts;
- __u16 sinit_max_init_timeo;
-};
-
-struct sctp_sndrcvinfo {
- __u16 sinfo_stream;
- __u16 sinfo_ssn;
- __u16 sinfo_flags;
- __u32 sinfo_ppid;
- __u32 sinfo_context;
- __u32 sinfo_timetolive;
- __u32 sinfo_tsn;
- __u32 sinfo_cumtsn;
- sctp_assoc_t sinfo_assoc_id;
-};
-
-struct sctp_event_subscribe {
- __u8 sctp_data_io_event;
- __u8 sctp_association_event;
- __u8 sctp_address_event;
- __u8 sctp_send_failure_event;
- __u8 sctp_peer_error_event;
- __u8 sctp_shutdown_event;
- __u8 sctp_partial_delivery_event;
- __u8 sctp_adaptation_layer_event;
-};
-
-struct sctp_send_failed {
- __u16 ssf_type;
- __u16 ssf_flags;
- __u32 ssf_length;
- __u32 ssf_error;
- struct sctp_sndrcvinfo ssf_info;
- sctp_assoc_t ssf_assoc_id;
- __u8 ssf_data[0];
-};
-
-struct sctp_assoc_change {
- __u16 sac_type;
- __u16 sac_flags;
- __u32 sac_length;
- __u16 sac_state;
- __u16 sac_error;
- __u16 sac_outbound_streams;
- __u16 sac_inbound_streams;
- sctp_assoc_t sac_assoc_id;
- __u8 sac_info[0];
-};
-
-struct sctp_shutdown_event {
- __u16 sse_type;
- __u16 sse_flags;
- __u32 sse_length;
- sctp_assoc_t sse_assoc_id;
-};
-
-struct sctp_paddr_change {
- __u16 spc_type;
- __u16 spc_flags;
- __u32 spc_length;
- struct sockaddr_storage spc_aaddr;
- int spc_state;
- int spc_error;
- sctp_assoc_t spc_assoc_id;
-} __attribute__((packed, aligned(4)));
-
-struct sctp_remote_error {
- __u16 sre_type;
- __u16 sre_flags;
- __u32 sre_length;
- __u16 sre_error;
- sctp_assoc_t sre_assoc_id;
- __u8 sre_data[0];
-};
-
-struct sctp_adaptation_event {
- __u16 sai_type;
- __u16 sai_flags;
- __u32 sai_length;
- __u32 sai_adaptation_ind;
- sctp_assoc_t sai_assoc_id;
-};
-
-struct sctp_setprim {
- sctp_assoc_t ssp_assoc_id;
- struct sockaddr_storage ssp_addr;
-} __attribute__((packed, aligned(4)));
-
-struct sctp_setpeerprim {
- sctp_assoc_t sspp_assoc_id;
- struct sockaddr_storage sspp_addr;
-} __attribute__((packed, aligned(4)));
-
-
-struct sctp_pdapi_event {
- __u16 pdapi_type;
- __u16 pdapi_flags;
- __u32 pdapi_length;
- __u32 pdapi_indication;
- sctp_assoc_t pdapi_assoc_id;
-};
-
-union sctp_notification {
- struct {
- __u16 sn_type; /* Notification type. */
- __u16 sn_flags;
- __u32 sn_length;
- } sn_header;
- struct sctp_assoc_change sn_assoc_change;
- struct sctp_paddr_change sn_paddr_change;
- struct sctp_remote_error sn_remote_error;
- struct sctp_send_failed sn_send_failed;
- struct sctp_shutdown_event sn_shutdown_event;
- struct sctp_adaptation_event sn_adaptation_event;
- struct sctp_pdapi_event sn_pdapi_event;
-};
-
-#endif /* SCTP_INITMSG */
-
-/* Function types to support dynamic linking of socket API extension functions
- * for SCTP. This is so that there is no linkage depandancy during build or
- * runtime for libsctp.*/
-typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
-typedef int sctp_freeladdrs_func(struct sockaddr *addrs);
-typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
-typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
-typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
-typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
-
-
-#endif /* __linux__ */
-
-sctp_getladdrs_func* nio_sctp_getladdrs;
-sctp_freeladdrs_func* nio_sctp_freeladdrs;
-sctp_getpaddrs_func* nio_sctp_getpaddrs;
-sctp_freepaddrs_func* nio_sctp_freepaddrs;
-sctp_bindx_func* nio_sctp_bindx;
-sctp_peeloff_func* nio_sctp_peeloff;
-
-jboolean loadSocketExtensionFuncs(JNIEnv* env);
-
-#endif /* !SUN_NIO_CH_SCTP_H */
--- a/jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,594 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include "Sctp.h"
-
-#include "jni.h"
-#include "nio_util.h"
-#include "nio.h"
-#include "net_util.h"
-#include "net_util_md.h"
-#include "sun_nio_ch_SctpNet.h"
-#include "sun_nio_ch_SctpChannelImpl.h"
-#include "sun_nio_ch_SctpAssocChange.h"
-#include "sun_nio_ch_SctpResultContainer.h"
-#include "sun_nio_ch_SctpPeerAddrChange.h"
-
-/* sizeof(union sctp_notification */
-#define NOTIFICATION_BUFFER_SIZE 280
-
-#define MESSAGE_IMPL_CLASS "sun/nio/ch/SctpMessageInfoImpl"
-#define RESULT_CONTAINER_CLASS "sun/nio/ch/SctpResultContainer"
-#define SEND_FAILED_CLASS "sun/nio/ch/SctpSendFailed"
-#define ASSOC_CHANGE_CLASS "sun/nio/ch/SctpAssocChange"
-#define PEER_CHANGE_CLASS "sun/nio/ch/SctpPeerAddrChange"
-#define SHUTDOWN_CLASS "sun/nio/ch/SctpShutdown"
-
-struct controlData {
- int assocId;
- unsigned short streamNumber;
- jboolean unordered;
- unsigned int ppid;
-};
-
-static jclass smi_class; /* sun.nio.ch.SctpMessageInfoImpl */
-static jmethodID smi_ctrID; /* sun.nio.ch.SctpMessageInfoImpl.<init> */
-static jfieldID src_valueID; /* sun.nio.ch.SctpResultContainer.value */
-static jfieldID src_typeID; /* sun.nio.ch.SctpResultContainer.type */
-static jclass ssf_class; /* sun.nio.ch.SctpSendFailed */
-static jmethodID ssf_ctrID; /* sun.nio.ch.SctpSendFailed.<init> */
-static jclass sac_class; /* sun.nio.ch.SctpAssociationChanged */
-static jmethodID sac_ctrID; /* sun.nio.ch.SctpAssociationChanged.<init> */
-static jclass spc_class; /* sun.nio.ch.SctpPeerAddressChanged */
-static jmethodID spc_ctrID; /* sun.nio.ch.SctpPeerAddressChanged.<init> */
-static jclass ss_class; /* sun.nio.ch.SctpShutdown */
-static jmethodID ss_ctrID; /* sun.nio.ch.SctpShutdown.<init> */
-static jfieldID isa_addrID; /* java.net.InetSocketAddress.addr */
-static jfieldID isa_portID; /* java.net.InetSocketAddress.port */
-
-/* defined in SctpNet.c */
-jobject SockAddrToInetSocketAddress(JNIEnv* env, struct sockaddr* addr);
-
-/* use SocketChannelImpl's checkConnect implementation */
-extern jint Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv* env,
- jobject this, jobject fdo, jboolean block, jboolean ready);
-
-/*
- * Class: sun_nio_ch_SctpChannelImpl
- * Method: initIDs
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpChannelImpl_initIDs
- (JNIEnv *env, jclass klass) {
- jclass cls;
-
- /* SctpMessageInfoImpl */
- cls = (*env)->FindClass(env, MESSAGE_IMPL_CLASS);
- CHECK_NULL(cls);
- smi_class = (*env)->NewGlobalRef(env, cls);
- CHECK_NULL(smi_class);
- smi_ctrID = (*env)->GetMethodID(env, cls, "<init>",
- "(ILjava/net/SocketAddress;IIZZI)V");
- CHECK_NULL(smi_ctrID);
-
- /* SctpResultContainer */
- cls = (*env)->FindClass(env, RESULT_CONTAINER_CLASS);
- CHECK_NULL(cls);
- src_valueID = (*env)->GetFieldID(env, cls, "value", "Ljava/lang/Object;");
- CHECK_NULL(src_valueID);
- src_typeID = (*env)->GetFieldID(env, cls, "type", "I");
- CHECK_NULL(src_typeID);
-
- /* SctpSendFailed */
- cls = (*env)->FindClass(env, SEND_FAILED_CLASS);
- CHECK_NULL(cls);
- ssf_class = (*env)->NewGlobalRef(env, cls);
- CHECK_NULL(ssf_class);
- ssf_ctrID = (*env)->GetMethodID(env, cls, "<init>",
- "(ILjava/net/SocketAddress;Ljava/nio/ByteBuffer;II)V");
- CHECK_NULL(ssf_ctrID);
-
- /* SctpAssocChange */
- cls = (*env)->FindClass(env, ASSOC_CHANGE_CLASS);
- CHECK_NULL(cls);
- sac_class = (*env)->NewGlobalRef(env, cls);
- CHECK_NULL(sac_class);
- sac_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(IIII)V");
- CHECK_NULL(sac_ctrID);
-
- /* SctpPeerAddrChange */
- cls = (*env)->FindClass(env, PEER_CHANGE_CLASS);
- CHECK_NULL(cls);
- spc_class = (*env)->NewGlobalRef(env, cls);
- CHECK_NULL(spc_class);
- spc_ctrID = (*env)->GetMethodID(env, cls, "<init>",
- "(ILjava/net/SocketAddress;I)V");
- CHECK_NULL(spc_ctrID);
-
- /* sun.nio.ch.SctpShutdown */
- cls = (*env)->FindClass(env, SHUTDOWN_CLASS);
- CHECK_NULL(cls);
- ss_class = (*env)->NewGlobalRef(env, cls);
- CHECK_NULL(ss_class);
- ss_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
- CHECK_NULL(ss_ctrID);
-
- /* InetSocketAddress */
- cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
- CHECK_NULL(cls);
- isa_addrID = (*env)->GetFieldID(env, cls, "addr", "Ljava/net/InetAddress;");
- CHECK_NULL(isa_addrID);
- isa_portID = (*env)->GetFieldID(env, cls, "port", "I");
-}
-
-void getControlData
- (struct msghdr* msg, struct controlData* cdata) {
- struct cmsghdr* cmsg;
-
- for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
- if (cmsg->cmsg_level == IPPROTO_SCTP && cmsg->cmsg_type == SCTP_SNDRCV) {
- struct sctp_sndrcvinfo *sri;
-
- sri = (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg);
- cdata->assocId = sri->sinfo_assoc_id;
- cdata->streamNumber = sri->sinfo_stream;
- cdata->unordered = (sri->sinfo_flags & SCTP_UNORDERED) ? JNI_TRUE :
- JNI_FALSE;
- cdata->ppid = ntohl(sri->sinfo_ppid);
-
- return;
- }
- }
- return;
-}
-
-void setControlData
- (struct msghdr* msg, struct controlData* cdata) {
- struct cmsghdr* cmsg;
- struct sctp_sndrcvinfo *sri;
-
- cmsg = CMSG_FIRSTHDR(msg);
- cmsg->cmsg_level = IPPROTO_SCTP;
- cmsg->cmsg_type = SCTP_SNDRCV;
- cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
-
- /* Initialize the payload */
- sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
- memset(sri, 0, sizeof (*sri));
-
- if (cdata->streamNumber > 0) {
- sri->sinfo_stream = cdata->streamNumber;
- }
- if (cdata->assocId > 0) {
- sri->sinfo_assoc_id = cdata->assocId;
- }
- if (cdata->unordered == JNI_TRUE) {
- sri->sinfo_flags = sri->sinfo_flags | SCTP_UNORDERED;
- }
-
- if (cdata->ppid > 0) {
- sri->sinfo_ppid = htonl(cdata->ppid);
- }
-
- /* Sum of the length of all control messages in the buffer. */
- msg->msg_controllen = cmsg->cmsg_len;
-}
-
-// TODO: test: can create send failed without any data? if so need to
-// update API so that buffer can be null if no data.
-void handleSendFailed
- (JNIEnv* env, int fd, jobject resultContainerObj, struct sctp_send_failed *ssf,
- int read, jboolean isEOR, struct sockaddr* sap) {
- jobject bufferObj = NULL, resultObj, isaObj;
- char *addressP;
- struct sctp_sndrcvinfo *sri;
- int remaining, dataLength;
-
- /* the actual undelivered message data is directly after the ssf */
- int dataOffset = sizeof(struct sctp_send_failed);
-
- sri = (struct sctp_sndrcvinfo*) &ssf->ssf_info;
-
- /* the number of bytes remaining to be read in the sctp_send_failed notif*/
- remaining = ssf->ssf_length - read;
-
- /* the size of the actual undelivered message */
- dataLength = ssf->ssf_length - dataOffset;
-
- /* retrieved address from sockaddr */
- isaObj = SockAddrToInetSocketAddress(env, sap);
-
- /* data retrieved from sff_data */
- if (dataLength > 0) {
- struct iovec iov[1];
- struct msghdr msg[1];
- int rv, alreadyRead;
- char *dataP = (char*) ssf;
- dataP += dataOffset;
-
- if ((addressP = malloc(dataLength)) == NULL) {
- JNU_ThrowOutOfMemoryError(env, "handleSendFailed");
- return;
- }
-
- memset(msg, 0, sizeof (*msg));
- msg->msg_iov = iov;
- msg->msg_iovlen = 1;
-
- bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
- CHECK_NULL(bufferObj);
-
- alreadyRead = read - dataOffset;
- if (alreadyRead > 0) {
- memcpy(addressP, /*ssf->ssf_data*/ dataP, alreadyRead);
- iov->iov_base = addressP + alreadyRead;
- iov->iov_len = dataLength - alreadyRead;
- } else {
- iov->iov_base = addressP;
- iov->iov_len = dataLength;
- }
-
- if (remaining > 0) {
- if ((rv = recvmsg(fd, msg, 0)) < 0) {
- handleSocketError(env, errno);
- return;
- }
-
- if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
- //TODO: assert false: "should not reach here";
- return;
- }
- // TODO: Set and document (in API) buffers position.
- }
- }
-
- /* create SctpSendFailed */
- resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
- isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
- CHECK_NULL(resultObj);
- (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
- (*env)->SetIntField(env, resultContainerObj, src_typeID,
- sun_nio_ch_SctpResultContainer_SEND_FAILED);
-}
-
-void handleAssocChange
- (JNIEnv* env, jobject resultContainerObj, struct sctp_assoc_change *sac) {
- jobject resultObj;
- int state = 0;
-
- switch (sac->sac_state) {
- case SCTP_COMM_UP :
- state = sun_nio_ch_SctpAssocChange_SCTP_COMM_UP;
- break;
- case SCTP_COMM_LOST :
- state = sun_nio_ch_SctpAssocChange_SCTP_COMM_LOST;
- break;
- case SCTP_RESTART :
- state = sun_nio_ch_SctpAssocChange_SCTP_RESTART;
- break;
- case SCTP_SHUTDOWN_COMP :
- state = sun_nio_ch_SctpAssocChange_SCTP_SHUTDOWN;
- break;
- case SCTP_CANT_STR_ASSOC :
- state = sun_nio_ch_SctpAssocChange_SCTP_CANT_START;
- }
-
- /* create SctpAssociationChanged */
- resultObj = (*env)->NewObject(env, sac_class, sac_ctrID, sac->sac_assoc_id,
- state, sac->sac_outbound_streams, sac->sac_inbound_streams);
- CHECK_NULL(resultObj);
- (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
- (*env)->SetIntField(env, resultContainerObj, src_typeID,
- sun_nio_ch_SctpResultContainer_ASSOCIATION_CHANGED);
-}
-
-void handleShutdown
- (JNIEnv* env, jobject resultContainerObj, struct sctp_shutdown_event* sse) {
- /* create SctpShutdown */
- jobject resultObj = (*env)->NewObject(env, ss_class, ss_ctrID, sse->sse_assoc_id);
- CHECK_NULL(resultObj);
- (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
- (*env)->SetIntField(env, resultContainerObj, src_typeID,
- sun_nio_ch_SctpResultContainer_SHUTDOWN);
-}
-
-void handlePeerAddrChange
- (JNIEnv* env, jobject resultContainerObj, struct sctp_paddr_change* spc) {
- int event = 0;
- jobject addressObj, resultObj;
- unsigned int state = spc->spc_state;
-
- switch (state) {
- case SCTP_ADDR_AVAILABLE :
- event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_AVAILABLE;
- break;
- case SCTP_ADDR_UNREACHABLE :
- event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_UNREACHABLE;
- break;
- case SCTP_ADDR_REMOVED :
- event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_REMOVED;
- break;
- case SCTP_ADDR_ADDED :
- event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_ADDED;
- break;
- case SCTP_ADDR_MADE_PRIM :
- event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_MADE_PRIM;
-#ifdef __linux__ /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
- break;
- case SCTP_ADDR_CONFIRMED :
- event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_CONFIRMED;
-#endif /* __linux__ */
- }
-
- addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
-
- /* create SctpPeerAddressChanged */
- resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id,
- addressObj, event);
- CHECK_NULL(resultObj);
- (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
- (*env)->SetIntField(env, resultContainerObj, src_typeID,
- sun_nio_ch_SctpResultContainer_PEER_ADDRESS_CHANGED);
-}
-
-void handleUninteresting
- (union sctp_notification *snp) {
- //fprintf(stdout,"\nNative: handleUninterestingNotification: Receive notification type [%u]", snp->sn_header.sn_type);
-}
-
-/**
- * Handle notifications from the SCTP stack.
- * Returns JNI_TRUE if the notification is one that is of interest to the
- * Java API, otherwise JNI_FALSE.
- */
-jboolean handleNotification
- (JNIEnv* env, int fd, jobject resultContainerObj, union sctp_notification* snp,
- int read, jboolean isEOR, struct sockaddr* sap) {
- switch (snp->sn_header.sn_type) {
- case SCTP_SEND_FAILED:
- handleSendFailed(env, fd, resultContainerObj, &snp->sn_send_failed,
- read, isEOR, sap);
- return JNI_TRUE;
- case SCTP_ASSOC_CHANGE:
- handleAssocChange(env, resultContainerObj, &snp->sn_assoc_change);
- return JNI_TRUE;
- case SCTP_SHUTDOWN_EVENT:
- handleShutdown(env, resultContainerObj, &snp->sn_shutdown_event);
- return JNI_TRUE;
- case SCTP_PEER_ADDR_CHANGE:
- handlePeerAddrChange(env, resultContainerObj, &snp->sn_paddr_change);
- return JNI_TRUE;
- default :
- /* the Java API is not interested in this event, maybe we are? */
- handleUninteresting(snp);
- }
- return JNI_FALSE;
-}
-
-void handleMessage
- (JNIEnv* env, jobject resultContainerObj, struct msghdr* msg,int read,
- jboolean isEOR, struct sockaddr* sap) {
- jobject isa, resultObj;
- struct controlData cdata[1];
-
- if (read == 0) {
- /* we reached EOF */
- read = -1;
- }
-
- isa = SockAddrToInetSocketAddress(env, sap);
- getControlData(msg, cdata);
-
- /* create SctpMessageInfoImpl */
- resultObj = (*env)->NewObject(env, smi_class, smi_ctrID, cdata->assocId,
- isa, read, cdata->streamNumber,
- isEOR ? JNI_TRUE : JNI_FALSE,
- cdata->unordered, cdata->ppid);
- CHECK_NULL(resultObj);
- (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
- (*env)->SetIntField(env, resultContainerObj, src_typeID,
- sun_nio_ch_SctpResultContainer_MESSAGE);
-}
-
-/*
- * Class: sun_nio_ch_SctpChannelImpl
- * Method: receive0
- * Signature: (ILsun/nio/ch/SctpResultContainer;JIZ)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0
- (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
- jlong address, jint length, jboolean peek) {
- SOCKADDR sa;
- int sa_len = sizeof(sa);
- ssize_t rv = 0;
- jlong *addr = jlong_to_ptr(address);
- struct iovec iov[1];
- struct msghdr msg[1];
- char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
- int flags = peek == JNI_TRUE ? MSG_PEEK : 0;
-
- /* Set up the msghdr structure for receiving */
- memset(msg, 0, sizeof (*msg));
- msg->msg_name = &sa;
- msg->msg_namelen = sa_len;
- iov->iov_base = addr;
- iov->iov_len = length;
- msg->msg_iov = iov;
- msg->msg_iovlen = 1;
- msg->msg_control = cbuf;
- msg->msg_controllen = sizeof(cbuf);
- msg->msg_flags = 0;
-
- do {
- if ((rv = recvmsg(fd, msg, flags)) < 0) {
- if (errno == EWOULDBLOCK) {
- return IOS_UNAVAILABLE;
- } else if (errno == EINTR) {
- return IOS_INTERRUPTED;
-
-#ifdef __linux__
- } else if (errno == ENOTCONN) {
- /* ENOTCONN when EOF reached */
- rv = 0;
- /* there will be no control data */
- msg->msg_controllen = 0;
-#endif /* __linux__ */
-
- } else {
- handleSocketError(env, errno);
- return 0;
- }
- }
-
- if (msg->msg_flags & MSG_NOTIFICATION) {
- char *bufp = (char*)addr;
- union sctp_notification *snp;
-
- if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
- char buf[NOTIFICATION_BUFFER_SIZE];
- int rvSAVE = rv;
- memcpy(buf, addr, rv);
- iov->iov_base = buf + rv;
- iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
- if ((rv = recvmsg(fd, msg, flags)) < 0) {
- handleSocketError(env, errno);
- return 0;
- }
- bufp = buf;
- rv += rvSAVE;
- }
- snp = (union sctp_notification *) bufp;
- if (handleNotification(env, fd, resultContainerObj, snp, rv,
- (msg->msg_flags & MSG_EOR),
- (struct sockaddr*)&sa ) == JNI_TRUE) {
- /* We have received a notification that is of interest to
- to the Java API. The appropriate notification will be
- set in the result container. */
- return 0;
- }
-
- // set iov back to addr, and reset msg_controllen
- iov->iov_base = addr;
- iov->iov_len = length;
- msg->msg_control = cbuf;
- msg->msg_controllen = sizeof(cbuf);
- }
- } while (msg->msg_flags & MSG_NOTIFICATION);
-
- handleMessage(env, resultContainerObj, msg, rv,
- (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
- return rv;
-}
-
-/*
- * Class: sun_nio_ch_SctpChannelImpl
- * Method: send0
- * Signature: (IJILjava/net/SocketAddress;IIZI)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_send0
- (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
- jobject saTarget, jint assocId, jint streamNumber, jboolean unordered,
- jint ppid) {
- SOCKADDR sa;
- int sa_len = sizeof(sa);
- ssize_t rv = 0;
- jlong *addr = jlong_to_ptr(address);
- struct iovec iov[1];
- struct msghdr msg[1];
- int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
- char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
- struct controlData cdata[1];
-
- /* SctpChannel:
- * saTarget may contain the preferred address or NULL to use primary,
- * assocId will always be -1
- * SctpMultiChannell:
- * Setup new association, saTarget will contain address, assocId = -1
- * Association already existing, assocId != -1, saTarget = preferred addr
- */
- if (saTarget != NULL /*&& assocId <= 0*/) {
-
- jobject targetAddress = (*env)->GetObjectField(env, saTarget, isa_addrID);
- jint targetPort = (*env)->GetIntField(env, saTarget, isa_portID);
-
- if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
- (struct sockaddr *)&sa,
- &sa_len, JNI_TRUE) != 0) {
- return IOS_THROWN;
- }
- } else {
- memset(&sa, '\x0', sa_len);
- sa_len = 0;
- }
-
- /* Set up the msghdr structure for sending */
- memset(msg, 0, sizeof (*msg));
- memset(cbuf, 0, cbuf_size);
- msg->msg_name = &sa;
- msg->msg_namelen = sa_len;
- iov->iov_base = addr;
- iov->iov_len = length;
- msg->msg_iov = iov;
- msg->msg_iovlen = 1;
- msg->msg_control = cbuf;
- msg->msg_controllen = cbuf_size;
- msg->msg_flags = 0;
-
- cdata->streamNumber = streamNumber;
- cdata->assocId = assocId;
- cdata->unordered = unordered;
- cdata->ppid = ppid;
- setControlData(msg, cdata);
-
- if ((rv = sendmsg(fd, msg, 0)) < 0) {
- if (errno == EWOULDBLOCK) {
- return IOS_UNAVAILABLE;
- } else if (errno == EINTR) {
- return IOS_INTERRUPTED;
- } else if (errno == EPIPE) {
- JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
- "Socket is shutdown for writing");
- } else {
- handleSocketError(env, errno);
- return 0;
- }
- }
-
- return rv;
-}
-
-/*
- * Class: sun_nio_ch_SctpChannelImpl
- * Method: checkConnect
- * Signature: (Ljava/io/FileDescriptor;ZZ)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_checkConnect
- (JNIEnv* env, jobject this, jobject fdo, jboolean block, jboolean ready) {
- return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this,
- fdo, block, ready);
-}
-
--- a/jdk/src/solaris/native/sun/nio/ch/SctpNet.c Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,753 +0,0 @@
-/*
- * Copyright (c) 2009, 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.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <dlfcn.h>
-
-#include "Sctp.h"
-#include "jni.h"
-#include "jni_util.h"
-#include "nio_util.h"
-#include "nio.h"
-#include "net_util.h"
-#include "net_util_md.h"
-#include "sun_nio_ch_SctpNet.h"
-#include "sun_nio_ch_SctpStdSocketOption.h"
-
-static jclass isaCls = 0;
-static jmethodID isaCtrID = 0;
-
-static const char* nativeSctpLib = "libsctp.so.1";
-static jboolean funcsLoaded = JNI_FALSE;
-
-JNIEXPORT jint JNICALL JNI_OnLoad
- (JavaVM *vm, void *reserved) {
- return JNI_VERSION_1_2;
-}
-
-static int preCloseFD = -1; /* File descriptor to which we dup other fd's
- before closing them for real */
-
-/**
- * Loads the native sctp library that contains the socket extension
- * functions, as well as locating the individual functions.
- * There will be a pending exception if this method returns false.
- */
-jboolean loadSocketExtensionFuncs
- (JNIEnv* env) {
- if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- if ((nio_sctp_getladdrs = (sctp_getladdrs_func*)
- dlsym(RTLD_DEFAULT, "sctp_getladdrs")) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- if ((nio_sctp_freeladdrs = (sctp_freeladdrs_func*)
- dlsym(RTLD_DEFAULT, "sctp_freeladdrs")) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- if ((nio_sctp_getpaddrs = (sctp_getpaddrs_func*)
- dlsym(RTLD_DEFAULT, "sctp_getpaddrs")) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- if ((nio_sctp_freepaddrs = (sctp_freepaddrs_func*)
- dlsym(RTLD_DEFAULT, "sctp_freepaddrs")) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- if ((nio_sctp_bindx = (sctp_bindx_func*)
- dlsym(RTLD_DEFAULT, "sctp_bindx")) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- if ((nio_sctp_peeloff = (sctp_peeloff_func*)
- dlsym(RTLD_DEFAULT, "sctp_peeloff")) == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
- dlerror());
- return JNI_FALSE;
- }
-
- funcsLoaded = JNI_TRUE;
- return JNI_TRUE;
-}
-
-jint
-handleSocketError(JNIEnv *env, jint errorValue)
-{
- char *xn;
- switch (errorValue) {
- case EINPROGRESS: /* Non-blocking connect */
- return 0;
- case EPROTO:
- xn= JNU_JAVANETPKG "ProtocolException";
- break;
- case ECONNREFUSED:
- xn = JNU_JAVANETPKG "ConnectException";
- break;
- case ETIMEDOUT:
- xn = JNU_JAVANETPKG "ConnectException";
- break;
- case EHOSTUNREACH:
- xn = JNU_JAVANETPKG "NoRouteToHostException";
- break;
- case EADDRINUSE: /* Fall through */
- case EADDRNOTAVAIL:
- xn = JNU_JAVANETPKG "BindException";
- break;
- default:
- xn = JNU_JAVANETPKG "SocketException";
- break;
- }
- errno = errorValue;
- JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
- return IOS_THROWN;
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_init
- (JNIEnv *env, jclass cl) {
- int sp[2];
- if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
- JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
- return;
- }
- preCloseFD = sp[0];
- close(sp[1]);
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: socket0
- * Signature: (Z)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0
- (JNIEnv *env, jclass klass, jboolean oneToOne) {
- int fd;
- struct sctp_event_subscribe event;
-#ifdef AF_INET6
- int domain = ipv6_available() ? AF_INET6 : AF_INET;
-#else
- int domain = AF_INET;
-#endif
-
- /* Try to load the socket API extension functions */
- if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
- return 0;
- }
-
- fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
-
- if (fd < 0) {
- return handleSocketError(env, errno);
- }
-
- /* Enable events */
- memset(&event, 0, sizeof(event));
- event.sctp_data_io_event = 1;
- event.sctp_association_event = 1;
- event.sctp_address_event = 1;
- event.sctp_send_failure_event = 1;
- //event.sctp_peer_error_event = 1;
- event.sctp_shutdown_event = 1;
- //event.sctp_partial_delivery_event = 1;
- //event.sctp_adaptation_layer_event = 1;
- if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
- handleSocketError(env, errno);
- }
- return fd;
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: bindx
- * Signature: (I[Ljava/net/InetAddress;IIZ)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_bindx
- (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
- jint addrsLength, jboolean add, jboolean preferIPv6) {
- SOCKADDR *sap, *tmpSap;
- int i, sa_len = sizeof(SOCKADDR);
- jobject ia;
-
- if (addrsLength < 1)
- return;
-
- if ((sap = calloc(addrsLength, sa_len)) == NULL) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
- return;
- }
-
- tmpSap = sap;
- for (i=0; i<addrsLength; i++) {
- ia = (*env)->GetObjectArrayElement(env, addrs, i);
- if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
- &sa_len, preferIPv6) != 0) {
- free(sap);
- return;
- }
- tmpSap++;
- }
-
- if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
- SCTP_BINDX_REM_ADDR) != 0) {
- handleSocketError(env, errno);
- }
-
- free(sap);
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: listen0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_listen0
- (JNIEnv *env, jclass cl, jint fd, jint backlog) {
- if (listen(fd, backlog) < 0)
- handleSocketError(env, errno);
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: connect0
- * Signature: (ILjava/net/InetAddress;I)I
- */
-JNIEXPORT jint JNICALL
-Java_sun_nio_ch_SctpNet_connect0
- (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
- SOCKADDR sa;
- int sa_len = SOCKADDR_LEN;
- int rv;
-
- if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
- &sa_len, JNI_TRUE) != 0) {
- return IOS_THROWN;
- }
-
- rv = connect(fd, (struct sockaddr *)&sa, sa_len);
- if (rv != 0) {
- if (errno == EINPROGRESS) {
- return IOS_UNAVAILABLE;
- } else if (errno == EINTR) {
- return IOS_INTERRUPTED;
- }
- return handleSocketError(env, errno);
- }
- return 1;
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: close0
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_close0
- (JNIEnv *env, jclass clazz, jint fd) {
- if (fd != -1) {
- int rv = close(fd);
- if (rv < 0)
- JNU_ThrowIOExceptionWithLastError(env, "Close failed");
- }
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: preClose0
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_preClose0
- (JNIEnv *env, jclass clazz, jint fd) {
- if (preCloseFD >= 0) {
- if (dup2(preCloseFD, fd) < 0)
- JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
- }
-}
-
-void initializeISA
- (JNIEnv* env) {
- if (isaCls == 0) {
- jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
- CHECK_NULL(c);
- isaCls = (*env)->NewGlobalRef(env, c);
- CHECK_NULL(isaCls);
- (*env)->DeleteLocalRef(env, c);
- isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>",
- "(Ljava/net/InetAddress;I)V");
- }
-}
-
-jobject SockAddrToInetSocketAddress
- (JNIEnv *env, struct sockaddr* sap) {
- int port = 0;
-
- jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
- if (ia == NULL)
- return NULL;
-
- if (isaCls == 0) {
- initializeISA(env);
- CHECK_NULL_RETURN(isaCls, NULL);
- }
-
- return (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: getLocalAddresses0
- * Signature: (I)[Ljava/net/SocketAddress;
- */
-JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_SctpNet_getLocalAddresses0
- (JNIEnv *env, jclass klass, jint fd) {
- void *addr_buf, *laddr;
- struct sockaddr* sap;
- int i, addrCount;
- jobjectArray isaa;
-
-#ifdef __solaris__
- if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
-#else /* __linux__ */
- if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
-#endif
- handleSocketError(env, errno);
- return NULL;
- }
-
- if (addrCount < 1)
- return NULL;
-
- if (isaCls == 0) {
- initializeISA(env);
- CHECK_NULL_RETURN(isaCls, NULL);
- }
-
- isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
- if (isaa == NULL) {
- nio_sctp_freeladdrs(addr_buf);
- return NULL;
- }
-
- laddr = addr_buf;
- for (i=0; i<addrCount; i++) {
- int port = 0;
- jobject isa = NULL, ia;
- sap = (struct sockaddr*)addr_buf;
- ia = NET_SockaddrToInetAddress(env, sap, &port);
- if (ia != NULL)
- isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
- if (isa != NULL)
- (*env)->SetObjectArrayElement(env, isaa, i, isa);
-
- if (sap->sa_family == AF_INET)
- addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
- else
- addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
- }
-
- nio_sctp_freeladdrs(laddr);
- return isaa;
-}
-
-jobjectArray getRemoteAddresses
- (JNIEnv *env, jint fd, sctp_assoc_t id) {
- void *addr_buf, *paddr;
- struct sockaddr* sap;
- int i, addrCount;
- jobjectArray isaa;
-
-#if __solaris__
- if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
-#else /* __linux__ */
- if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
-#endif
- handleSocketError(env, errno);
- return NULL;
- }
-
- if (addrCount < 1)
- return NULL;
-
- if (isaCls == 0) {
- initializeISA(env);
- CHECK_NULL_RETURN(isaCls, NULL);
- }
-
- isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
- if (isaa == NULL) {
- nio_sctp_freepaddrs(addr_buf);
- return NULL;
- }
-
- paddr = addr_buf;
- for (i=0; i<addrCount; i++) {
- jobject ia, isa = NULL;
- int port;
- sap = (struct sockaddr*)addr_buf;
- ia = NET_SockaddrToInetAddress(env, sap, &port);
- if (ia != NULL)
- isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
- if (isa != NULL)
- (*env)->SetObjectArrayElement(env, isaa, i, isa);
-
- if (sap->sa_family == AF_INET)
- addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
- else
- addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
- }
-
- nio_sctp_freepaddrs(paddr);
-
- return isaa;
-}
-
- /*
- * Class: sun_nio_ch_SctpNet
- * Method: getRemoteAddresses0
- * Signature: (II)[Ljava/net/SocketAddress;
- */
-JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_SctpNet_getRemoteAddresses0
- (JNIEnv *env, jclass klass, jint fd, jint assocId) {
- return getRemoteAddresses(env, fd, assocId);
-}
-
-/* Map the Java level option to the native level */
-int mapSocketOption
- (jint cmd, int *level, int *optname) {
- static struct {
- jint cmd;
- int level;
- int optname;
- } const opts[] = {
- { sun_nio_ch_SctpStdSocketOption_SCTP_DISABLE_FRAGMENTS, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS },
- { sun_nio_ch_SctpStdSocketOption_SCTP_EXPLICIT_COMPLETE, IPPROTO_SCTP, SCTP_EXPLICIT_EOR },
- { sun_nio_ch_SctpStdSocketOption_SCTP_FRAGMENT_INTERLEAVE, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE },
- { sun_nio_ch_SctpStdSocketOption_SCTP_NODELAY, IPPROTO_SCTP, SCTP_NODELAY },
- { sun_nio_ch_SctpStdSocketOption_SO_SNDBUF, SOL_SOCKET, SO_SNDBUF },
- { sun_nio_ch_SctpStdSocketOption_SO_RCVBUF, SOL_SOCKET, SO_RCVBUF },
- { sun_nio_ch_SctpStdSocketOption_SO_LINGER, SOL_SOCKET, SO_LINGER } };
-
- int i;
- for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
- if (cmd == opts[i].cmd) {
- *level = opts[i].level;
- *optname = opts[i].optname;
- return 0;
- }
- }
-
- /* not found */
- return -1;
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: setIntOption0
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setIntOption0
- (JNIEnv *env, jclass klass, jint fd, jint opt, int arg) {
- int klevel, kopt;
- int result;
- struct linger linger;
- void *parg;
- int arglen;
-
- if (mapSocketOption(opt, &klevel, &kopt) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "Unsupported socket option");
- return;
- }
-
- if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER) {
- parg = (void *)&linger;
- arglen = sizeof(linger);
- if (arg >= 0) {
- linger.l_onoff = 1;
- linger.l_linger = arg;
- } else {
- linger.l_onoff = 0;
- linger.l_linger = 0;
- }
- } else {
- parg = (void *)&arg;
- arglen = sizeof(arg);
- }
-
- if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun_nio_ch_SctpNet.setIntOption0");
- }
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: getIntOption0
- * Signature: (II)I
- */
-JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_getIntOption0
- (JNIEnv *env, jclass klass, jint fd, jint opt) {
- int klevel, kopt;
- int result;
- struct linger linger;
- void *arg;
- int arglen;
-
- if (mapSocketOption(opt, &klevel, &kopt) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "Unsupported socket option");
- return -1;
- }
-
- if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER) {
- arg = (void *)&linger;
- arglen = sizeof(linger);
- } else {
- arg = (void *)&result;
- arglen = sizeof(result);
- }
-
- if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun.nio.ch.Net.getIntOption");
- return -1;
- }
-
- if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER)
- return linger.l_onoff ? linger.l_linger : -1;
- else
- return result;
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: getPrimAddrOption0
- * Signature: (II)Ljava/net/SocketAddress;
- */
-JNIEXPORT jobject JNICALL Java_sun_nio_ch_SctpNet_getPrimAddrOption0
- (JNIEnv *env, jclass klass, jint fd, jint assocId) {
- struct sctp_setprim prim;
- unsigned int prim_len = sizeof(prim);
- struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
-
- prim.ssp_assoc_id = assocId;
-
- if (getsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, &prim_len) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun.nio.ch.SctpNet.getPrimAddrOption0");
- return NULL;
- }
-
- return SockAddrToInetSocketAddress(env, sap);
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: setPrimAddrOption0
- * Signature: (IILjava/net/InetAddress;I)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setPrimAddrOption0
- (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
- struct sctp_setprim prim;
- struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
- int sap_len;
-
- if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
- &sap_len, JNI_TRUE) != 0) {
- return;
- }
-
- prim.ssp_assoc_id = assocId;
-
- if (setsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, sizeof(prim)) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun.nio.ch.SctpNet.setPrimAddrOption0");
- }
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: setPeerPrimAddrOption0
- * Signature: (IILjava/net/InetAddress;I)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setPeerPrimAddrOption0
- (JNIEnv *env, jclass klass, jint fd, jint assocId,
- jobject iaObj, jint port, jboolean preferIPv6) {
- struct sctp_setpeerprim prim;
- struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
- int sap_len;
-
- if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
- &sap_len, preferIPv6) != 0) {
- return;
- }
-
- prim.sspp_assoc_id = assocId;
-
- if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
- sizeof(prim)) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
- }
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: getInitMsgOption0
- * Signature: (I[I)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_getInitMsgOption0
- (JNIEnv *env, jclass klass, jint fd, jintArray retVal) {
- struct sctp_initmsg sctp_initmsg;
- unsigned int sim_len = sizeof(sctp_initmsg);
- int vals[2];
-
- if (getsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
- &sim_len) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun.nio.ch.SctpNet.getInitMsgOption0");
- return;
- }
-
- vals[0] = sctp_initmsg.sinit_max_instreams;
- vals[1] = sctp_initmsg.sinit_num_ostreams;
- (*env)->SetIntArrayRegion(env, retVal, 0, 2, vals);
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: setInitMsgOption0
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setInitMsgOption0
- (JNIEnv *env, jclass klass, jint fd, jint inArg, jint outArg) {
- struct sctp_initmsg sctp_initmsg;
-
- sctp_initmsg.sinit_max_instreams = (unsigned int)inArg;
- sctp_initmsg.sinit_num_ostreams = (unsigned int)outArg;
- sctp_initmsg.sinit_max_attempts = 0; // default
- sctp_initmsg.sinit_max_init_timeo = 0; // default
-
- if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
- sizeof(sctp_initmsg)) < 0) {
- JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
- "sun.nio.ch.SctpNet.setInitMsgOption0");
- }
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: shutdown0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_shutdown0
- (JNIEnv *env, jclass klass, jint fd, jint assocId) {
- int rv;
- struct msghdr msg[1];
- struct iovec iov[1];
- int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
- char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
- struct cmsghdr* cmsg;
- struct sctp_sndrcvinfo *sri;
-
- /* SctpSocketChannel */
- if (assocId < 0) {
- shutdown(fd, SHUT_WR);
- return;
- }
-
- memset(msg, 0, sizeof (*msg));
- memset(cbuf, 0, cbuf_size);
- msg->msg_name = NULL;
- msg->msg_namelen = 0;
- iov->iov_base = NULL;
- iov->iov_len = 0;
- msg->msg_iov = iov;
- msg->msg_iovlen = 1;
- msg->msg_control = cbuf;
- msg->msg_controllen = cbuf_size;
- msg->msg_flags = 0;
-
- cmsg = CMSG_FIRSTHDR(msg);
- cmsg->cmsg_level = IPPROTO_SCTP;
- cmsg->cmsg_type = SCTP_SNDRCV;
- cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
-
- /* Initialize the payload: */
- sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
- memset(sri, 0, sizeof (*sri));
-
- if (assocId > 0) {
- sri->sinfo_assoc_id = assocId;
- }
-
- sri->sinfo_flags = sri->sinfo_flags | SCTP_EOF;
-
- /* Sum of the length of all control messages in the buffer. */
- msg->msg_controllen = cmsg->cmsg_len;
-
- if ((rv = sendmsg(fd, msg, 0)) < 0) {
- handleSocketError(env, errno);
- }
-}
-
-/*
- * Class: sun_nio_ch_SctpNet
- * Method: branch
- * Signature: (II)I
- */
-JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_branch0
- (JNIEnv *env, jclass klass, jint fd, jint assocId) {
- int newfd = 0;
- if ((newfd = nio_sctp_peeloff(fd, assocId)) < 0) {
- handleSocketError(env, errno);
- }
-
- return newfd;
-}
--- a/jdk/src/solaris/native/sun/nio/ch/SctpServerChannelImpl.c Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 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.
- */
-
-#include "sun_nio_ch_SctpServerChannelImpl.h"
-
-extern void Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv* env,
- jclass c);
-
-extern jint Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv* env,
- jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa);
-
-/*
- * Class: sun_nio_ch_SctpServerChannelImpl
- * Method: initIDs
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpServerChannelImpl_initIDs
- (JNIEnv* env, jclass c) {
- Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(env, c);
-}
-
-/*
- * Class: sun_nio_ch_SctpServerChannelImpl
- * Method: accept0
- * Signature: (Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpServerChannelImpl_accept0
- (JNIEnv* env, jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa) {
- return Java_sun_nio_ch_ServerSocketChannelImpl_accept0(env, this,
- ssfdo, newfdo, isaa);
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/Sctp.h Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#ifndef SUN_NIO_CH_SCTP_H
+#define SUN_NIO_CH_SCTP_H
+
+#ifdef __solaris__
+
+#define _XPG4_2
+#define __EXTENSIONS__
+#include <sys/socket.h>
+#include <netinet/sctp.h>
+#include "jni.h"
+
+/* Current Solaris headers don't comply with draft rfc */
+#ifndef SCTP_EOF
+#define SCTP_EOF MSG_EOF
+#endif
+
+#ifndef SCTP_UNORDERED
+#define SCTP_UNORDERED MSG_UNORDERED
+#endif
+
+/* The current version of the socket API extension shipped with Solaris does
+ * not define the following options that the Java API (optionally) supports */
+#ifndef SCTP_EXPLICIT_EOR
+#define SCTP_EXPLICIT_EOR -1
+#endif
+#ifndef SCTP_FRAGMENT_INTERLEAVE
+#define SCTP_FRAGMENT_INTERLEAVE -1
+#endif
+#ifndef SCTP_SET_PEER_PRIMARY_ADDR
+#define SCTP_SET_PEER_PRIMARY_ADDR -1
+#endif
+
+/* Function types to support dynamic linking of socket API extension functions
+ * for SCTP. This is so that there is no linkage depandancy during build or
+ * runtime for libsctp.*/
+typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
+typedef int sctp_freeladdrs_func(void* addrs);
+typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
+typedef int sctp_freepaddrs_func(void *addrs);
+typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
+typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
+
+
+
+#else /* __linux__ */
+#include <stdint.h>
+#include <linux/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include "jni.h"
+
+//Causes compiler error if not found, should make warning and uncomment
+/*#include <netinet/sctp.h>*/
+
+#ifndef IPPROTO_SCTP
+#define IPPROTO_SCTP 132
+#endif
+
+/* The current version of lksctp does
+ * not define the following option that the Java API (optionally) supports */
+#ifndef SCTP_EXPLICIT_EOR
+#define SCTP_EXPLICIT_EOR -1
+#endif
+
+/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
+#ifndef SCTP_INITMSG
+
+enum sctp_optname {
+ SCTP_RTOINFO,
+#define SCTP_RTOINFO SCTP_RTOINFO
+ SCTP_ASSOCINFO,
+#define SCTP_ASSOCINFO SCTP_ASSOCINFO
+ SCTP_INITMSG,
+#define SCTP_INITMSG SCTP_INITMSG
+ SCTP_NODELAY, /* Get/set nodelay option. */
+#define SCTP_NODELAY SCTP_NODELAY
+ SCTP_AUTOCLOSE,
+#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
+ SCTP_SET_PEER_PRIMARY_ADDR,
+#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
+ SCTP_PRIMARY_ADDR,
+#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
+ SCTP_ADAPTATION_LAYER,
+#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER
+ SCTP_DISABLE_FRAGMENTS,
+#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
+ SCTP_PEER_ADDR_PARAMS,
+#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
+ SCTP_DEFAULT_SEND_PARAM,
+#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
+ SCTP_EVENTS,
+#define SCTP_EVENTS SCTP_EVENTS
+ SCTP_I_WANT_MAPPED_V4_ADDR, /* Turn on/off mapped v4 addresses */
+#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
+ SCTP_MAXSEG, /* Get/set maximum fragment. */
+#define SCTP_MAXSEG SCTP_MAXSEG
+ SCTP_STATUS,
+#define SCTP_STATUS SCTP_STATUS
+ SCTP_GET_PEER_ADDR_INFO,
+#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
+ SCTP_DELAYED_ACK_TIME,
+#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
+ SCTP_CONTEXT, /* Receive Context */
+#define SCTP_CONTEXT SCTP_CONTEXT
+ SCTP_FRAGMENT_INTERLEAVE,
+#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE
+ SCTP_PARTIAL_DELIVERY_POINT, /* Set/Get partial delivery point */
+#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
+ SCTP_MAX_BURST, /* Set/Get max burst */
+#define SCTP_MAX_BURST SCTP_MAX_BURST
+};
+
+enum sctp_sac_state {
+ SCTP_COMM_UP,
+ SCTP_COMM_LOST,
+ SCTP_RESTART,
+ SCTP_SHUTDOWN_COMP,
+ SCTP_CANT_STR_ASSOC,
+};
+
+enum sctp_spc_state {
+ SCTP_ADDR_AVAILABLE,
+ SCTP_ADDR_UNREACHABLE,
+ SCTP_ADDR_REMOVED,
+ SCTP_ADDR_ADDED,
+ SCTP_ADDR_MADE_PRIM,
+ SCTP_ADDR_CONFIRMED,
+};
+
+enum sctp_sinfo_flags {
+ SCTP_UNORDERED = 1, /* Send/receive message unordered. */
+ SCTP_ADDR_OVER = 2, /* Override the primary destination. */
+ SCTP_ABORT=4, /* Send an ABORT message to the peer. */
+ SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
+};
+
+enum sctp_sn_type {
+ SCTP_SN_TYPE_BASE = (1<<15),
+ SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_SEND_FAILED,
+ SCTP_REMOTE_ERROR,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_PARTIAL_DELIVERY_EVENT,
+ SCTP_ADAPTATION_INDICATION,
+};
+
+typedef enum sctp_cmsg_type {
+ SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
+#define SCTP_INIT SCTP_INIT
+ SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
+#define SCTP_SNDRCV SCTP_SNDRCV
+} sctp_cmsg_t;
+
+enum sctp_msg_flags {
+ MSG_NOTIFICATION = 0x8000,
+#define MSG_NOTIFICATION MSG_NOTIFICATION
+};
+
+#define SCTP_BINDX_ADD_ADDR 0x01
+#define SCTP_BINDX_REM_ADDR 0x02
+
+typedef __s32 sctp_assoc_t;
+
+struct sctp_initmsg {
+ __u16 sinit_num_ostreams;
+ __u16 sinit_max_instreams;
+ __u16 sinit_max_attempts;
+ __u16 sinit_max_init_timeo;
+};
+
+struct sctp_sndrcvinfo {
+ __u16 sinfo_stream;
+ __u16 sinfo_ssn;
+ __u16 sinfo_flags;
+ __u32 sinfo_ppid;
+ __u32 sinfo_context;
+ __u32 sinfo_timetolive;
+ __u32 sinfo_tsn;
+ __u32 sinfo_cumtsn;
+ sctp_assoc_t sinfo_assoc_id;
+};
+
+struct sctp_event_subscribe {
+ __u8 sctp_data_io_event;
+ __u8 sctp_association_event;
+ __u8 sctp_address_event;
+ __u8 sctp_send_failure_event;
+ __u8 sctp_peer_error_event;
+ __u8 sctp_shutdown_event;
+ __u8 sctp_partial_delivery_event;
+ __u8 sctp_adaptation_layer_event;
+};
+
+struct sctp_send_failed {
+ __u16 ssf_type;
+ __u16 ssf_flags;
+ __u32 ssf_length;
+ __u32 ssf_error;
+ struct sctp_sndrcvinfo ssf_info;
+ sctp_assoc_t ssf_assoc_id;
+ __u8 ssf_data[0];
+};
+
+struct sctp_assoc_change {
+ __u16 sac_type;
+ __u16 sac_flags;
+ __u32 sac_length;
+ __u16 sac_state;
+ __u16 sac_error;
+ __u16 sac_outbound_streams;
+ __u16 sac_inbound_streams;
+ sctp_assoc_t sac_assoc_id;
+ __u8 sac_info[0];
+};
+
+struct sctp_shutdown_event {
+ __u16 sse_type;
+ __u16 sse_flags;
+ __u32 sse_length;
+ sctp_assoc_t sse_assoc_id;
+};
+
+struct sctp_paddr_change {
+ __u16 spc_type;
+ __u16 spc_flags;
+ __u32 spc_length;
+ struct sockaddr_storage spc_aaddr;
+ int spc_state;
+ int spc_error;
+ sctp_assoc_t spc_assoc_id;
+} __attribute__((packed, aligned(4)));
+
+struct sctp_remote_error {
+ __u16 sre_type;
+ __u16 sre_flags;
+ __u32 sre_length;
+ __u16 sre_error;
+ sctp_assoc_t sre_assoc_id;
+ __u8 sre_data[0];
+};
+
+struct sctp_adaptation_event {
+ __u16 sai_type;
+ __u16 sai_flags;
+ __u32 sai_length;
+ __u32 sai_adaptation_ind;
+ sctp_assoc_t sai_assoc_id;
+};
+
+struct sctp_setprim {
+ sctp_assoc_t ssp_assoc_id;
+ struct sockaddr_storage ssp_addr;
+} __attribute__((packed, aligned(4)));
+
+struct sctp_setpeerprim {
+ sctp_assoc_t sspp_assoc_id;
+ struct sockaddr_storage sspp_addr;
+} __attribute__((packed, aligned(4)));
+
+
+struct sctp_pdapi_event {
+ __u16 pdapi_type;
+ __u16 pdapi_flags;
+ __u32 pdapi_length;
+ __u32 pdapi_indication;
+ sctp_assoc_t pdapi_assoc_id;
+};
+
+union sctp_notification {
+ struct {
+ __u16 sn_type; /* Notification type. */
+ __u16 sn_flags;
+ __u32 sn_length;
+ } sn_header;
+ struct sctp_assoc_change sn_assoc_change;
+ struct sctp_paddr_change sn_paddr_change;
+ struct sctp_remote_error sn_remote_error;
+ struct sctp_send_failed sn_send_failed;
+ struct sctp_shutdown_event sn_shutdown_event;
+ struct sctp_adaptation_event sn_adaptation_event;
+ struct sctp_pdapi_event sn_pdapi_event;
+};
+
+#endif /* SCTP_INITMSG */
+
+/* Function types to support dynamic linking of socket API extension functions
+ * for SCTP. This is so that there is no linkage depandancy during build or
+ * runtime for libsctp.*/
+typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
+typedef int sctp_freeladdrs_func(struct sockaddr *addrs);
+typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
+typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
+typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
+typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
+
+
+#endif /* __linux__ */
+
+sctp_getladdrs_func* nio_sctp_getladdrs;
+sctp_freeladdrs_func* nio_sctp_freeladdrs;
+sctp_getpaddrs_func* nio_sctp_getpaddrs;
+sctp_freepaddrs_func* nio_sctp_freepaddrs;
+sctp_bindx_func* nio_sctp_bindx;
+sctp_peeloff_func* nio_sctp_peeloff;
+
+jboolean loadSocketExtensionFuncs(JNIEnv* env);
+
+#endif /* !SUN_NIO_CH_SCTP_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,596 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "Sctp.h"
+
+#include "jni.h"
+#include "nio_util.h"
+#include "nio.h"
+#include "net_util.h"
+#include "net_util_md.h"
+#include "sun_nio_ch_sctp_SctpNet.h"
+#include "sun_nio_ch_sctp_SctpChannelImpl.h"
+#include "sun_nio_ch_sctp_AssociationChange.h"
+#include "sun_nio_ch_sctp_ResultContainer.h"
+#include "sun_nio_ch_sctp_PeerAddrChange.h"
+
+/* sizeof(union sctp_notification */
+#define NOTIFICATION_BUFFER_SIZE 280
+
+#define MESSAGE_IMPL_CLASS "sun/nio/ch/sctp/MessageInfoImpl"
+#define RESULT_CONTAINER_CLASS "sun/nio/ch/sctp/ResultContainer"
+#define SEND_FAILED_CLASS "sun/nio/ch/sctp/SendFailed"
+#define ASSOC_CHANGE_CLASS "sun/nio/ch/sctp/AssociationChange"
+#define PEER_CHANGE_CLASS "sun/nio/ch/sctp/PeerAddrChange"
+#define SHUTDOWN_CLASS "sun/nio/ch/sctp/Shutdown"
+
+struct controlData {
+ int assocId;
+ unsigned short streamNumber;
+ jboolean unordered;
+ unsigned int ppid;
+};
+
+static jclass smi_class; /* sun.nio.ch.sctp.MessageInfoImpl */
+static jmethodID smi_ctrID; /* sun.nio.ch.sctp.MessageInfoImpl.<init> */
+static jfieldID src_valueID; /* sun.nio.ch.sctp.ResultContainer.value */
+static jfieldID src_typeID; /* sun.nio.ch.sctp.ResultContainer.type */
+static jclass ssf_class; /* sun.nio.ch.sctp.SendFailed */
+static jmethodID ssf_ctrID; /* sun.nio.ch.sctp.SendFailed.<init> */
+static jclass sac_class; /* sun.nio.ch.sctp.AssociationChange */
+static jmethodID sac_ctrID; /* sun.nio.ch.sctp.AssociationChange.<init> */
+static jclass spc_class; /* sun.nio.ch.sctp.PeerAddressChanged */
+static jmethodID spc_ctrID; /* sun.nio.ch.sctp.PeerAddressChanged.<init> */
+static jclass ss_class; /* sun.nio.ch.sctp.Shutdown */
+static jmethodID ss_ctrID; /* sun.nio.ch.sctp.Shutdown.<init> */
+static jfieldID isa_addrID; /* java.net.InetSocketAddress.addr */
+static jfieldID isa_portID; /* java.net.InetSocketAddress.port */
+
+/* defined in SctpNet.c */
+jobject SockAddrToInetSocketAddress(JNIEnv* env, struct sockaddr* addr);
+
+jint handleSocketError(JNIEnv *env, jint errorValue);
+
+/* use SocketChannelImpl's checkConnect implementation */
+extern jint Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv* env,
+ jobject this, jobject fdo, jboolean block, jboolean ready);
+
+/*
+ * Class: sun_nio_ch_sctp_SctpChannelImpl
+ * Method: initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_initIDs
+ (JNIEnv *env, jclass klass) {
+ jclass cls;
+
+ /* MessageInfoImpl */
+ cls = (*env)->FindClass(env, MESSAGE_IMPL_CLASS);
+ CHECK_NULL(cls);
+ smi_class = (*env)->NewGlobalRef(env, cls);
+ CHECK_NULL(smi_class);
+ smi_ctrID = (*env)->GetMethodID(env, cls, "<init>",
+ "(ILjava/net/SocketAddress;IIZZI)V");
+ CHECK_NULL(smi_ctrID);
+
+ /* ResultContainer */
+ cls = (*env)->FindClass(env, RESULT_CONTAINER_CLASS);
+ CHECK_NULL(cls);
+ src_valueID = (*env)->GetFieldID(env, cls, "value", "Ljava/lang/Object;");
+ CHECK_NULL(src_valueID);
+ src_typeID = (*env)->GetFieldID(env, cls, "type", "I");
+ CHECK_NULL(src_typeID);
+
+ /* SendFailed */
+ cls = (*env)->FindClass(env, SEND_FAILED_CLASS);
+ CHECK_NULL(cls);
+ ssf_class = (*env)->NewGlobalRef(env, cls);
+ CHECK_NULL(ssf_class);
+ ssf_ctrID = (*env)->GetMethodID(env, cls, "<init>",
+ "(ILjava/net/SocketAddress;Ljava/nio/ByteBuffer;II)V");
+ CHECK_NULL(ssf_ctrID);
+
+ /* AssociationChange */
+ cls = (*env)->FindClass(env, ASSOC_CHANGE_CLASS);
+ CHECK_NULL(cls);
+ sac_class = (*env)->NewGlobalRef(env, cls);
+ CHECK_NULL(sac_class);
+ sac_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(IIII)V");
+ CHECK_NULL(sac_ctrID);
+
+ /* PeerAddrChange */
+ cls = (*env)->FindClass(env, PEER_CHANGE_CLASS);
+ CHECK_NULL(cls);
+ spc_class = (*env)->NewGlobalRef(env, cls);
+ CHECK_NULL(spc_class);
+ spc_ctrID = (*env)->GetMethodID(env, cls, "<init>",
+ "(ILjava/net/SocketAddress;I)V");
+ CHECK_NULL(spc_ctrID);
+
+ /* Shutdown */
+ cls = (*env)->FindClass(env, SHUTDOWN_CLASS);
+ CHECK_NULL(cls);
+ ss_class = (*env)->NewGlobalRef(env, cls);
+ CHECK_NULL(ss_class);
+ ss_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
+ CHECK_NULL(ss_ctrID);
+
+ /* InetSocketAddress */
+ cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
+ CHECK_NULL(cls);
+ isa_addrID = (*env)->GetFieldID(env, cls, "addr", "Ljava/net/InetAddress;");
+ CHECK_NULL(isa_addrID);
+ isa_portID = (*env)->GetFieldID(env, cls, "port", "I");
+}
+
+void getControlData
+ (struct msghdr* msg, struct controlData* cdata) {
+ struct cmsghdr* cmsg;
+
+ for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+ if (cmsg->cmsg_level == IPPROTO_SCTP && cmsg->cmsg_type == SCTP_SNDRCV) {
+ struct sctp_sndrcvinfo *sri;
+
+ sri = (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg);
+ cdata->assocId = sri->sinfo_assoc_id;
+ cdata->streamNumber = sri->sinfo_stream;
+ cdata->unordered = (sri->sinfo_flags & SCTP_UNORDERED) ? JNI_TRUE :
+ JNI_FALSE;
+ cdata->ppid = ntohl(sri->sinfo_ppid);
+
+ return;
+ }
+ }
+ return;
+}
+
+void setControlData
+ (struct msghdr* msg, struct controlData* cdata) {
+ struct cmsghdr* cmsg;
+ struct sctp_sndrcvinfo *sri;
+
+ cmsg = CMSG_FIRSTHDR(msg);
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_SNDRCV;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
+
+ /* Initialize the payload */
+ sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
+ memset(sri, 0, sizeof (*sri));
+
+ if (cdata->streamNumber > 0) {
+ sri->sinfo_stream = cdata->streamNumber;
+ }
+ if (cdata->assocId > 0) {
+ sri->sinfo_assoc_id = cdata->assocId;
+ }
+ if (cdata->unordered == JNI_TRUE) {
+ sri->sinfo_flags = sri->sinfo_flags | SCTP_UNORDERED;
+ }
+
+ if (cdata->ppid > 0) {
+ sri->sinfo_ppid = htonl(cdata->ppid);
+ }
+
+ /* Sum of the length of all control messages in the buffer. */
+ msg->msg_controllen = cmsg->cmsg_len;
+}
+
+// TODO: test: can create send failed without any data? if so need to
+// update API so that buffer can be null if no data.
+void handleSendFailed
+ (JNIEnv* env, int fd, jobject resultContainerObj, struct sctp_send_failed *ssf,
+ int read, jboolean isEOR, struct sockaddr* sap) {
+ jobject bufferObj = NULL, resultObj, isaObj;
+ char *addressP;
+ struct sctp_sndrcvinfo *sri;
+ int remaining, dataLength;
+
+ /* the actual undelivered message data is directly after the ssf */
+ int dataOffset = sizeof(struct sctp_send_failed);
+
+ sri = (struct sctp_sndrcvinfo*) &ssf->ssf_info;
+
+ /* the number of bytes remaining to be read in the sctp_send_failed notif*/
+ remaining = ssf->ssf_length - read;
+
+ /* the size of the actual undelivered message */
+ dataLength = ssf->ssf_length - dataOffset;
+
+ /* retrieved address from sockaddr */
+ isaObj = SockAddrToInetSocketAddress(env, sap);
+
+ /* data retrieved from sff_data */
+ if (dataLength > 0) {
+ struct iovec iov[1];
+ struct msghdr msg[1];
+ int rv, alreadyRead;
+ char *dataP = (char*) ssf;
+ dataP += dataOffset;
+
+ if ((addressP = malloc(dataLength)) == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "handleSendFailed");
+ return;
+ }
+
+ memset(msg, 0, sizeof (*msg));
+ msg->msg_iov = iov;
+ msg->msg_iovlen = 1;
+
+ bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
+ CHECK_NULL(bufferObj);
+
+ alreadyRead = read - dataOffset;
+ if (alreadyRead > 0) {
+ memcpy(addressP, /*ssf->ssf_data*/ dataP, alreadyRead);
+ iov->iov_base = addressP + alreadyRead;
+ iov->iov_len = dataLength - alreadyRead;
+ } else {
+ iov->iov_base = addressP;
+ iov->iov_len = dataLength;
+ }
+
+ if (remaining > 0) {
+ if ((rv = recvmsg(fd, msg, 0)) < 0) {
+ handleSocketError(env, errno);
+ return;
+ }
+
+ if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
+ //TODO: assert false: "should not reach here";
+ return;
+ }
+ // TODO: Set and document (in API) buffers position.
+ }
+ }
+
+ /* create SendFailed */
+ resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
+ isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
+ CHECK_NULL(resultObj);
+ (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+ (*env)->SetIntField(env, resultContainerObj, src_typeID,
+ sun_nio_ch_sctp_ResultContainer_SEND_FAILED);
+}
+
+void handleAssocChange
+ (JNIEnv* env, jobject resultContainerObj, struct sctp_assoc_change *sac) {
+ jobject resultObj;
+ int state = 0;
+
+ switch (sac->sac_state) {
+ case SCTP_COMM_UP :
+ state = sun_nio_ch_sctp_AssociationChange_SCTP_COMM_UP;
+ break;
+ case SCTP_COMM_LOST :
+ state = sun_nio_ch_sctp_AssociationChange_SCTP_COMM_LOST;
+ break;
+ case SCTP_RESTART :
+ state = sun_nio_ch_sctp_AssociationChange_SCTP_RESTART;
+ break;
+ case SCTP_SHUTDOWN_COMP :
+ state = sun_nio_ch_sctp_AssociationChange_SCTP_SHUTDOWN;
+ break;
+ case SCTP_CANT_STR_ASSOC :
+ state = sun_nio_ch_sctp_AssociationChange_SCTP_CANT_START;
+ }
+
+ /* create AssociationChange */
+ resultObj = (*env)->NewObject(env, sac_class, sac_ctrID, sac->sac_assoc_id,
+ state, sac->sac_outbound_streams, sac->sac_inbound_streams);
+ CHECK_NULL(resultObj);
+ (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+ (*env)->SetIntField(env, resultContainerObj, src_typeID,
+ sun_nio_ch_sctp_ResultContainer_ASSOCIATION_CHANGED);
+}
+
+void handleShutdown
+ (JNIEnv* env, jobject resultContainerObj, struct sctp_shutdown_event* sse) {
+ /* create Shutdown */
+ jobject resultObj = (*env)->NewObject(env, ss_class, ss_ctrID, sse->sse_assoc_id);
+ CHECK_NULL(resultObj);
+ (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+ (*env)->SetIntField(env, resultContainerObj, src_typeID,
+ sun_nio_ch_sctp_ResultContainer_SHUTDOWN);
+}
+
+void handlePeerAddrChange
+ (JNIEnv* env, jobject resultContainerObj, struct sctp_paddr_change* spc) {
+ int event = 0;
+ jobject addressObj, resultObj;
+ unsigned int state = spc->spc_state;
+
+ switch (state) {
+ case SCTP_ADDR_AVAILABLE :
+ event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_AVAILABLE;
+ break;
+ case SCTP_ADDR_UNREACHABLE :
+ event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_UNREACHABLE;
+ break;
+ case SCTP_ADDR_REMOVED :
+ event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_REMOVED;
+ break;
+ case SCTP_ADDR_ADDED :
+ event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_ADDED;
+ break;
+ case SCTP_ADDR_MADE_PRIM :
+ event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_MADE_PRIM;
+#ifdef __linux__ /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
+ break;
+ case SCTP_ADDR_CONFIRMED :
+ event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_CONFIRMED;
+#endif /* __linux__ */
+ }
+
+ addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
+
+ /* create PeerAddressChanged */
+ resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id,
+ addressObj, event);
+ CHECK_NULL(resultObj);
+ (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+ (*env)->SetIntField(env, resultContainerObj, src_typeID,
+ sun_nio_ch_sctp_ResultContainer_PEER_ADDRESS_CHANGED);
+}
+
+void handleUninteresting
+ (union sctp_notification *snp) {
+ //fprintf(stdout,"\nNative: handleUninterestingNotification: Receive notification type [%u]", snp->sn_header.sn_type);
+}
+
+/**
+ * Handle notifications from the SCTP stack.
+ * Returns JNI_TRUE if the notification is one that is of interest to the
+ * Java API, otherwise JNI_FALSE.
+ */
+jboolean handleNotification
+ (JNIEnv* env, int fd, jobject resultContainerObj, union sctp_notification* snp,
+ int read, jboolean isEOR, struct sockaddr* sap) {
+ switch (snp->sn_header.sn_type) {
+ case SCTP_SEND_FAILED:
+ handleSendFailed(env, fd, resultContainerObj, &snp->sn_send_failed,
+ read, isEOR, sap);
+ return JNI_TRUE;
+ case SCTP_ASSOC_CHANGE:
+ handleAssocChange(env, resultContainerObj, &snp->sn_assoc_change);
+ return JNI_TRUE;
+ case SCTP_SHUTDOWN_EVENT:
+ handleShutdown(env, resultContainerObj, &snp->sn_shutdown_event);
+ return JNI_TRUE;
+ case SCTP_PEER_ADDR_CHANGE:
+ handlePeerAddrChange(env, resultContainerObj, &snp->sn_paddr_change);
+ return JNI_TRUE;
+ default :
+ /* the Java API is not interested in this event, maybe we are? */
+ handleUninteresting(snp);
+ }
+ return JNI_FALSE;
+}
+
+void handleMessage
+ (JNIEnv* env, jobject resultContainerObj, struct msghdr* msg,int read,
+ jboolean isEOR, struct sockaddr* sap) {
+ jobject isa, resultObj;
+ struct controlData cdata[1];
+
+ if (read == 0) {
+ /* we reached EOF */
+ read = -1;
+ }
+
+ isa = SockAddrToInetSocketAddress(env, sap);
+ getControlData(msg, cdata);
+
+ /* create MessageInfoImpl */
+ resultObj = (*env)->NewObject(env, smi_class, smi_ctrID, cdata->assocId,
+ isa, read, cdata->streamNumber,
+ isEOR ? JNI_TRUE : JNI_FALSE,
+ cdata->unordered, cdata->ppid);
+ CHECK_NULL(resultObj);
+ (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+ (*env)->SetIntField(env, resultContainerObj, src_typeID,
+ sun_nio_ch_sctp_ResultContainer_MESSAGE);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpChannelImpl
+ * Method: receive0
+ * Signature: (ILsun/nio/ch/sctp/ResultContainer;JIZ)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
+ (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
+ jlong address, jint length, jboolean peek) {
+ SOCKADDR sa;
+ int sa_len = sizeof(sa);
+ ssize_t rv = 0;
+ jlong *addr = jlong_to_ptr(address);
+ struct iovec iov[1];
+ struct msghdr msg[1];
+ char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
+ int flags = peek == JNI_TRUE ? MSG_PEEK : 0;
+
+ /* Set up the msghdr structure for receiving */
+ memset(msg, 0, sizeof (*msg));
+ msg->msg_name = &sa;
+ msg->msg_namelen = sa_len;
+ iov->iov_base = addr;
+ iov->iov_len = length;
+ msg->msg_iov = iov;
+ msg->msg_iovlen = 1;
+ msg->msg_control = cbuf;
+ msg->msg_controllen = sizeof(cbuf);
+ msg->msg_flags = 0;
+
+ do {
+ if ((rv = recvmsg(fd, msg, flags)) < 0) {
+ if (errno == EWOULDBLOCK) {
+ return IOS_UNAVAILABLE;
+ } else if (errno == EINTR) {
+ return IOS_INTERRUPTED;
+
+#ifdef __linux__
+ } else if (errno == ENOTCONN) {
+ /* ENOTCONN when EOF reached */
+ rv = 0;
+ /* there will be no control data */
+ msg->msg_controllen = 0;
+#endif /* __linux__ */
+
+ } else {
+ handleSocketError(env, errno);
+ return 0;
+ }
+ }
+
+ if (msg->msg_flags & MSG_NOTIFICATION) {
+ char *bufp = (char*)addr;
+ union sctp_notification *snp;
+
+ if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
+ char buf[NOTIFICATION_BUFFER_SIZE];
+ int rvSAVE = rv;
+ memcpy(buf, addr, rv);
+ iov->iov_base = buf + rv;
+ iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
+ if ((rv = recvmsg(fd, msg, flags)) < 0) {
+ handleSocketError(env, errno);
+ return 0;
+ }
+ bufp = buf;
+ rv += rvSAVE;
+ }
+ snp = (union sctp_notification *) bufp;
+ if (handleNotification(env, fd, resultContainerObj, snp, rv,
+ (msg->msg_flags & MSG_EOR),
+ (struct sockaddr*)&sa ) == JNI_TRUE) {
+ /* We have received a notification that is of interest to
+ to the Java API. The appropriate notification will be
+ set in the result container. */
+ return 0;
+ }
+
+ // set iov back to addr, and reset msg_controllen
+ iov->iov_base = addr;
+ iov->iov_len = length;
+ msg->msg_control = cbuf;
+ msg->msg_controllen = sizeof(cbuf);
+ }
+ } while (msg->msg_flags & MSG_NOTIFICATION);
+
+ handleMessage(env, resultContainerObj, msg, rv,
+ (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
+ return rv;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpChannelImpl
+ * Method: send0
+ * Signature: (IJILjava/net/SocketAddress;IIZI)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_send0
+ (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
+ jobject saTarget, jint assocId, jint streamNumber, jboolean unordered,
+ jint ppid) {
+ SOCKADDR sa;
+ int sa_len = sizeof(sa);
+ ssize_t rv = 0;
+ jlong *addr = jlong_to_ptr(address);
+ struct iovec iov[1];
+ struct msghdr msg[1];
+ int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
+ char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
+ struct controlData cdata[1];
+
+ /* SctpChannel:
+ * saTarget may contain the preferred address or NULL to use primary,
+ * assocId will always be -1
+ * SctpMultiChannell:
+ * Setup new association, saTarget will contain address, assocId = -1
+ * Association already existing, assocId != -1, saTarget = preferred addr
+ */
+ if (saTarget != NULL /*&& assocId <= 0*/) {
+
+ jobject targetAddress = (*env)->GetObjectField(env, saTarget, isa_addrID);
+ jint targetPort = (*env)->GetIntField(env, saTarget, isa_portID);
+
+ if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
+ (struct sockaddr *)&sa,
+ &sa_len, JNI_TRUE) != 0) {
+ return IOS_THROWN;
+ }
+ } else {
+ memset(&sa, '\x0', sa_len);
+ sa_len = 0;
+ }
+
+ /* Set up the msghdr structure for sending */
+ memset(msg, 0, sizeof (*msg));
+ memset(cbuf, 0, cbuf_size);
+ msg->msg_name = &sa;
+ msg->msg_namelen = sa_len;
+ iov->iov_base = addr;
+ iov->iov_len = length;
+ msg->msg_iov = iov;
+ msg->msg_iovlen = 1;
+ msg->msg_control = cbuf;
+ msg->msg_controllen = cbuf_size;
+ msg->msg_flags = 0;
+
+ cdata->streamNumber = streamNumber;
+ cdata->assocId = assocId;
+ cdata->unordered = unordered;
+ cdata->ppid = ppid;
+ setControlData(msg, cdata);
+
+ if ((rv = sendmsg(fd, msg, 0)) < 0) {
+ if (errno == EWOULDBLOCK) {
+ return IOS_UNAVAILABLE;
+ } else if (errno == EINTR) {
+ return IOS_INTERRUPTED;
+ } else if (errno == EPIPE) {
+ JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+ "Socket is shutdown for writing");
+ } else {
+ handleSocketError(env, errno);
+ return 0;
+ }
+ }
+
+ return rv;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpChannelImpl
+ * Method: checkConnect
+ * Signature: (Ljava/io/FileDescriptor;ZZ)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect
+ (JNIEnv* env, jobject this, jobject fdo, jboolean block, jboolean ready) {
+ return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this,
+ fdo, block, ready);
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,753 @@
+/*
+ * Copyright (c) 2009, 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "Sctp.h"
+#include "jni.h"
+#include "jni_util.h"
+#include "nio_util.h"
+#include "nio.h"
+#include "net_util.h"
+#include "net_util_md.h"
+#include "sun_nio_ch_sctp_SctpNet.h"
+#include "sun_nio_ch_sctp_SctpStdSocketOption.h"
+
+static jclass isaCls = 0;
+static jmethodID isaCtrID = 0;
+
+static const char* nativeSctpLib = "libsctp.so.1";
+static jboolean funcsLoaded = JNI_FALSE;
+
+JNIEXPORT jint JNICALL JNI_OnLoad
+ (JavaVM *vm, void *reserved) {
+ return JNI_VERSION_1_2;
+}
+
+static int preCloseFD = -1; /* File descriptor to which we dup other fd's
+ before closing them for real */
+
+/**
+ * Loads the native sctp library that contains the socket extension
+ * functions, as well as locating the individual functions.
+ * There will be a pending exception if this method returns false.
+ */
+jboolean loadSocketExtensionFuncs
+ (JNIEnv* env) {
+ if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ if ((nio_sctp_getladdrs = (sctp_getladdrs_func*)
+ dlsym(RTLD_DEFAULT, "sctp_getladdrs")) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ if ((nio_sctp_freeladdrs = (sctp_freeladdrs_func*)
+ dlsym(RTLD_DEFAULT, "sctp_freeladdrs")) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ if ((nio_sctp_getpaddrs = (sctp_getpaddrs_func*)
+ dlsym(RTLD_DEFAULT, "sctp_getpaddrs")) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ if ((nio_sctp_freepaddrs = (sctp_freepaddrs_func*)
+ dlsym(RTLD_DEFAULT, "sctp_freepaddrs")) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ if ((nio_sctp_bindx = (sctp_bindx_func*)
+ dlsym(RTLD_DEFAULT, "sctp_bindx")) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ if ((nio_sctp_peeloff = (sctp_peeloff_func*)
+ dlsym(RTLD_DEFAULT, "sctp_peeloff")) == NULL) {
+ JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+ dlerror());
+ return JNI_FALSE;
+ }
+
+ funcsLoaded = JNI_TRUE;
+ return JNI_TRUE;
+}
+
+jint
+handleSocketError(JNIEnv *env, jint errorValue)
+{
+ char *xn;
+ switch (errorValue) {
+ case EINPROGRESS: /* Non-blocking connect */
+ return 0;
+ case EPROTO:
+ xn= JNU_JAVANETPKG "ProtocolException";
+ break;
+ case ECONNREFUSED:
+ xn = JNU_JAVANETPKG "ConnectException";
+ break;
+ case ETIMEDOUT:
+ xn = JNU_JAVANETPKG "ConnectException";
+ break;
+ case EHOSTUNREACH:
+ xn = JNU_JAVANETPKG "NoRouteToHostException";
+ break;
+ case EADDRINUSE: /* Fall through */
+ case EADDRNOTAVAIL:
+ xn = JNU_JAVANETPKG "BindException";
+ break;
+ default:
+ xn = JNU_JAVANETPKG "SocketException";
+ break;
+ }
+ errno = errorValue;
+ JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
+ return IOS_THROWN;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_init
+ (JNIEnv *env, jclass cl) {
+ int sp[2];
+ if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
+ JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
+ return;
+ }
+ preCloseFD = sp[0];
+ close(sp[1]);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: socket0
+ * Signature: (Z)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpNet_socket0
+ (JNIEnv *env, jclass klass, jboolean oneToOne) {
+ int fd;
+ struct sctp_event_subscribe event;
+#ifdef AF_INET6
+ int domain = ipv6_available() ? AF_INET6 : AF_INET;
+#else
+ int domain = AF_INET;
+#endif
+
+ /* Try to load the socket API extension functions */
+ if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
+ return 0;
+ }
+
+ fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
+
+ if (fd < 0) {
+ return handleSocketError(env, errno);
+ }
+
+ /* Enable events */
+ memset(&event, 0, sizeof(event));
+ event.sctp_data_io_event = 1;
+ event.sctp_association_event = 1;
+ event.sctp_address_event = 1;
+ event.sctp_send_failure_event = 1;
+ //event.sctp_peer_error_event = 1;
+ event.sctp_shutdown_event = 1;
+ //event.sctp_partial_delivery_event = 1;
+ //event.sctp_adaptation_layer_event = 1;
+ if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
+ handleSocketError(env, errno);
+ }
+ return fd;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: bindx
+ * Signature: (I[Ljava/net/InetAddress;IIZ)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_bindx
+ (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
+ jint addrsLength, jboolean add, jboolean preferIPv6) {
+ SOCKADDR *sap, *tmpSap;
+ int i, sa_len = sizeof(SOCKADDR);
+ jobject ia;
+
+ if (addrsLength < 1)
+ return;
+
+ if ((sap = calloc(addrsLength, sa_len)) == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
+ return;
+ }
+
+ tmpSap = sap;
+ for (i=0; i<addrsLength; i++) {
+ ia = (*env)->GetObjectArrayElement(env, addrs, i);
+ if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
+ &sa_len, preferIPv6) != 0) {
+ free(sap);
+ return;
+ }
+ tmpSap++;
+ }
+
+ if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
+ SCTP_BINDX_REM_ADDR) != 0) {
+ handleSocketError(env, errno);
+ }
+
+ free(sap);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: listen0
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_listen0
+ (JNIEnv *env, jclass cl, jint fd, jint backlog) {
+ if (listen(fd, backlog) < 0)
+ handleSocketError(env, errno);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: connect0
+ * Signature: (ILjava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL
+Java_sun_nio_ch_sctp_SctpNet_connect0
+ (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
+ SOCKADDR sa;
+ int sa_len = SOCKADDR_LEN;
+ int rv;
+
+ if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
+ &sa_len, JNI_TRUE) != 0) {
+ return IOS_THROWN;
+ }
+
+ rv = connect(fd, (struct sockaddr *)&sa, sa_len);
+ if (rv != 0) {
+ if (errno == EINPROGRESS) {
+ return IOS_UNAVAILABLE;
+ } else if (errno == EINTR) {
+ return IOS_INTERRUPTED;
+ }
+ return handleSocketError(env, errno);
+ }
+ return 1;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: close0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_close0
+ (JNIEnv *env, jclass clazz, jint fd) {
+ if (fd != -1) {
+ int rv = close(fd);
+ if (rv < 0)
+ JNU_ThrowIOExceptionWithLastError(env, "Close failed");
+ }
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: preClose0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_preClose0
+ (JNIEnv *env, jclass clazz, jint fd) {
+ if (preCloseFD >= 0) {
+ if (dup2(preCloseFD, fd) < 0)
+ JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
+ }
+}
+
+void initializeISA
+ (JNIEnv* env) {
+ if (isaCls == 0) {
+ jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
+ CHECK_NULL(c);
+ isaCls = (*env)->NewGlobalRef(env, c);
+ CHECK_NULL(isaCls);
+ (*env)->DeleteLocalRef(env, c);
+ isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>",
+ "(Ljava/net/InetAddress;I)V");
+ }
+}
+
+jobject SockAddrToInetSocketAddress
+ (JNIEnv *env, struct sockaddr* sap) {
+ int port = 0;
+
+ jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
+ if (ia == NULL)
+ return NULL;
+
+ if (isaCls == 0) {
+ initializeISA(env);
+ CHECK_NULL_RETURN(isaCls, NULL);
+ }
+
+ return (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: getLocalAddresses0
+ * Signature: (I)[Ljava/net/SocketAddress;
+ */
+JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0
+ (JNIEnv *env, jclass klass, jint fd) {
+ void *addr_buf, *laddr;
+ struct sockaddr* sap;
+ int i, addrCount;
+ jobjectArray isaa;
+
+#ifdef __solaris__
+ if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
+#else /* __linux__ */
+ if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
+#endif
+ handleSocketError(env, errno);
+ return NULL;
+ }
+
+ if (addrCount < 1)
+ return NULL;
+
+ if (isaCls == 0) {
+ initializeISA(env);
+ CHECK_NULL_RETURN(isaCls, NULL);
+ }
+
+ isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
+ if (isaa == NULL) {
+ nio_sctp_freeladdrs(addr_buf);
+ return NULL;
+ }
+
+ laddr = addr_buf;
+ for (i=0; i<addrCount; i++) {
+ int port = 0;
+ jobject isa = NULL, ia;
+ sap = (struct sockaddr*)addr_buf;
+ ia = NET_SockaddrToInetAddress(env, sap, &port);
+ if (ia != NULL)
+ isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
+ if (isa != NULL)
+ (*env)->SetObjectArrayElement(env, isaa, i, isa);
+
+ if (sap->sa_family == AF_INET)
+ addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
+ else
+ addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
+ }
+
+ nio_sctp_freeladdrs(laddr);
+ return isaa;
+}
+
+jobjectArray getRemoteAddresses
+ (JNIEnv *env, jint fd, sctp_assoc_t id) {
+ void *addr_buf, *paddr;
+ struct sockaddr* sap;
+ int i, addrCount;
+ jobjectArray isaa;
+
+#if __solaris__
+ if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
+#else /* __linux__ */
+ if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
+#endif
+ handleSocketError(env, errno);
+ return NULL;
+ }
+
+ if (addrCount < 1)
+ return NULL;
+
+ if (isaCls == 0) {
+ initializeISA(env);
+ CHECK_NULL_RETURN(isaCls, NULL);
+ }
+
+ isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
+ if (isaa == NULL) {
+ nio_sctp_freepaddrs(addr_buf);
+ return NULL;
+ }
+
+ paddr = addr_buf;
+ for (i=0; i<addrCount; i++) {
+ jobject ia, isa = NULL;
+ int port;
+ sap = (struct sockaddr*)addr_buf;
+ ia = NET_SockaddrToInetAddress(env, sap, &port);
+ if (ia != NULL)
+ isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
+ if (isa != NULL)
+ (*env)->SetObjectArrayElement(env, isaa, i, isa);
+
+ if (sap->sa_family == AF_INET)
+ addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
+ else
+ addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
+ }
+
+ nio_sctp_freepaddrs(paddr);
+
+ return isaa;
+}
+
+ /*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: getRemoteAddresses0
+ * Signature: (II)[Ljava/net/SocketAddress;
+ */
+JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getRemoteAddresses0
+ (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+ return getRemoteAddresses(env, fd, assocId);
+}
+
+/* Map the Java level option to the native level */
+int mapSocketOption
+ (jint cmd, int *level, int *optname) {
+ static struct {
+ jint cmd;
+ int level;
+ int optname;
+ } const opts[] = {
+ { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_DISABLE_FRAGMENTS, IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS },
+ { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_EXPLICIT_COMPLETE, IPPROTO_SCTP, SCTP_EXPLICIT_EOR },
+ { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_FRAGMENT_INTERLEAVE, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE },
+ { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_NODELAY, IPPROTO_SCTP, SCTP_NODELAY },
+ { sun_nio_ch_sctp_SctpStdSocketOption_SO_SNDBUF, SOL_SOCKET, SO_SNDBUF },
+ { sun_nio_ch_sctp_SctpStdSocketOption_SO_RCVBUF, SOL_SOCKET, SO_RCVBUF },
+ { sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER, SOL_SOCKET, SO_LINGER } };
+
+ int i;
+ for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
+ if (cmd == opts[i].cmd) {
+ *level = opts[i].level;
+ *optname = opts[i].optname;
+ return 0;
+ }
+ }
+
+ /* not found */
+ return -1;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: setIntOption0
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setIntOption0
+ (JNIEnv *env, jclass klass, jint fd, jint opt, int arg) {
+ int klevel, kopt;
+ int result;
+ struct linger linger;
+ void *parg;
+ int arglen;
+
+ if (mapSocketOption(opt, &klevel, &kopt) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "Unsupported socket option");
+ return;
+ }
+
+ if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER) {
+ parg = (void *)&linger;
+ arglen = sizeof(linger);
+ if (arg >= 0) {
+ linger.l_onoff = 1;
+ linger.l_linger = arg;
+ } else {
+ linger.l_onoff = 0;
+ linger.l_linger = 0;
+ }
+ } else {
+ parg = (void *)&arg;
+ arglen = sizeof(arg);
+ }
+
+ if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun_nio_ch_sctp_SctpNet.setIntOption0");
+ }
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: getIntOption0
+ * Signature: (II)I
+ */
+JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_getIntOption0
+ (JNIEnv *env, jclass klass, jint fd, jint opt) {
+ int klevel, kopt;
+ int result;
+ struct linger linger;
+ void *arg;
+ int arglen;
+
+ if (mapSocketOption(opt, &klevel, &kopt) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "Unsupported socket option");
+ return -1;
+ }
+
+ if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER) {
+ arg = (void *)&linger;
+ arglen = sizeof(linger);
+ } else {
+ arg = (void *)&result;
+ arglen = sizeof(result);
+ }
+
+ if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.Net.getIntOption");
+ return -1;
+ }
+
+ if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER)
+ return linger.l_onoff ? linger.l_linger : -1;
+ else
+ return result;
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: getPrimAddrOption0
+ * Signature: (II)Ljava/net/SocketAddress;
+ */
+JNIEXPORT jobject JNICALL Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0
+ (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+ struct sctp_setprim prim;
+ unsigned int prim_len = sizeof(prim);
+ struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
+
+ prim.ssp_assoc_id = assocId;
+
+ if (getsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, &prim_len) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.SctpNet.getPrimAddrOption0");
+ return NULL;
+ }
+
+ return SockAddrToInetSocketAddress(env, sap);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: setPrimAddrOption0
+ * Signature: (IILjava/net/InetAddress;I)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0
+ (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
+ struct sctp_setprim prim;
+ struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
+ int sap_len;
+
+ if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
+ &sap_len, JNI_TRUE) != 0) {
+ return;
+ }
+
+ prim.ssp_assoc_id = assocId;
+
+ if (setsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, sizeof(prim)) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.SctpNet.setPrimAddrOption0");
+ }
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: setPeerPrimAddrOption0
+ * Signature: (IILjava/net/InetAddress;I)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0
+ (JNIEnv *env, jclass klass, jint fd, jint assocId,
+ jobject iaObj, jint port, jboolean preferIPv6) {
+ struct sctp_setpeerprim prim;
+ struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
+ int sap_len;
+
+ if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
+ &sap_len, preferIPv6) != 0) {
+ return;
+ }
+
+ prim.sspp_assoc_id = assocId;
+
+ if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
+ sizeof(prim)) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
+ }
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: getInitMsgOption0
+ * Signature: (I[I)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_getInitMsgOption0
+ (JNIEnv *env, jclass klass, jint fd, jintArray retVal) {
+ struct sctp_initmsg sctp_initmsg;
+ unsigned int sim_len = sizeof(sctp_initmsg);
+ int vals[2];
+
+ if (getsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
+ &sim_len) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.SctpNet.getInitMsgOption0");
+ return;
+ }
+
+ vals[0] = sctp_initmsg.sinit_max_instreams;
+ vals[1] = sctp_initmsg.sinit_num_ostreams;
+ (*env)->SetIntArrayRegion(env, retVal, 0, 2, vals);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: setInitMsgOption0
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setInitMsgOption0
+ (JNIEnv *env, jclass klass, jint fd, jint inArg, jint outArg) {
+ struct sctp_initmsg sctp_initmsg;
+
+ sctp_initmsg.sinit_max_instreams = (unsigned int)inArg;
+ sctp_initmsg.sinit_num_ostreams = (unsigned int)outArg;
+ sctp_initmsg.sinit_max_attempts = 0; // default
+ sctp_initmsg.sinit_max_init_timeo = 0; // default
+
+ if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
+ sizeof(sctp_initmsg)) < 0) {
+ JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+ "sun.nio.ch.SctpNet.setInitMsgOption0");
+ }
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: shutdown0
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_shutdown0
+ (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+ int rv;
+ struct msghdr msg[1];
+ struct iovec iov[1];
+ int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
+ char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
+ struct cmsghdr* cmsg;
+ struct sctp_sndrcvinfo *sri;
+
+ /* SctpSocketChannel */
+ if (assocId < 0) {
+ shutdown(fd, SHUT_WR);
+ return;
+ }
+
+ memset(msg, 0, sizeof (*msg));
+ memset(cbuf, 0, cbuf_size);
+ msg->msg_name = NULL;
+ msg->msg_namelen = 0;
+ iov->iov_base = NULL;
+ iov->iov_len = 0;
+ msg->msg_iov = iov;
+ msg->msg_iovlen = 1;
+ msg->msg_control = cbuf;
+ msg->msg_controllen = cbuf_size;
+ msg->msg_flags = 0;
+
+ cmsg = CMSG_FIRSTHDR(msg);
+ cmsg->cmsg_level = IPPROTO_SCTP;
+ cmsg->cmsg_type = SCTP_SNDRCV;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
+
+ /* Initialize the payload: */
+ sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
+ memset(sri, 0, sizeof (*sri));
+
+ if (assocId > 0) {
+ sri->sinfo_assoc_id = assocId;
+ }
+
+ sri->sinfo_flags = sri->sinfo_flags | SCTP_EOF;
+
+ /* Sum of the length of all control messages in the buffer. */
+ msg->msg_controllen = cmsg->cmsg_len;
+
+ if ((rv = sendmsg(fd, msg, 0)) < 0) {
+ handleSocketError(env, errno);
+ }
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpNet
+ * Method: branch
+ * Signature: (II)I
+ */
+JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_branch0
+ (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+ int newfd = 0;
+ if ((newfd = nio_sctp_peeloff(fd, assocId)) < 0) {
+ handleSocketError(env, errno);
+ }
+
+ return newfd;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpServerChannelImpl.c Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 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.
+ */
+
+#include "sun_nio_ch_sctp_SctpServerChannelImpl.h"
+
+extern void Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv* env,
+ jclass c);
+
+extern jint Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv* env,
+ jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa);
+
+/*
+ * Class: sun_nio_ch_sctp_SctpServerChannelImpl
+ * Method: initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpServerChannelImpl_initIDs
+ (JNIEnv* env, jclass c) {
+ Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(env, c);
+}
+
+/*
+ * Class: sun_nio_ch_sctp_SctpServerChannelImpl
+ * Method: accept0
+ * Signature: (Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpServerChannelImpl_accept0
+ (JNIEnv* env, jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa) {
+ return Java_sun_nio_ch_ServerSocketChannelImpl_accept0(env, this,
+ ssfdo, newfdo, isaa);
+}
--- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Fri Mar 02 09:13:13 2012 -0800
@@ -605,9 +605,12 @@
JNIEXPORT jbyteArray JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong value) {
- char entry[sizeof(struct dirent64) + PATH_MAX + 1];
- struct dirent64* ptr = (struct dirent64*)&entry;
struct dirent64* result;
+ struct {
+ struct dirent64 buf;
+ char name_extra[PATH_MAX + 1 - sizeof result->d_name];
+ } entry;
+ struct dirent64* ptr = &entry.buf;
int res;
DIR* dirp = jlong_to_ptr(value);
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DRenderer.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DRenderer.java Fri Mar 02 09:13:13 2012 -0800
@@ -27,6 +27,7 @@
import java.awt.Transparency;
import java.awt.geom.Path2D;
+import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.loops.GraphicsPrimitive;
import sun.java2d.pipe.BufferedPaints;
@@ -47,7 +48,12 @@
int ctxflags =
sg2d.paint.getTransparency() == Transparency.OPAQUE ?
D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
- D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
+ D3DSurfaceData dstData;
+ try {
+ dstData = (D3DSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
D3DContext.validateContext(dstData, dstData,
sg2d.getCompClip(), sg2d.composite,
null, sg2d.paint, sg2d, ctxflags);
@@ -56,7 +62,12 @@
@Override
protected void validateContextAA(SunGraphics2D sg2d) {
int ctxflags = D3DContext.NO_CONTEXT_FLAGS;
- D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
+ D3DSurfaceData dstData;
+ try {
+ dstData = (D3DSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
D3DContext.validateContext(dstData, dstData,
sg2d.getCompClip(), sg2d.composite,
null, sg2d.paint, sg2d, ctxflags);
@@ -70,7 +81,12 @@
int ctxflags =
sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
- D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
+ D3DSurfaceData dstData;
+ try {
+ dstData = (D3DSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
D3DContext.validateContext(dstData, dstData,
sg2d.getCompClip(), sg2d.composite,
null, null, null, ctxflags);
--- a/jdk/src/windows/classes/sun/java2d/windows/GDIRenderer.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/classes/sun/java2d/windows/GDIRenderer.java Fri Mar 02 09:13:13 2012 -0800
@@ -29,6 +29,7 @@
import java.awt.Shape;
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
+import sun.java2d.InvalidPipeException;
import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceData;
import sun.java2d.pipe.Region;
@@ -45,7 +46,7 @@
PixelFillPipe,
ShapeDrawPipe
{
- native void doDrawLine(SurfaceData sData,
+ native void doDrawLine(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x1, int y1, int x2, int y2);
@@ -54,24 +55,32 @@
{
int transx = sg2d.transX;
int transy = sg2d.transY;
- doDrawLine(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x1+transx, y1+transy, x2+transx, y2+transy);
+ try {
+ doDrawLine((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x1+transx, y1+transy, x2+transx, y2+transy);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doDrawRect(SurfaceData sData,
+ native void doDrawRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void drawRect(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
- doDrawRect(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height);
+ try {
+ doDrawRect((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doDrawRoundRect(SurfaceData sData,
+ native void doDrawRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH);
@@ -80,25 +89,33 @@
int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- doDrawRoundRect(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height,
- arcWidth, arcHeight);
+ try {
+ doDrawRoundRect((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height,
+ arcWidth, arcHeight);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doDrawOval(SurfaceData sData,
+ native void doDrawOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void drawOval(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
- doDrawOval(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height);
+ try {
+ doDrawOval((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doDrawArc(SurfaceData sData,
+ native void doDrawArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent);
@@ -107,13 +124,17 @@
int x, int y, int width, int height,
int startAngle, int arcAngle)
{
- doDrawArc(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height,
- startAngle, arcAngle);
+ try {
+ doDrawArc((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height,
+ startAngle, arcAngle);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doDrawPoly(SurfaceData sData,
+ native void doDrawPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
@@ -123,33 +144,45 @@
int xpoints[], int ypoints[],
int npoints)
{
- doDrawPoly(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false);
+ try {
+ doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, false);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
public void drawPolygon(SunGraphics2D sg2d,
int xpoints[], int ypoints[],
int npoints)
{
- doDrawPoly(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, true);
+ try {
+ doDrawPoly((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ sg2d.transX, sg2d.transY, xpoints, ypoints, npoints, true);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doFillRect(SurfaceData sData,
+ native void doFillRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void fillRect(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
- doFillRect(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height);
+ try {
+ doFillRect((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doFillRoundRect(SurfaceData sData,
+ native void doFillRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH);
@@ -158,25 +191,33 @@
int x, int y, int width, int height,
int arcWidth, int arcHeight)
{
- doFillRoundRect(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height,
- arcWidth, arcHeight);
+ try {
+ doFillRoundRect((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height,
+ arcWidth, arcHeight);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doFillOval(SurfaceData sData,
+ native void doFillOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h);
public void fillOval(SunGraphics2D sg2d,
int x, int y, int width, int height)
{
- doFillOval(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height);
+ try {
+ doFillOval((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doFillArc(SurfaceData sData,
+ native void doFillArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent);
@@ -185,13 +226,17 @@
int x, int y, int width, int height,
int startAngle, int arcAngle)
{
- doFillArc(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- x+sg2d.transX, y+sg2d.transY, width, height,
- startAngle, arcAngle);
+ try {
+ doFillArc((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ x+sg2d.transX, y+sg2d.transY, width, height,
+ startAngle, arcAngle);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doFillPoly(SurfaceData sData,
+ native void doFillPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
@@ -201,12 +246,16 @@
int xpoints[], int ypoints[],
int npoints)
{
- doFillPoly(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
+ try {
+ doFillPoly((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ sg2d.transX, sg2d.transY, xpoints, ypoints, npoints);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
- native void doShape(SurfaceData sData,
+ native void doShape(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transX, int transY,
Path2D.Float p2df, boolean isfill);
@@ -228,9 +277,13 @@
transX = 0;
transY = 0;
}
- doShape(sg2d.surfaceData,
- sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
- transX, transY, p2df, isfill);
+ try {
+ doShape((GDIWindowSurfaceData)sg2d.surfaceData,
+ sg2d.getCompClip(), sg2d.composite, sg2d.eargb,
+ transX, transY, p2df, isfill);
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
}
// REMIND: This is just a hack to get WIDE lines to honor the
@@ -239,7 +292,12 @@
// method that could be filled by the doShape method more quickly.
public void doFillSpans(SunGraphics2D sg2d, SpanIterator si) {
int box[] = new int[4];
- SurfaceData sd = sg2d.surfaceData;
+ GDIWindowSurfaceData sd;
+ try {
+ sd = (GDIWindowSurfaceData)sg2d.surfaceData;
+ } catch (ClassCastException e) {
+ throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
+ }
Region clip = sg2d.getCompClip();
Composite comp = sg2d.composite;
int eargb = sg2d.eargb;
@@ -268,7 +326,7 @@
doShape(sg2d, s, true);
}
- public native void devCopyArea(SurfaceData sData,
+ public native void devCopyArea(GDIWindowSurfaceData sData,
int srcx, int srcy,
int dx, int dy,
int w, int h);
@@ -278,21 +336,21 @@
}
public static class Tracer extends GDIRenderer {
- void doDrawLine(SurfaceData sData,
+ void doDrawLine(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x1, int y1, int x2, int y2)
{
GraphicsPrimitive.tracePrimitive("GDIDrawLine");
super.doDrawLine(sData, clip, comp, color, x1, y1, x2, y2);
}
- void doDrawRect(SurfaceData sData,
+ void doDrawRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIDrawRect");
super.doDrawRect(sData, clip, comp, color, x, y, w, h);
}
- void doDrawRoundRect(SurfaceData sData,
+ void doDrawRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH)
@@ -301,14 +359,14 @@
super.doDrawRoundRect(sData, clip, comp, color,
x, y, w, h, arcW, arcH);
}
- void doDrawOval(SurfaceData sData,
+ void doDrawOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIDrawOval");
super.doDrawOval(sData, clip, comp, color, x, y, w, h);
}
- void doDrawArc(SurfaceData sData,
+ void doDrawArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent)
@@ -317,7 +375,7 @@
super.doDrawArc(sData, clip, comp, color, x, y, w, h,
angleStart, angleExtent);
}
- void doDrawPoly(SurfaceData sData,
+ void doDrawPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
@@ -327,14 +385,14 @@
super.doDrawPoly(sData, clip, comp, color, transx, transy,
xpoints, ypoints, npoints, isclosed);
}
- void doFillRect(SurfaceData sData,
+ void doFillRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIFillRect");
super.doFillRect(sData, clip, comp, color, x, y, w, h);
}
- void doFillRoundRect(SurfaceData sData,
+ void doFillRoundRect(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int arcW, int arcH)
@@ -343,14 +401,14 @@
super.doFillRoundRect(sData, clip, comp, color,
x, y, w, h, arcW, arcH);
}
- void doFillOval(SurfaceData sData,
+ void doFillOval(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h)
{
GraphicsPrimitive.tracePrimitive("GDIFillOval");
super.doFillOval(sData, clip, comp, color, x, y, w, h);
}
- void doFillArc(SurfaceData sData,
+ void doFillArc(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int x, int y, int w, int h,
int angleStart, int angleExtent)
@@ -359,7 +417,7 @@
super.doFillArc(sData, clip, comp, color, x, y, w, h,
angleStart, angleExtent);
}
- void doFillPoly(SurfaceData sData,
+ void doFillPoly(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transx, int transy,
int[] xpoints, int[] ypoints,
@@ -369,7 +427,7 @@
super.doFillPoly(sData, clip, comp, color, transx, transy,
xpoints, ypoints, npoints);
}
- void doShape(SurfaceData sData,
+ void doShape(GDIWindowSurfaceData sData,
Region clip, Composite comp, int color,
int transX, int transY,
Path2D.Float p2df, boolean isfill)
@@ -380,7 +438,7 @@
super.doShape(sData, clip, comp, color,
transX, transY, p2df, isfill);
}
- public void devCopyArea(SurfaceData sData,
+ public void devCopyArea(GDIWindowSurfaceData sData,
int srcx, int srcy,
int dx, int dy,
int w, int h)
--- a/jdk/src/windows/classes/sun/nio/ch/NativeThread.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/NativeThread.java Fri Mar 02 09:13:13 2012 -0800
@@ -31,7 +31,11 @@
class NativeThread {
- static long current() { return -1; }
+ static long current() {
+ // return 0 to ensure that async close of blocking sockets will close
+ // the underlying socket.
+ return 0;
+ }
static void signal(long nt) { }
--- a/jdk/src/windows/classes/sun/nio/ch/SctpChannelImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetAddress;
-import java.io.IOException;
-import java.util.Set;
-import java.nio.ByteBuffer;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-
-/**
- * Unimplemented.
- */
-public class SctpChannelImpl extends SctpChannel
-{
- private static final String message = "SCTP not supported on this platform";
-
- public SctpChannelImpl(SelectorProvider provider) {
- super(provider);
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Association association() {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpChannel bind(SocketAddress local)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpChannel bindAddress(InetAddress address)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpChannel unbindAddress(InetAddress address)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public boolean connect(SocketAddress remote) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public boolean connect(SocketAddress remote, int maxOutStreams,
- int maxInStreams) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public boolean isConnectionPending() {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public boolean finishConnect() throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SocketAddress> getAllLocalAddresses()
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SocketAddress> getRemoteAddresses()
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpChannel shutdown() throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> T getOption(SctpSocketOption<T> name)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SctpSocketOption<?>> supportedOptions() {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> MessageInfo receive(ByteBuffer dst, T attachment,
- NotificationHandler<T> handler) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public int send(ByteBuffer src, MessageInfo messageInfo)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- protected void implConfigureBlocking(boolean block) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public void implCloseSelectableChannel() throws IOException {
- throw new UnsupportedOperationException(message);
- }
-}
--- a/jdk/src/windows/classes/sun/nio/ch/SctpMultiChannelImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetAddress;
-import java.io.IOException;
-import java.util.Set;
-import java.nio.ByteBuffer;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.SctpMultiChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-
-/**
- * Unimplemented.
- */
-public class SctpMultiChannelImpl extends SctpMultiChannel
-{
- private static final String message = "SCTP not supported on this platform";
-
- public SctpMultiChannelImpl(SelectorProvider provider) {
- super(provider);
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<Association> associations() {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpMultiChannel bind(SocketAddress local,
- int backlog) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpMultiChannel bindAddress(InetAddress address)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpMultiChannel unbindAddress(InetAddress address)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SocketAddress> getAllLocalAddresses()
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SocketAddress> getRemoteAddresses
- (Association association) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpMultiChannel shutdown(Association association)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> T getOption(SctpSocketOption<T> name,
- Association association) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
- T value, Association association) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SctpSocketOption<?>> supportedOptions() {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
- NotificationHandler<T> handler) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public int send(ByteBuffer buffer, MessageInfo messageInfo)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpChannel branch(Association association)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- protected void implConfigureBlocking(boolean block) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public void implCloseSelectableChannel() throws IOException {
- throw new UnsupportedOperationException(message);
- }
-}
--- a/jdk/src/windows/classes/sun/nio/ch/SctpServerChannelImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 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 sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetAddress;
-import java.io.IOException;
-import java.util.Set;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpServerChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-
-/**
- * Unimplemented.
- */
-public class SctpServerChannelImpl extends SctpServerChannel
-{
- private static final String message = "SCTP not supported on this platform";
-
- public SctpServerChannelImpl(SelectorProvider provider) {
- super(provider);
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpChannel accept() throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpServerChannel bind(SocketAddress local,
- int backlog) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpServerChannel bindAddress(InetAddress address)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public SctpServerChannel unbindAddress(InetAddress address)
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SocketAddress> getAllLocalAddresses()
- throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> T getOption(SctpSocketOption<T> name) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public <T> SctpServerChannel setOption(SctpSocketOption<T> name,
- T value) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public Set<SctpSocketOption<?>> supportedOptions() {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- protected void implConfigureBlocking(boolean block) throws IOException {
- throw new UnsupportedOperationException(message);
- }
-
- @Override
- public void implCloseSelectableChannel() throws IOException {
- throw new UnsupportedOperationException(message);
- }
-}
--- a/jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/SocketDispatcher.java Fri Mar 02 09:13:13 2012 -0800
@@ -55,10 +55,11 @@
return writev0(fd, address, len);
}
- void close(FileDescriptor fd) throws IOException {
+ void preClose(FileDescriptor fd) throws IOException {
+ preClose0(fd);
}
- void preClose(FileDescriptor fd) throws IOException {
+ void close(FileDescriptor fd) throws IOException {
close0(fd);
}
@@ -75,5 +76,7 @@
static native long writev0(FileDescriptor fd, long address, int len)
throws IOException;
+ static native void preClose0(FileDescriptor fd) throws IOException;
+
static native void close0(FileDescriptor fd) throws IOException;
}
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -585,7 +585,7 @@
((SelChImpl)selch).kill();
}
- void putEventOps(SelectionKeyImpl sk, int ops) {
+ public void putEventOps(SelectionKeyImpl sk, int ops) {
synchronized (closeLock) {
if (pollWrapper == null)
throw new ClosedSelectorException();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/sctp/SctpChannelImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetAddress;
+import java.io.IOException;
+import java.util.Set;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+
+/**
+ * Unimplemented.
+ */
+public class SctpChannelImpl extends SctpChannel
+{
+ private static final String message = "SCTP not supported on this platform";
+
+ public SctpChannelImpl(SelectorProvider provider) {
+ super(provider);
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Association association() {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpChannel bind(SocketAddress local)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpChannel bindAddress(InetAddress address)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpChannel unbindAddress(InetAddress address)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public boolean connect(SocketAddress remote) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public boolean connect(SocketAddress remote, int maxOutStreams,
+ int maxInStreams) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public boolean isConnectionPending() {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public boolean finishConnect() throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SocketAddress> getAllLocalAddresses()
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SocketAddress> getRemoteAddresses()
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpChannel shutdown() throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> T getOption(SctpSocketOption<T> name)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SctpSocketOption<?>> supportedOptions() {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> MessageInfo receive(ByteBuffer dst, T attachment,
+ NotificationHandler<T> handler) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public int send(ByteBuffer src, MessageInfo messageInfo)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ protected void implConfigureBlocking(boolean block) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public void implCloseSelectableChannel() throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetAddress;
+import java.io.IOException;
+import java.util.Set;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.SctpMultiChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+
+/**
+ * Unimplemented.
+ */
+public class SctpMultiChannelImpl extends SctpMultiChannel
+{
+ private static final String message = "SCTP not supported on this platform";
+
+ public SctpMultiChannelImpl(SelectorProvider provider) {
+ super(provider);
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<Association> associations() {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpMultiChannel bind(SocketAddress local,
+ int backlog) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpMultiChannel bindAddress(InetAddress address)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpMultiChannel unbindAddress(InetAddress address)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SocketAddress> getAllLocalAddresses()
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SocketAddress> getRemoteAddresses
+ (Association association) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpMultiChannel shutdown(Association association)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> T getOption(SctpSocketOption<T> name,
+ Association association) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
+ T value, Association association) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SctpSocketOption<?>> supportedOptions() {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
+ NotificationHandler<T> handler) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public int send(ByteBuffer buffer, MessageInfo messageInfo)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpChannel branch(Association association)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ protected void implConfigureBlocking(boolean block) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public void implCloseSelectableChannel() throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 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 sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetAddress;
+import java.io.IOException;
+import java.util.Set;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpServerChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+
+/**
+ * Unimplemented.
+ */
+public class SctpServerChannelImpl extends SctpServerChannel
+{
+ private static final String message = "SCTP not supported on this platform";
+
+ public SctpServerChannelImpl(SelectorProvider provider) {
+ super(provider);
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpChannel accept() throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpServerChannel bind(SocketAddress local,
+ int backlog) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpServerChannel bindAddress(InetAddress address)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public SctpServerChannel unbindAddress(InetAddress address)
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SocketAddress> getAllLocalAddresses()
+ throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> T getOption(SctpSocketOption<T> name) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public <T> SctpServerChannel setOption(SctpSocketOption<T> name,
+ T value) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public Set<SctpSocketOption<?>> supportedOptions() {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ protected void implConfigureBlocking(boolean block) throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+
+ @Override
+ public void implCloseSelectableChannel() throws IOException {
+ throw new UnsupportedOperationException(message);
+ }
+}
--- a/jdk/src/windows/native/java/lang/java_props_md.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/native/java/lang/java_props_md.c Fri Mar 02 09:13:13 2012 -0800
@@ -31,6 +31,9 @@
#include <sys/timeb.h>
#include <tchar.h>
+#include <stdlib.h>
+#include <Wincon.h>
+
#include "locale_str.h"
#include "java_props.h"
@@ -123,6 +126,17 @@
return ret;
}
+static char* getConsoleEncoding()
+{
+ char* buf = malloc(16);
+ int cp = GetConsoleCP();
+ if (cp >= 874 && cp <= 950)
+ sprintf(buf, "ms%d", cp);
+ else
+ sprintf(buf, "cp%d", cp);
+ return buf;
+}
+
// Exported entries for AWT
DllExport const char *
getEncodingFromLangID(LANGID langID)
@@ -562,6 +576,7 @@
{
char * display_encoding;
+ HANDLE hStdOutErr;
// Windows UI Language selection list only cares "language"
// information of the UI Language. For example, the list
@@ -606,6 +621,20 @@
sprops.encoding = "MS950_HKSCS";
sprops.sun_jnu_encoding = "MS950_HKSCS";
}
+
+ hStdOutErr = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (hStdOutErr != INVALID_HANDLE_VALUE &&
+ GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
+ sprops.sun_stdout_encoding = getConsoleEncoding();
+ }
+ hStdOutErr = GetStdHandle(STD_ERROR_HANDLE);
+ if (hStdOutErr != INVALID_HANDLE_VALUE &&
+ GetFileType(hStdOutErr) == FILE_TYPE_CHAR) {
+ if (sprops.sun_stdout_encoding != NULL)
+ sprops.sun_stderr_encoding = sprops.sun_stdout_encoding;
+ else
+ sprops.sun_stderr_encoding = getConsoleEncoding();
+ }
}
}
--- a/jdk/src/windows/native/sun/java2d/windows/GDIRenderer.cpp Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/native/sun/java2d/windows/GDIRenderer.cpp Fri Mar 02 09:13:13 2012 -0800
@@ -117,7 +117,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doDrawLine
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doDrawLine
@@ -164,7 +164,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doDrawRect
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doDrawRect
@@ -209,7 +209,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doDrawRoundRect
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doDrawRoundRect
@@ -253,7 +253,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doDrawOval
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doDrawOval
@@ -291,7 +291,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doDrawArc
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doDrawArc
@@ -347,7 +347,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doDrawPoly
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;III[I[IIZ)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;III[I[IIZ)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doDrawPoly
@@ -412,7 +412,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doFillRect
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doFillRect
@@ -445,7 +445,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doFillRoundRect
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doFillRoundRect
@@ -488,7 +488,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doFillOval
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doFillOval
@@ -555,7 +555,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doFillArc
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;IIIIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doFillArc
@@ -615,7 +615,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doFillPoly
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;III[I[II)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;Ljava/awt/Composite;III[I[II)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_doFillPoly
@@ -680,7 +680,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: doShape
- * Signature: (Lsun/java2d/SurfaceData;Lsun/java2d/pipe/Region;
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;Lsun/java2d/pipe/Region;
* Ljava/awt/Composite;IIILjava/awt/geom/Path2D.Float;Z)V
*/
JNIEXPORT void JNICALL
@@ -863,7 +863,7 @@
/*
* Class: sun_java2d_windows_GDIRenderer
* Method: devCopyArea
- * Signature: (Lsun/awt/windows/SurfaceData;IIIIII)V
+ * Signature: (Lsun/java2d/windows/GDIWindowSurfaceData;IIIIII)V
*/
JNIEXPORT void JNICALL
Java_sun_java2d_windows_GDIRenderer_devCopyArea
--- a/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/src/windows/native/sun/nio/ch/SocketDispatcher.c Fri Mar 02 09:13:13 2012 -0800
@@ -238,23 +238,25 @@
}
JNIEXPORT void JNICALL
-Java_sun_nio_ch_SocketDispatcher_close0(JNIEnv *env, jclass clazz,
- jobject fdo)
+Java_sun_nio_ch_SocketDispatcher_preClose0(JNIEnv *env, jclass clazz,
+ jobject fdo)
{
jint fd = fdval(env, fdo);
struct linger l;
int len = sizeof(l);
-
- if (fd != -1) {
- int result = 0;
- if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
- if (l.l_onoff == 0) {
- WSASendDisconnect(fd, NULL);
- }
- }
- result = closesocket(fd);
- if (result == SOCKET_ERROR) {
- JNU_ThrowIOExceptionWithLastError(env, "Socket close failed");
+ if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
+ if (l.l_onoff == 0) {
+ WSASendDisconnect(fd, NULL);
}
}
}
+
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_SocketDispatcher_close0(JNIEnv *env, jclass clazz,
+ jobject fdo)
+{
+ jint fd = fdval(env, fdo);
+ if (closesocket(fd) == SOCKET_ERROR) {
+ JNU_ThrowIOExceptionWithLastError(env, "Socket close failed");
+ }
+}
--- a/jdk/test/Makefile Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/Makefile Fri Mar 02 09:13:13 2012 -0800
@@ -432,14 +432,14 @@
javax/imageio javax/print sun/pisces)
$(call RunOthervmBatch)
-# Stable agentvm testruns (minus items from PROBLEM_LIST)
+# Stable othervm testruns (minus items from PROBLEM_LIST)
JDK_ALL_TARGETS += jdk_beans1
JDK_DEFAULT_TARGETS += jdk_beans1
jdk_beans1: $(call TestDirs, \
java/beans/beancontext java/beans/PropertyChangeSupport \
java/beans/Introspector java/beans/Performance \
java/beans/VetoableChangeSupport java/beans/Statement)
- $(call RunAgentvmBatch)
+ $(call RunOthervmBatch)
# Stable othervm testruns (minus items from PROBLEM_LIST)
# Using agentvm has serious problems with these tests
@@ -517,14 +517,14 @@
JDK_ALL_TARGETS += jdk_nio2
JDK_DEFAULT_TARGETS += jdk_nio2
jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \
- java/nio/channels java/nio/MappedByteBuffer)
+ java/nio/channels java/nio/MappedByteBuffer sun/nio/ch)
$(call SharedLibraryPermissions,java/nio/channels)
$(call RunAgentvmBatch)
# Stable agentvm testruns (minus items from PROBLEM_LIST)
JDK_ALL_TARGETS += jdk_nio3
JDK_DEFAULT_TARGETS += jdk_nio3
-jdk_nio3: $(call TestDirs, sun/nio)
+jdk_nio3: $(call TestDirs, java/nio/charset sun/nio/cs)
$(call RunAgentvmBatch)
# All nio tests
--- a/jdk/test/ProblemList.txt Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/ProblemList.txt Fri Mar 02 09:13:13 2012 -0800
@@ -114,83 +114,10 @@
# jdk_awt
-# None of the awt tests are using samevm, might not be worth the effort due
-# to the vm overhead not being enough to make a difference.
-# In general, the awt tests are problematic with or without samevm, and there
-# are issues with using a Xvfb display.
-
-# Fails on solaris sparc, timedout? in othervm mode
-java/awt/event/MouseEvent/AcceptExtraButton/AcceptExtraButton.java generic-all
-
-# Causes hang in samevm mode??? Solaris 11 i586
-java/awt/FullScreen/SetFSWindow/FSFrame.java generic-all
-
-# Fails on solaris 11 i586, -client, in othervm mode not sure why
-java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java generic-all
-java/awt/Focus/CloseDialogActivateOwnerTest/CloseDialogActivateOwnerTest.java generic-all
-java/awt/FontClass/FontAccess.java generic-all
-java/awt/Mixing/HWDisappear.java generic-all
-java/awt/Mixing/MixingInHwPanel.java generic-all
-java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.html generic-all
-java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java generic-all
-java/awt/Toolkit/SecurityTest/SecurityTest2.java generic-all
-java/awt/image/mlib/MlibOpsTest.java generic-all
-
-# Fails on windows, othervm mode, various errors
-java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java generic-all
-java/awt/Focus/OwnedWindowFocusIMECrashTest/OwnedWindowFocusIMECrashTest.java generic-all
-java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java generic-all
-java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Standard.java generic-all
-java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html generic-all
-java/awt/font/Threads/FontThread.java generic-all
-java/awt/print/PrinterJob/PrtException.java generic-all
-
-# Fails with windows X64, othervm, -server
-com/sun/awt/Translucency/WindowOpacity.java generic-all
-java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java generic-all
-java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html generic-all
-java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html generic-all
-java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java generic-all
-java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java generic-all
-java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java generic-all
-java/awt/Mixing/MixingOnShrinkingHWButton.java generic-all
-java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java generic-all
-
############################################################################
# jdk_beans
-# A large set of the beans tests set the security manager, which would seem
-# to indicate that a large number of them should be "othervm", yet are all
-# very small tests and could greatly benefit from a samevm test run.
-# So a large batch of beans tests are currently run with othervm mode.
-
-# Filed 6986807
-java/beans/Introspector/TestTypeResolver.java generic-all
-
-# Filed 6986813
-java/beans/Introspector/memory/Test4508780.java generic-all
-
-# Linux, some kind of problems with X11 display
-java/beans/PropertyChangeSupport/Test4682386.java generic-all
-java/beans/PropertyChangeSupport/TestSynchronization.java generic-all
-java/beans/Statement/Test4653179.java generic-all
-
-# Runs REALLY slow on Solaris sparc for some reason, both -client and -server
-java/beans/XMLEncoder/Test4625418.java solaris-sparc
-
-# Problems with samevm and setting security manager (speculation partially)
-java/beans/Introspector/4168475/Test4168475.java generic-all
-java/beans/Introspector/4520754/Test4520754.java generic-all
-java/beans/Introspector/6380849/TestBeanInfo.java generic-all
-java/beans/Introspector/Test4144543.java generic-all
-
-# Failed to call method solaris-sparc???
-java/beans/EventHandler/Test6788531.java generic-all
-
-# Jar or class not found???
-java/beans/XMLEncoder/6329581/Test6329581.java generic-all
-
############################################################################
# jdk_lang
@@ -211,78 +138,15 @@
# jdk_management
-# Failing, bug was filed: 6959636
-javax/management/loading/LibraryLoader/LibraryLoaderTest.java generic-all
-
-# Access denied messages on windows/mks, filed 6954450
-sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh windows-all
-
-# Fails on linux: KO: StringMonitor notification missed or not emitted
-javax/management/monitor/NonComparableAttributeValueTest.java generic-all
-
-# Port conflict? Fails with communication error
-sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh generic-all
-
-# Fails on Windows 2000, Test failed for iiop java.lang.NullPointerException
-# at org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(Unknown Source)
-# at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
-javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
-
-# Solaris 10 sparc, NPE from org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke
-javax/management/remote/mandatory/threads/ExecutorTest.java generic-all
-
-# Linux 32bit Fedora 9, IllegalStateException
-javax/management/monitor/RuntimeExceptionTest.java generic-all
-
-# Problems with rmi connection, othervm
-javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all
-
-# Fails with port already in use
-sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh generic-all
-
-# Fails with port already in use
-sun/management/jmxremote/bootstrap/RmiRegistrySslTest.sh generic-all
-
-# Windows, connection can't last that long
-javax/management/eventService/LeaseTest.java generic-all
+# 6959636
+javax/management/loading/LibraryLoader/LibraryLoaderTest.java windows-all
-# Linux othervm, X64, java.lang.Exception: Failed: ratio=102.4027795593753
-javax/management/remote/mandatory/notif/ListenerScaleTest.java generic-all
-
-# Windows run seems to have triggered a hotspot gc error (see 6801625)
-com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.sh generic-all
-
-# rmi problem? othervm, java.lang.reflect.UndeclaredThrowableException
-javax/management/remote/mandatory/subjectDelegation/SubjectDelegation3Test.java generic-all
-
-# Linux Fedora 9 32bit NPE in rmi server somehere??? othervm
-javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java generic-all
-
-# Times out on solaris sparc, with othervm
-javax/management/eventService/AddRemoveListenerTest.java generic-all
-
-# Linux i586 and x64 -server, timed out waiting for threads to expire? othervm
-javax/management/eventService/EventClientThreadTest.java generic-all
+# 7144846
+javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
-# Linux i586 -server, Expected to receive 20, but got 21, othervm
-# Fails on Linux X64 -server 20!=21
-javax/management/eventService/FetchingTest.java generic-all
-
-# NPE on windows 2000 i586 -client and -server
-javax/management/eventService/CustomForwarderTest.java windows-all
-
-# Windows i586 failure, callback did not complete
-javax/management/eventService/LeaseManagerDeadlockTest.java windows-all
-
-# Port already in use
-sun/management/jmxremote/bootstrap/LocalManagementTest.sh generic-all
-
-# Failed to initialize connector (also overflowing jtreg io buffers)
-sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh generic-all
-sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh generic-all
-
-# Windows X64, java.lang.IllegalStateException
-javax/management/monitor/AttributeArbitraryDataTypeTest.java generic-all
+# 7073626
+sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh windows-all
+sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh windows-all
############################################################################
@@ -298,72 +162,6 @@
# Need to be marked othervm, or changed to be samevm safe
com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
-# Need to be marked othervm, or changed to be samevm safe
-com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
-
-# Solaris sparc and others, exception in initializer
-javax/imageio/CachePremissionsTest/CachePermissionsTest.java generic-all
-
-# Leaves file rgba_* open, fails with windows samevm
-javax/imageio/plugins/png/PngOutputTypeTest.java generic-all
-
-# Suspect test.png file is left open, windows samevm problems
-javax/imageio/plugins/png/ITXtTest.java generic-all
-
-# Solaris sparc and others, failed to compile testcase
-javax/imageio/metadata/DOML3Node.java generic-all
-
-# One of these tests is leaving file IMGP1001.JPG open, windows samevm
-javax/imageio/plugins/jpeg/ConcurrentReadingTest.java generic-all
-javax/imageio/plugins/jpeg/ReadingInterruptionTest.java generic-all
-
-# One of these files is missing a close on writer_* files, windows samevm
-javax/imageio/plugins/jpeg/ConcurrentWritingTest.java generic-all
-javax/imageio/plugins/jpeg/WritingInterruptionTest.java generic-all
-
-# Leaving file test.jpg open, windows samevm
-javax/imageio/plugins/jpeg/ReadAsGrayTest.java generic-all
-
-# Missing close on file wbmp*, windows samevm
-javax/imageio/plugins/wbmp/CanDecodeTest.java generic-all
-
-# Failures on OpenSolaris, cannot read input files? samevm issues?
-javax/imageio/metadata/BooleanAttributes.java generic-all
-javax/imageio/plugins/bmp/BMPSubsamplingTest.java generic-all
-javax/imageio/plugins/bmp/TopDownTest.java generic-all
-javax/imageio/plugins/gif/EncodeSubImageTest.java generic-all
-javax/imageio/plugins/gif/GifTransparencyTest.java generic-all
-javax/imageio/plugins/png/GrayPngTest.java generic-all
-javax/imageio/plugins/png/ItxtUtf8Test.java generic-all
-javax/imageio/plugins/png/MergeStdCommentTest.java generic-all
-javax/imageio/plugins/png/ShortHistogramTest.java generic-all
-javax/imageio/plugins/shared/BitDepth.java generic-all
-
-# Exclude all javax/print tests, even if they passed, they may need samevm work
-
-# Times out on solaris-sparc, sparcv9, x64 -server, some on i586 -client
-javax/print/attribute/autosense/PrintAutoSenseData.java generic-all
-javax/print/attribute/Chroma.java generic-all
-javax/print/attribute/CollateAttr.java generic-all
-javax/print/attribute/PSCopiesFlavorTest.java generic-all
-javax/print/LookupServices.java generic-all
-javax/print/TestRaceCond.java generic-all
-
-# These tests really require a printer (might all be windows only tests?)
-javax/print/CheckDupFlavor.java generic-all
-javax/print/PrintSE/PrintSE.sh generic-all
-javax/print/attribute/ChromaticityValues.java generic-all
-javax/print/attribute/GetCopiesSupported.java generic-all
-javax/print/attribute/SidesPageRangesTest.java generic-all
-javax/print/attribute/SupportedPrintableAreas.java generic-all
-javax/print/attribute/AttributeTest.java generic-all
-
-# Only print test left, excluding just because all print tests have been
-javax/print/attribute/MediaMappingsTest.java generic-all
-
-# Filed 7058852
-javax/sound/sampled/FileWriter/AlawEncoderSync.java generic-all
-
############################################################################
# jdk_net
@@ -386,6 +184,7 @@
# failing on vista 32/64 on nightly
# 7102702
java/net/PortUnreachableException/OneExceptionOnly.java windows-all
+
############################################################################
# jdk_io
@@ -410,71 +209,11 @@
# jdk_rmi
-# Port already in use, fails on sparc, othervm
-java/rmi/reliability/benchmark/runRmiBench.sh generic-all
-
-# Already in use port issues? othervm solaris
-java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java generic-all
-java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java generic-all
-
-java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java generic-all
-java/rmi/transport/dgcDeadLock/TestImpl_Stub.java generic-all
-
-# Address already in use, othervm mode, solaris
-java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java generic-all
-java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java generic-all
-
-# Registry already running on port, solaris
-java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java generic-all
-
-# Fails on Linux 32 and 64bit -server?, impl not garbage collected???
-java/rmi/transport/pinLastArguments/PinLastArguments.java generic-all
-
-# Times out on solaris sparc
-java/rmi/server/RemoteServer/AddrInUse.java generic-all
-
-# Connection error on Windows i586 -server
-# Also connection errors in othervm on Solaris 10 sparc, same port???
-sun/rmi/transport/tcp/DeadCachedConnection.java generic-all
+# 7140992
+java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
-# Connection errors in othervm on Solaris 10 sparc, same port???
-java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all
-java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java generic-all
-java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java generic-all
-java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java generic-all
-java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java generic-all
-java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java generic-all
-java/rmi/activation/Activatable/extLoadedImpl/ext.sh generic-all
-java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java generic-all
-java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java generic-all
-java/rmi/activation/Activatable/nestedActivate/NestedActivate.java generic-all
-java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java generic-all
-java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java generic-all
-java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java generic-all
-java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java generic-all
-java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java generic-all
-java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java generic-all
-java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java generic-all
-java/rmi/reliability/juicer/AppleUserImpl.java generic-all
-java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java generic-all
-java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java generic-all
-java/rmi/transport/handshakeTimeout/HandshakeTimeout.java generic-all
-java/rmi/activation/Activatable/restartService/RestartService.java generic-all
-java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java generic-all
-java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java generic-all
-java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java generic-all
-java/rmi/activation/CommandEnvironment/SetChildEnv.java generic-all
-java/rmi/registry/classPathCodebase/ClassPathCodebase.java generic-all
-java/rmi/registry/reexport/Reexport.java generic-all
-java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
-java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java generic-all
-java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java generic-all
-java/rmi/server/useCustomRef/UseCustomRef.java generic-all
-java/rmi/transport/checkFQDN/CheckFQDN.java generic-all
-java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
-java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java generic-all
-java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java generic-all
-java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
+# 6948101
+java/rmi/transport/pinLastArguments/PinLastArguments.java generic-all
# 7132247
java/rmi/registry/readTest/readTest.sh windows-all
@@ -483,6 +222,12 @@
# jdk_security
+# 7145024
+sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java solaris-all
+
+# 7147060
+com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
+
# Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586
sun/security/pkcs11/ec/ReadCertificates.java solaris-i586
@@ -538,25 +283,23 @@
############################################################################
-# jdk_swing (not using samevm)
+# jdk_sound
-# Fails on solaris 11 i586, with othervm
-javax/swing/JFileChooser/6570445/bug6570445.java generic-all
-javax/swing/JFileChooser/6738668/bug6738668.java generic-all
-javax/swing/JPopupMenu/6675802/bug6675802.java generic-all
-javax/swing/system/6799345/TestShutdown.java generic-all
+############################################################################
+
+# jdk_swing
############################################################################
# jdk_text
-# Linux x64 occasional errors, no details
-java/text/Bidi/Bug6665028.java linux-x64
-
############################################################################
# jdk_tools
+# 6461635
+com/sun/tools/attach/BasicTests.sh generic-all
+
# Filed 6952105
com/sun/jdi/SuspendThreadTest.java generic-all
@@ -572,15 +315,16 @@
# Filed 6402201
com/sun/jdi/ProcessAttachTest.sh generic-all
-# Filed 6986875
-sun/tools/jps/jps-Vvml.sh generic-all
-
# Filed 6979016
sun/tools/jconsole/ResourceCheckTest.sh generic-all
# 7132203
sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all
+# Tests take too long, see 7143279
+tools/pack200/CommandLineTests.java generic-all
+tools/pack200/Pack200Test.java generic-all
+
############################################################################
# jdk_util
@@ -588,11 +332,6 @@
# Filed 6933803
java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
-# Filed 7022325
-# Fails with assertion error on windows
-# 11 separate stacktraces created... file reuse problem?
-java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
-
# Filed 6772009
java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
--- a/jdk/test/TEST.ROOT Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/TEST.ROOT Fri Mar 02 09:13:13 2012 -0800
@@ -4,3 +4,9 @@
# The list of keywords supported in the entire test suite
keys=2d dnd i18n
+
+# Tests that must run in othervm mode
+othervm.dirs=java/rmi sun/rmi javax/management
+
+# Tests that cannot run concurrently
+exclusiveAccess.dirs=java/rmi sun/rmi sun/management/jmxremote sun/tools/jstatd
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/ExecuteDiagnosticCommand.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 7104647
- * @summary Basic Test for HotSpotDiagnosticMXBean.execute()
- * @author Frederic Parain
- *
- * @run main ExecuteDiagnosticCommand
- */
-
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-import javax.management.MBeanServer;
-
-public class ExecuteDiagnosticCommand {
- private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
- "com.sun.management:type=HotSpotDiagnostic";
-
- public static void main(String[] args) throws Exception {
- HotSpotDiagnosticMXBean mbean =
- ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
- executeDiagnosticCommand(mbean);
-
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
- HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
- HotSpotDiagnosticMXBean.class);
- executeDiagnosticCommand(mbean);
- }
-
- private static void executeDiagnosticCommand(HotSpotDiagnosticMXBean mbean) {
- String s = mbean.execute("help help");
- System.out.println(s);
- s = mbean.execute("help", "help");
- System.out.println(s);
- String tab[] = { "help"};
- s = mbean.execute("help", tab);
- System.out.println(s);
- }
-}
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommandInfo.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 7104647
- * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommandInfo()
- * @author Frederic Parain
- *
- * @run main GetDiagnosticCommandInfo
- */
-
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.DiagnosticCommandInfo;
-import com.sun.management.DiagnosticCommandArgumentInfo;
-import com.sun.management.VMOption;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-import javax.management.MBeanServer;
-
-public class GetDiagnosticCommandInfo {
- private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
- "com.sun.management:type=HotSpotDiagnostic";
-
- public static void main(String[] args) throws Exception {
- HotSpotDiagnosticMXBean mbean =
- ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
- checkDiagnosticCommandArguments(mbean);
-
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
- HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
- HotSpotDiagnosticMXBean.class);
- checkDiagnosticCommandArguments(mbean);
- }
-
- private static void checkDiagnosticCommandArguments(HotSpotDiagnosticMXBean mbean) {
- // check getDiagnosticCommandInfo()
- StringBuilder sb = new StringBuilder();
- List<DiagnosticCommandInfo> infoList = mbean.getDiagnosticCommandInfo();
- for(DiagnosticCommandInfo info : infoList) {
- printCommandInfo(info,sb);
- }
- // check getDiagnosticCommandInfo(List<String>)
- List<String> commands = mbean.getDiagnosticCommands();
- List<DiagnosticCommandInfo> list2 =
- mbean.getDiagnosticCommandInfo(commands);
- for(DiagnosticCommandInfo info : list2) {
- printCommandInfo(info,sb);
- }
- // check getDiagnosticCommandInfo(String)
- for(String cmd : commands) {
- DiagnosticCommandInfo info2 = mbean.getDiagnosticCommandInfo(cmd);
- printCommandInfo(info2,sb);
- }
- System.out.println(sb.toString());
- }
-
- private static void printCommandInfo(DiagnosticCommandInfo info,
- StringBuilder sb) {
- sb.append("\t").append(info.getName()).append(":\n");
- sb.append("\t\tDescription=").append(info.getDescription()).append("\n");
- sb.append("\t\tImpact=").append(info.getImpact()).append("\n");
- sb.append("\t\tStatus=");
- if (info.isEnabled()) {
- sb.append("Enabled\n");
- } else {
- sb.append("Disbled\n");
- }
- sb.append("\t\tArguments=");
- for(DiagnosticCommandArgumentInfo arg : info.getArgumentsInfo()) {
- printArgumentInfo(arg,sb);
- }
- }
-
- private static void printArgumentInfo(DiagnosticCommandArgumentInfo info,
- StringBuilder sb) {
- sb.append("\t\t\t").append(info.getName()).append(":\n");
- sb.append("\t\t\t\tType=").append(info.getType()).append("\n");
- sb.append("\t\t\t\tDescription=").append(info.getDescription()).append("\n");
- if(info.getDefault() != null) {
- sb.append("\t\t\t\tDefault=").append(info.getDefault()).append("\n");
- }
- if(info.isMandatory()) {
- sb.append("\t\t\t\tMandatory\n");
- } else {
- sb.append("\t\t\t\tOptional\n");
- }
- if(info.isOption()) {
- sb.append("\t\t\t\tIs an option\n");
- } else {
- sb.append("\t\t\t\tIs an argument expected at position");
- sb.append(info.getPosition());
- sb.append("\n");
- }
- }
-}
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommands.java Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please 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 7104647
- * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommands()
- * @author Frederic Parain
- *
- * @run main GetDiagnosticCommands
- */
-
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.VMOption;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-import javax.management.MBeanServer;
-
-public class GetDiagnosticCommands {
- private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
- "com.sun.management:type=HotSpotDiagnostic";
-
- public static void main(String[] args) throws Exception {
- HotSpotDiagnosticMXBean mbean =
- ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
- checkDiagnosticCommands(mbean);
-
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
- HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
- HotSpotDiagnosticMXBean.class);
- checkDiagnosticCommands(mbean);
- }
-
- private static void checkDiagnosticCommands(HotSpotDiagnosticMXBean mbean) {
- List<String> commands = mbean.getDiagnosticCommands();
- System.out.println("Commands:");
- for (String cmd : commands) {
- System.out.println(cmd);
- }
- }
-}
--- a/jdk/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java Fri Mar 02 09:13:13 2012 -0800
@@ -96,7 +96,10 @@
// Test mouse wheel over the choice
String name = Toolkit.getDefaultToolkit().getClass().getName();
- if(!name.equals("sun.awt.X11.XToolkit")) { // mouse wheel doesn't work for the choice on X11, so skip it
+
+ // mouse wheel doesn't work for the choice on X11 and Mac, so skip it
+ if(!name.equals("sun.awt.X11.XToolkit")
+ && !name.equals("sun.lwawt.macosx.LWCToolkit")) {
robot.mouseWheel(1);
Util.waitForIdle(robot);
--- a/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Fri Mar 02 09:13:13 2012 -0800
@@ -54,9 +54,12 @@
Util.clickOnComp(frame.button, robot);
}
- frame.panel.stop();
+ boolean ret = frame.panel.stop();
frame.dispose();
+ if (!ret) {
+ throw new RuntimeException("Test failed!");
+ }
System.out.println("Test passed.");
}
@@ -140,17 +143,19 @@
}
}
- public void stop() {
+ public boolean stop() {
active = false;
try {
- synchronized (sync) {
- sync.notify();
- }
- synchronized (thread) {
- thread.wait();
+ sync();
+ thread.join(1000);
+ if (thread.isAlive()) {
+ thread.interrupt();
+ return false;
}
} catch (InterruptedException ex) {
+ return false;
}
+ return true;
}
public void draw() {
--- a/jdk/test/java/io/Serializable/expectedStackTrace/ExpectedStackTrace.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/io/Serializable/expectedStackTrace/ExpectedStackTrace.java Fri Mar 02 09:13:13 2012 -0800
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 6317435
+ * @bug 6317435 7110700
* @summary Verify that stack trace contains a proper cause of
* InvalidClassException (methods: checkSerialize,
* checkDeserialize or checkDefaultSerialize)
@@ -59,7 +59,7 @@
private static final String SER_METHOD_NAME = "checkSerializable";
public static final void main(String[] args) throws Exception {
- System.err.println("\nRegression test for CR6317435");
+ System.err.println("\nRegression test for CRs 6317435, 7110700");
checkSerializable(getObject());
}
@@ -99,9 +99,12 @@
}
}
if (found) {
+ if (ex.getCause() != null) {
+ throw new Error("\nTest for CR 7110700 FAILED");
+ }
System.err.println("\nTEST PASSED");
} else {
- throw new Error();
+ throw new Error("\nTest for CR 6317435 FAILED");
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/Math/ExactArithTests.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,266 @@
+/*
+ * 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.math.BigInteger;
+
+/**
+ * @test Test for Math.*Exact integer and long methods.
+ * @bug 6708398
+ * @summary Basic tests for Math exact arithmetic operations.
+ *
+ * @author Roger Riggs
+ */
+public class ExactArithTests {
+
+ /**
+ * The count of test errors.
+ */
+ private static int errors = 0;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ testIntegerExact();
+ testLongExact();
+
+ if (errors > 0) {
+ throw new RuntimeException(errors + " errors found in ExactArithTests.");
+ }
+ }
+
+ static void fail(String message) {
+ errors++;
+ System.err.println(message);
+ }
+
+ /**
+ * Test Math.addExact, multiplyExact, subtractExact, toIntValue methods
+ * with {@code int} arguments.
+ */
+ static void testIntegerExact() {
+ testIntegerExact(0, 0);
+ testIntegerExact(1, 1);
+ testIntegerExact(1, -1);
+ testIntegerExact(-1, 1);
+ testIntegerExact(1000, 2000);
+
+ testIntegerExact(Integer.MIN_VALUE, Integer.MIN_VALUE);
+ testIntegerExact(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testIntegerExact(Integer.MIN_VALUE, 1);
+ testIntegerExact(Integer.MAX_VALUE, 1);
+ testIntegerExact(Integer.MIN_VALUE, 2);
+ testIntegerExact(Integer.MAX_VALUE, 2);
+ testIntegerExact(Integer.MIN_VALUE, -1);
+ testIntegerExact(Integer.MAX_VALUE, -1);
+ testIntegerExact(Integer.MIN_VALUE, -2);
+ testIntegerExact(Integer.MAX_VALUE, -2);
+
+ }
+
+ /**
+ * Test exact arithmetic by comparing with the same operations using long
+ * and checking that the result is the same as the integer truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testIntegerExact(int x, int y) {
+ try {
+ // Test addExact
+ int sum = Math.addExact(x, y);
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 != sum2) {
+ fail("FAIL: int Math.addExact(" + x + " + " + y + ") = " + sum + "; expected Arithmetic exception");
+ } else if (sum != sum2) {
+ fail("FAIL: long Math.addExact(" + x + " + " + y + ") = " + sum + "; expected: " + sum2);
+ }
+ } catch (ArithmeticException ex) {
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 == sum2) {
+ fail("FAIL: int Math.addExact(" + x + " + " + y + ")" + "; Unexpected exception: " + ex);
+
+ }
+ }
+
+ try {
+ // Test subtractExact
+ int diff = Math.subtractExact(x, y);
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 != diff2) {
+ fail("FAIL: int Math.subtractExact(" + x + " - " + y + ") = " + diff + "; expected: " + diff2);
+ }
+
+ } catch (ArithmeticException ex) {
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 == diff2) {
+ fail("FAIL: int Math.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ int product = Math.multiplyExact(x, y);
+ long m2 = (long) x * (long) y;
+ if ((int) m2 != m2) {
+ fail("FAIL: int Math.multiplyExact(" + x + " * " + y + ") = " + product + "; expected: " + m2);
+ }
+ } catch (ArithmeticException ex) {
+ long m2 = (long) x * (long) y;
+ if ((int) m2 == m2) {
+ fail("FAIL: int Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Test Math.addExact, multiplyExact, subtractExact, toIntExact methods
+ * with {@code long} arguments.
+ */
+ static void testLongExact() {
+ testLongExactTwice(0, 0);
+ testLongExactTwice(1, 1);
+ testLongExactTwice(1, -1);
+ testLongExactTwice(1000, 2000);
+
+ testLongExactTwice(Long.MIN_VALUE, Long.MIN_VALUE);
+ testLongExactTwice(Long.MAX_VALUE, Long.MAX_VALUE);
+ testLongExactTwice(Long.MIN_VALUE, 1);
+ testLongExactTwice(Long.MAX_VALUE, 1);
+ testLongExactTwice(Long.MIN_VALUE, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Long.MIN_VALUE, -1);
+ testLongExactTwice(Long.MAX_VALUE, -1);
+ testLongExactTwice(Long.MIN_VALUE, -2);
+ testLongExactTwice(Long.MAX_VALUE, -2);
+ testLongExactTwice(Long.MIN_VALUE/2, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE, -Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE+1, Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MAX_VALUE+1, -Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MIN_VALUE-1, Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE-1, -Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE/2, 2);
+
+ }
+
+ /**
+ * Test each of the exact operations with the arguments and
+ * with the arguments reversed.
+ * @param x
+ * @param y
+ */
+ static void testLongExactTwice(long x, long y) {
+ testLongExact(x, y);
+ testLongExact(y, x);
+ }
+
+
+ /**
+ * Test long exact arithmetic by comparing with the same operations using BigInteger
+ * and checking that the result is the same as the long truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testLongExact(long x, long y) {
+ BigInteger resultBig = null;
+ final BigInteger xBig = BigInteger.valueOf(x);
+ final BigInteger yBig = BigInteger.valueOf(y);
+ try {
+ // Test addExact
+ resultBig = xBig.add(yBig);
+ long sum = Math.addExact(x, y);
+ checkResult("long Math.addExact", x, y, sum, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long Math.addExact(" + x + " + " + y + "); Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test subtractExact
+ resultBig = xBig.subtract(yBig);
+ long diff = Math.subtractExact(x, y);
+ checkResult("long Math.subtractExact", x, y, diff, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long Math.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ resultBig = xBig.multiply(yBig);
+ long product = Math.multiplyExact(x, y);
+ checkResult("long Math.multiplyExact", x, y, product, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test toIntExact
+ int value = Math.toIntExact(x);
+ if ((long)value != x) {
+ fail("FAIL: " + "long Math.toIntExact" + "(" + x + ") = " + value + "; expected an arithmetic exception: ");
+ }
+ } catch (ArithmeticException ex) {
+ if (resultBig.bitLength() <= 32) {
+ fail("FAIL: long Math.toIntExact(" + x + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Compare the expected and actual results.
+ * @param message message for the error
+ * @param x first argument
+ * @param y second argument
+ * @param result actual result value
+ * @param expected expected result value
+ */
+ static void checkResult(String message, long x, long y, long result, BigInteger expected) {
+ BigInteger resultBig = BigInteger.valueOf(result);
+ if (!inLongRange(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected an arithmetic exception: ");
+ } else if (!resultBig.equals(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected " + expected);
+ }
+ }
+
+ /**
+ * Check if the value fits in 64 bits (a long).
+ * @param value
+ * @return true if the value fits in 64 bits (including the sign).
+ */
+ static boolean inLongRange(BigInteger value) {
+ return value.bitLength() <= 63;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/StrictMath/ExactArithTests.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,266 @@
+/*
+ * 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.math.BigInteger;
+
+/**
+ * @test Test for StrictMath.*Exact integer and long methods.
+ * @bug 6708398
+ * @summary Basic tests for StrictMath exact arithmetic operations.
+ *
+ * @author Roger Riggs
+ */
+public class ExactArithTests {
+
+ /**
+ * The count of test errors.
+ */
+ private static int errors = 0;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ testIntegerExact();
+ testLongExact();
+
+ if (errors > 0) {
+ throw new RuntimeException(errors + " errors found in ExactArithTests.");
+ }
+ }
+
+ static void fail(String message) {
+ errors++;
+ System.err.println(message);
+ }
+
+ /**
+ * Test StrictMath.addExact, multiplyExact, subtractExact, toIntValue methods
+ * with {@code int} arguments.
+ */
+ static void testIntegerExact() {
+ testIntegerExact(0, 0);
+ testIntegerExact(1, 1);
+ testIntegerExact(1, -1);
+ testIntegerExact(-1, 1);
+ testIntegerExact(1000, 2000);
+
+ testIntegerExact(Integer.MIN_VALUE, Integer.MIN_VALUE);
+ testIntegerExact(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testIntegerExact(Integer.MIN_VALUE, 1);
+ testIntegerExact(Integer.MAX_VALUE, 1);
+ testIntegerExact(Integer.MIN_VALUE, 2);
+ testIntegerExact(Integer.MAX_VALUE, 2);
+ testIntegerExact(Integer.MIN_VALUE, -1);
+ testIntegerExact(Integer.MAX_VALUE, -1);
+ testIntegerExact(Integer.MIN_VALUE, -2);
+ testIntegerExact(Integer.MAX_VALUE, -2);
+
+ }
+
+ /**
+ * Test exact arithmetic by comparing with the same operations using long
+ * and checking that the result is the same as the integer truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testIntegerExact(int x, int y) {
+ try {
+ // Test addExact
+ int sum = StrictMath.addExact(x, y);
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 != sum2) {
+ fail("FAIL: int StrictMath.addExact(" + x + " + " + y + ") = " + sum + "; expected Arithmetic exception");
+ } else if (sum != sum2) {
+ fail("FAIL: long StrictMath.addExact(" + x + " + " + y + ") = " + sum + "; expected: " + sum2);
+ }
+ } catch (ArithmeticException ex) {
+ long sum2 = (long) x + (long) y;
+ if ((int) sum2 == sum2) {
+ fail("FAIL: int StrictMath.addExact(" + x + " + " + y + ")" + "; Unexpected exception: " + ex);
+
+ }
+ }
+
+ try {
+ // Test subtractExact
+ int diff = StrictMath.subtractExact(x, y);
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 != diff2) {
+ fail("FAIL: int StrictMath.subtractExact(" + x + " - " + y + ") = " + diff + "; expected: " + diff2);
+ }
+
+ } catch (ArithmeticException ex) {
+ long diff2 = (long) x - (long) y;
+ if ((int) diff2 == diff2) {
+ fail("FAIL: int StrictMath.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ int product = StrictMath.multiplyExact(x, y);
+ long m2 = (long) x * (long) y;
+ if ((int) m2 != m2) {
+ fail("FAIL: int StrictMath.multiplyExact(" + x + " * " + y + ") = " + product + "; expected: " + m2);
+ }
+ } catch (ArithmeticException ex) {
+ long m2 = (long) x * (long) y;
+ if ((int) m2 == m2) {
+ fail("FAIL: int StrictMath.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Test StrictMath.addExact, multiplyExact, subtractExact, toIntExact methods
+ * with {@code long} arguments.
+ */
+ static void testLongExact() {
+ testLongExactTwice(0, 0);
+ testLongExactTwice(1, 1);
+ testLongExactTwice(1, -1);
+ testLongExactTwice(1000, 2000);
+
+ testLongExactTwice(Long.MIN_VALUE, Long.MIN_VALUE);
+ testLongExactTwice(Long.MAX_VALUE, Long.MAX_VALUE);
+ testLongExactTwice(Long.MIN_VALUE, 1);
+ testLongExactTwice(Long.MAX_VALUE, 1);
+ testLongExactTwice(Long.MIN_VALUE, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Long.MIN_VALUE, -1);
+ testLongExactTwice(Long.MAX_VALUE, -1);
+ testLongExactTwice(Long.MIN_VALUE, -2);
+ testLongExactTwice(Long.MAX_VALUE, -2);
+ testLongExactTwice(Long.MIN_VALUE/2, 2);
+ testLongExactTwice(Long.MAX_VALUE, 2);
+ testLongExactTwice(Integer.MAX_VALUE, Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE, -Integer.MAX_VALUE);
+ testLongExactTwice(Integer.MAX_VALUE+1, Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MAX_VALUE+1, -Integer.MAX_VALUE+1);
+ testLongExactTwice(Integer.MIN_VALUE-1, Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE-1, -Integer.MIN_VALUE-1);
+ testLongExactTwice(Integer.MIN_VALUE/2, 2);
+
+ }
+
+ /**
+ * Test each of the exact operations with the arguments and
+ * with the arguments reversed.
+ * @param x
+ * @param y
+ */
+ static void testLongExactTwice(long x, long y) {
+ testLongExact(x, y);
+ testLongExact(y, x);
+ }
+
+
+ /**
+ * Test long exact arithmetic by comparing with the same operations using BigInteger
+ * and checking that the result is the same as the long truncation.
+ * Errors are reported with {@link fail}.
+ *
+ * @param x first parameter
+ * @param y second parameter
+ */
+ static void testLongExact(long x, long y) {
+ BigInteger resultBig = null;
+ final BigInteger xBig = BigInteger.valueOf(x);
+ final BigInteger yBig = BigInteger.valueOf(y);
+ try {
+ // Test addExact
+ resultBig = xBig.add(yBig);
+ long sum = StrictMath.addExact(x, y);
+ checkResult("long StrictMath.addExact", x, y, sum, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long StrictMath.addExact(" + x + " + " + y + "); Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test subtractExact
+ resultBig = xBig.subtract(yBig);
+ long diff = StrictMath.subtractExact(x, y);
+ checkResult("long StrictMath.subtractExact", x, y, diff, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long StrictMath.subtractExact(" + x + " - " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test multiplyExact
+ resultBig = xBig.multiply(yBig);
+ long product = StrictMath.multiplyExact(x, y);
+ checkResult("long StrictMath.multiplyExact", x, y, product, resultBig);
+ } catch (ArithmeticException ex) {
+ if (inLongRange(resultBig)) {
+ fail("FAIL: long StrictMath.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ try {
+ // Test toIntExact
+ int value = StrictMath.toIntExact(x);
+ if ((long)value != x) {
+ fail("FAIL: " + "long StrictMath.toIntExact" + "(" + x + ") = " + value + "; expected an arithmetic exception: ");
+ }
+ } catch (ArithmeticException ex) {
+ if (resultBig.bitLength() <= 32) {
+ fail("FAIL: long StrictMath.toIntExact(" + x + ")" + "; Unexpected exception: " + ex);
+ }
+ }
+
+ }
+
+ /**
+ * Compare the expected and actual results.
+ * @param message message for the error
+ * @param x first argument
+ * @param y second argument
+ * @param result actual result value
+ * @param expected expected result value
+ */
+ static void checkResult(String message, long x, long y, long result, BigInteger expected) {
+ BigInteger resultBig = BigInteger.valueOf(result);
+ if (!inLongRange(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected an arithmetic exception: ");
+ } else if (!resultBig.equals(expected)) {
+ fail("FAIL: " + message + "(" + x + ", " + y + ") = " + result + "; expected " + expected);
+ }
+ }
+
+ /**
+ * Check if the value fits in 64 bits (a long).
+ * @param value
+ * @return true if the value fits in 64 bits (including the sign).
+ */
+ static boolean inLongRange(BigInteger value) {
+ return value.bitLength() <= 63;
+ }
+}
--- a/jdk/test/java/nio/file/WatchService/Basic.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/nio/file/WatchService/Basic.java Fri Mar 02 09:13:13 2012 -0800
@@ -25,7 +25,7 @@
* @bug 4313887 6838333 7017446
* @summary Unit test for java.nio.file.WatchService
* @library ..
- * @run main/timeout=120 Basic
+ * @run main Basic
*/
import java.nio.file.*;
@@ -281,11 +281,11 @@
System.out.println("poll with timeout...");
try {
- long start = System.currentTimeMillis();
+ long start = System.nanoTime();
key = watcher.poll(3000, TimeUnit.MILLISECONDS);
if (key != null)
throw new RuntimeException("no keys registered");
- long waited = System.currentTimeMillis() - start;
+ long waited = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
if (waited < 2900)
throw new RuntimeException("poll was too short");
} catch (InterruptedException x) {
@@ -358,14 +358,14 @@
}
// assume that poll throws exception immediately
- long start = System.currentTimeMillis();
+ long start = System.nanoTime();
try {
watcher.poll(10000, TimeUnit.MILLISECONDS);
throw new RuntimeException("ClosedWatchServiceException not thrown");
} catch (InterruptedException x) {
throw new RuntimeException(x);
} catch (ClosedWatchServiceException x) {
- long waited = System.currentTimeMillis() - start;
+ long waited = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
if (waited > 5000)
throw new RuntimeException("poll was too long");
}
--- a/jdk/test/java/nio/file/WatchService/SensitivityModifier.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/nio/file/WatchService/SensitivityModifier.java Fri Mar 02 09:13:13 2012 -0800
@@ -23,9 +23,9 @@
/* @test
* @bug 4313887
- * @summary Sanity test for Sun-specific sensitivyt level watch event modifier
+ * @summary Sanity test for Sun-specific sensitivity level watch event modifier
* @library ..
- * @run main/timeout=330 Basic
+ * @run main/timeout=240 SensitivityModifier
*/
import java.nio.file.*;
@@ -96,6 +96,7 @@
// drain events (to avoid interference)
do {
+ key.pollEvents();
key.reset();
key = watcher.poll(1, TimeUnit.SECONDS);
} while (key != null);
--- a/jdk/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java Fri Mar 02 09:13:13 2012 -0800
@@ -75,10 +75,10 @@
throw new Error("Executor stuck");
// Wait for the invocation thread to complete.
- thread.join(1000);
+ thread.join(5000);
if (thread.isAlive()) {
thread.interrupt();
- thread.join(1000);
+ thread.join(5000);
throw new Error("invokeAll stuck");
}
}
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/Custom.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/Custom.java Fri Mar 02 09:13:13 2012 -0800
@@ -100,8 +100,8 @@
equal(countExecutorThreads(), threadCount);
equal(CustomTask.births.get(), threadCount);
tpe.shutdown();
- tpe.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
- Thread.sleep(10);
+ tpe.awaitTermination(120, TimeUnit.SECONDS);
+ Thread.sleep(1000);
equal(countExecutorThreads(), 0);
CustomSTPE stpe = new CustomSTPE();
@@ -110,8 +110,8 @@
equal(CustomSTPE.decorations.get(), threadCount);
equal(countExecutorThreads(), threadCount);
stpe.shutdown();
- stpe.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
- Thread.sleep(10);
+ stpe.awaitTermination(120, TimeUnit.SECONDS);
+ Thread.sleep(1000);
equal(countExecutorThreads(), 0);
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
--- a/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java Fri Mar 02 09:13:13 2012 -0800
@@ -86,7 +86,7 @@
} catch (Throwable t) { unexpected(t); }}});}
barrier.await();
es.shutdown();
- check(es.awaitTermination(10, TimeUnit.SECONDS));
+ check(es.awaitTermination(30, TimeUnit.SECONDS));
}
private static class FlakySync extends AbstractQueuedLongSynchronizer {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/CipherSpi/DirectBBRemaining.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,181 @@
+/*
+ * 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 7142509
+ * @summary Cipher.doFinal(ByteBuffer,ByteBuffer) fails to
+ * process when in.remaining() == 0
+ */
+
+import java.nio.ByteBuffer;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Random;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+/*
+ * Simple test case to show that Cipher.doFinal(ByteBuffer, ByteBuffer) fails to
+ * process the data internally buffered inBB the cipher when input.remaining()
+ * == 0 and at least one buffer is a direct buffer.
+ */
+public class DirectBBRemaining {
+
+ private static Random random = new SecureRandom();
+ private static int testSizes = 40;
+ private static int outputFrequency = 5;
+
+ public static void main(String args[]) throws Exception {
+ boolean failedOnce = false;
+ Exception failedReason = null;
+
+ byte[] keyBytes = new byte[8];
+ random.nextBytes(keyBytes);
+ SecretKey key = new SecretKeySpec(keyBytes, "DES");
+
+ Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
+ cipher.init(Cipher.ENCRYPT_MODE, key);
+
+ /*
+ * Iterate through various sizes to make sure that the code does empty
+ * blocks, single partial blocks, 1 full block, full + partial blocks,
+ * multiple full blocks, etc. 5 blocks (using DES) is probably overkill
+ * but will feel more confident the fix isn't breaking anything.
+ */
+ System.out.println("Output test results for every "
+ + outputFrequency + " tests...");
+
+ for (int size = 0; size <= testSizes; size++) {
+ boolean output = (size % outputFrequency) == 0;
+ if (output) {
+ System.out.print("\nTesting buffer size: " + size + ":");
+ }
+
+ int outSize = cipher.getOutputSize(size);
+
+ try {
+ encrypt(cipher, size,
+ ByteBuffer.allocate(size),
+ ByteBuffer.allocate(outSize),
+ ByteBuffer.allocateDirect(size),
+ ByteBuffer.allocateDirect(outSize),
+ output);
+ } catch (Exception e) {
+ System.out.print("\n Failed with size " + size);
+ failedOnce = true;
+ failedReason = e;
+
+ // If we got an exception, let's be safe for future
+ // testing and reset the cipher to a known good state.
+ cipher.init(Cipher.ENCRYPT_MODE, key);
+ }
+ }
+ if (failedOnce) {
+ throw failedReason;
+ }
+ System.out.println("\nTest Passed...");
+ }
+
+ private enum TestVariant {
+
+ HEAP_HEAP, HEAP_DIRECT, DIRECT_HEAP, DIRECT_DIRECT
+ };
+
+ private static void encrypt(Cipher cipher, int size,
+ ByteBuffer heapIn, ByteBuffer heapOut,
+ ByteBuffer directIn, ByteBuffer directOut,
+ boolean output) throws Exception {
+
+ ByteBuffer inBB = null;
+ ByteBuffer outBB = null;
+
+ // Set up data and encrypt to known/expected values.
+ byte[] testdata = new byte[size];
+ random.nextBytes(testdata);
+ byte[] expected = cipher.doFinal(testdata);
+
+ for (TestVariant tv : TestVariant.values()) {
+ if (output) {
+ System.out.print(" " + tv);
+ }
+
+ switch (tv) {
+ case HEAP_HEAP:
+ inBB = heapIn;
+ outBB = heapOut;
+ break;
+ case HEAP_DIRECT:
+ inBB = heapIn;
+ outBB = directOut;
+ break;
+ case DIRECT_HEAP:
+ inBB = directIn;
+ outBB = heapOut;
+ break;
+ case DIRECT_DIRECT:
+ inBB = directIn;
+ outBB = directOut;
+ break;
+ }
+
+ inBB.clear();
+ outBB.clear();
+
+ inBB.put(testdata);
+ inBB.flip();
+
+ // Process all data in one shot, but don't call doFinal() yet.
+ // May store up to n-1 bytes (w/block size n) internally.
+ cipher.update(inBB, outBB);
+ if (inBB.hasRemaining()) {
+ throw new Exception("buffer not empty");
+ }
+
+ // finish encryption and process all data buffered
+ cipher.doFinal(inBB, outBB);
+ outBB.flip();
+
+ // validate output size
+ if (outBB.remaining() != expected.length) {
+ throw new Exception(
+ "incomplete encryption output, expected "
+ + expected.length + " bytes but was only "
+ + outBB.remaining() + " bytes");
+ }
+
+ // validate output data
+ byte[] encrypted = new byte[outBB.remaining()];
+ outBB.get(encrypted);
+ if (!Arrays.equals(expected, encrypted)) {
+ throw new Exception("bad encryption output");
+ }
+
+ if (!Arrays.equals(cipher.doFinal(), cipher.doFinal())) {
+ throw new Exception("Internal buffers still held data!");
+ }
+ }
+ }
+}
--- a/jdk/test/javax/security/auth/x500/X500Principal/Parse.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/javax/security/auth/x500/X500Principal/Parse.java Fri Mar 02 09:13:13 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
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 7024771
+ * @bug 7024771 7024604
* @summary various X500Principal DN parsing tests
*/
@@ -32,12 +32,18 @@
public class Parse {
private static TestCase[] testCases = {
- new TestCase("CN=prefix\\<>suffix", false)
+ new TestCase("CN=prefix\\<>suffix", false),
+ new TestCase("OID.1=value", false),
+ new TestCase("oid.1=value", false),
+ new TestCase("OID.1.2=value", true),
+ new TestCase("oid.1.2=value", true),
+ new TestCase("1=value", false),
+ new TestCase("1.2=value", true)
};
public static void main(String args[]) throws Exception {
- for (int i = 0; i < testCases.length; i++) {
- testCases[i].run();
+ for (TestCase testCase : testCases) {
+ testCase.run();
}
System.out.println("Test completed ok.");
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/DataLine/DataLine_ArrayIndexOutOfBounds.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,226 @@
+/**
+ * @test
+ * @bug 7088367
+ * @summary SourceDataLine.write and TargetDataLine.read don't throw ArrayIndexOutOfBoundsException
+ * @author Alex Menkov
+ */
+
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.Line;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.Mixer;
+import javax.sound.sampled.SourceDataLine;
+import javax.sound.sampled.TargetDataLine;
+
+public class DataLine_ArrayIndexOutOfBounds {
+
+ static int total = 0;
+ static int failed = 0;
+
+ // shared buffer for all tests
+ static final byte[] buffer = new byte[5000000];
+
+ // the class describes different test scenarios (buffer properties)
+ static abstract class Scenario {
+ abstract int getBufferOffset(DataLine line);
+ abstract int getBufferLength(DataLine line);
+ }
+
+ // scenarios to tests
+ static Scenario[] scenarios = new Scenario[]{
+ new Scenario() {
+ public String toString() {
+ return "offset is near Integer.MAX_VALUE";
+ }
+ public int getBufferOffset(DataLine line) {
+ return Integer.MAX_VALUE - 4096;
+ }
+ public int getBufferLength(DataLine line) {
+ return 65536;
+ }
+ },
+ new Scenario() {
+ public String toString() {
+ return "offset is less than buffer.length, length is large";
+ }
+ int getBufferOffset(DataLine line) {
+ return buffer.length / 10;
+ }
+ int getBufferLength(DataLine line) {
+ return Integer.MAX_VALUE - getBufferOffset(line) + 4096;
+ }
+ }
+ };
+
+ public static void main(String[] args) throws Exception {
+ Mixer.Info[] infos = AudioSystem.getMixerInfo();
+ log("" + infos.length + " mixers detected");
+ for (int i=0; i<infos.length; i++) {
+ Mixer mixer = AudioSystem.getMixer(infos[i]);
+ log("Mixer " + (i+1) + ": " + infos[i]);
+ try {
+ mixer.open();
+ for (Scenario scenario: scenarios) {
+ testSDL(mixer, scenario);
+ testTDL(mixer, scenario);
+ }
+ mixer.close();
+ } catch (LineUnavailableException ex) {
+ log("LineUnavailableException: " + ex);
+ }
+ }
+ if (failed == 0) {
+ log("PASSED (" + total + " tests)");
+ } else {
+ log("FAILED (" + failed + " of " + total + " tests)");
+ throw new Exception("Test FAILED");
+ }
+ }
+
+ final static int STOPPER_DELAY = 5000; // 1 sec
+
+ static class AsyncLineStopper implements Runnable {
+ private final DataLine line;
+ private final long delayMS; // delay before stop the line
+ private final Thread thread;
+ private final Object readyEvent = new Object();
+ private final Object startEvent = new Object();
+
+ public AsyncLineStopper(DataLine line, long delayMS) {
+ this.line = line;
+ this.delayMS = delayMS;
+ thread = new Thread(this);
+ thread.setDaemon(true);
+ // starts the thread and waits until it becomes ready
+ synchronized (readyEvent) {
+ thread.start();
+ try {
+ readyEvent.wait();
+ } catch (InterruptedException ex) { }
+ }
+ }
+
+ // makes the delay and then stops the line
+ public void schedule() {
+ synchronized(startEvent) {
+ startEvent.notifyAll();
+ }
+ }
+
+ // force stop/close the line
+ public void force() {
+ thread.interrupt();
+ try {
+ thread.join();
+ } catch (InterruptedException ex) {
+ log("join exception: " + ex);
+ }
+ }
+
+ // Runnable implementation
+ public void run() {
+ try {
+ synchronized(readyEvent) {
+ readyEvent.notifyAll();
+ }
+ synchronized(startEvent) {
+ startEvent.wait();
+ }
+ // delay
+ Thread.sleep(delayMS);
+ } catch (InterruptedException ex) {
+ log(" AsyncLineStopper has been interrupted: " + ex);
+ }
+ // and flush
+ log(" stop...");
+ line.stop();
+ log(" close...");
+ line.close();
+ }
+ }
+
+ static void testSDL(Mixer mixer, Scenario scenario) {
+ log(" Testing SDL (scenario: " + scenario + ")...");
+ Line.Info linfo = new Line.Info(SourceDataLine.class);
+ SourceDataLine line = null;
+ try {
+ line = (SourceDataLine)mixer.getLine(linfo);
+ log(" got line: " + line);
+ log(" open...");
+ line.open();
+ } catch (IllegalArgumentException ex) {
+ log(" unsupported (IllegalArgumentException)");
+ return;
+ } catch (LineUnavailableException ex) {
+ log(" unavailable: " + ex);
+ return;
+ }
+
+ total++;
+
+ log(" start...");
+ line.start();
+
+ AsyncLineStopper lineStopper = new AsyncLineStopper(line, STOPPER_DELAY);
+ int offset = scenario.getBufferOffset(line);
+ int len = scenario.getBufferLength(line);
+ // ensure len represents integral number of frames
+ len -= len % line.getFormat().getFrameSize();
+
+ log(" write...");
+ lineStopper.schedule();
+ try {
+ line.write(buffer, offset, len);
+ log(" ERROR: didn't get ArrayIndexOutOfBoundsException");
+ failed++;
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ log(" OK: got ArrayIndexOutOfBoundsException: " + ex);
+ }
+ lineStopper.force();
+ }
+
+ static void testTDL(Mixer mixer, Scenario scenario) {
+ log(" Testing TDL (scenario: " + scenario + ")...");
+ Line.Info linfo = new Line.Info(TargetDataLine.class);
+ TargetDataLine line = null;
+ try {
+ line = (TargetDataLine)mixer.getLine(linfo);
+ log(" got line: " + line);
+ log(" open...");
+ line.open();
+ } catch (IllegalArgumentException ex) {
+ log(" unsupported (IllegalArgumentException)");
+ return;
+ } catch (LineUnavailableException ex) {
+ log(" unavailable: " + ex);
+ return;
+ }
+
+ total++;
+
+ log(" start...");
+ line.start();
+
+ AsyncLineStopper lineStopper = new AsyncLineStopper(line, STOPPER_DELAY);
+ int offset = scenario.getBufferOffset(line);
+ int len = scenario.getBufferLength(line);
+ // ensure len represents integral number of frames
+ len -= len % line.getFormat().getFrameSize();
+
+ log(" read...");
+ try {
+ line.read(buffer, offset, len);
+ log(" ERROR: didn't get ArrayIndexOutOfBoundsException");
+ failed++;
+ } catch (ArrayIndexOutOfBoundsException ex) {
+ log(" OK: got ArrayIndexOutOfBoundsException: " + ex);
+ }
+ lineStopper.force();
+ }
+
+ static void log(String s) {
+ System.out.println(s);
+ System.out.flush();
+ }
+}
--- a/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 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
@@ -26,28 +26,29 @@
* @bug 6396844
* @summary Tests memory leak for 20000 files
* @author Sergey Malenkov
- * @run main/othervm/timeout=1000 -mx256m TwentyThousandTest
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm/timeout=1000 -mx128m TwentyThousandTest
*/
+import sun.java2d.Disposer;
+import sun.java2d.DisposerRecord;
+
import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
import java.io.File;
import java.io.FileWriter;
-public class TwentyThousandTest implements ActionListener, Runnable {
+public class TwentyThousandTest {
private static final int FILES = 20000;
- private static final int ATTEMPTS = 100;
+ private static final int ATTEMPTS = 20;
private static final int INTERVAL = 100;
- private static final boolean ALWAYS_NEW_INSTANCE = false;
- private static final boolean UPDATE_UI_EACH_INTERVAL = true;
- private static final boolean AUTO_CLOSE_DIALOG = true;
+ private static String tmpDir;
- private static JFileChooser CHOOSER;
-
- private static String tmpDir;
+ private static volatile boolean disposerComplete;
public static void main(String[] args) throws Exception {
tmpDir = System.getProperty("java.io.tmpdir");
@@ -77,15 +78,13 @@
System.out.println("Do " + ATTEMPTS + " attempts for " + laf.getClassName());
- for ( int i = 0; i < ATTEMPTS; i++ ) {
+ for (int i = 0; i < ATTEMPTS; i++) {
System.out.print(i + " ");
doAttempt();
}
System.out.println();
-
- CHOOSER = null;
}
System.out.println("Removing " + FILES + " files");
@@ -94,7 +93,7 @@
getTempFile(i).delete();
}
- System.out.println( "Test passed successfully" );
+ System.out.println("Test passed successfully");
}
private static File getTempFile(int i) {
@@ -104,48 +103,55 @@
private static void doAttempt() throws Exception {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
- if ( ALWAYS_NEW_INSTANCE || ( CHOOSER == null ) )
- CHOOSER = new JFileChooser(tmpDir);
+ final JFileChooser chooser = new JFileChooser(tmpDir);
+
+ chooser.updateUI();
- if ( UPDATE_UI_EACH_INTERVAL )
- CHOOSER.updateUI();
+ // Postpone JFileChooser closing until it becomes visible
+ chooser.addHierarchyListener(new HierarchyListener() {
+ @Override
+ public void hierarchyChanged(HierarchyEvent e) {
+ if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
+ if (chooser.isShowing()) {
+ Thread thread = new Thread(new Runnable() {
+ public void run() {
+ try {
+ Thread.sleep(INTERVAL);
- if ( AUTO_CLOSE_DIALOG ) {
- Thread t = new Thread( new TwentyThousandTest( CHOOSER ) );
- t.start();
- CHOOSER.showOpenDialog( null );
- } else {
- CHOOSER.showOpenDialog( null );
- }
+ // Close JFileChooser
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ chooser.cancelSelection();
+ }
+ });
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ thread.start();
+ }
+ }
+ }
+ });
+
+ chooser.showOpenDialog(null);
}
});
- // Allow to collect garbage by GC
- Thread.sleep(1000);
-
- System.gc();
- }
-
- private final JFileChooser chooser;
-
- TwentyThousandTest( JFileChooser chooser ) {
- this.chooser = chooser;
- }
+ DisposerRecord disposerRecord = new DisposerRecord() {
+ public void dispose() {
+ disposerComplete = true;
+ }
+ };
- public void run() {
- while ( !this.chooser.isShowing() ) {
- try {
- Thread.sleep( 30 );
- } catch ( InterruptedException exception ) {
- exception.printStackTrace();
- }
+ disposerComplete = false;
+
+ Disposer.addRecord(new Object(), disposerRecord);
+
+ while (!disposerComplete) {
+ Util.generateOOME();
}
- Timer timer = new Timer( INTERVAL, this );
- timer.setRepeats( false );
- timer.start();
- }
-
- public void actionPerformed( ActionEvent event ) {
- this.chooser.cancelSelection();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,70 @@
+/*
+ * 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 7138665
+ @summary JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7
+ @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug7138665 {
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
+ JOptionPane.OK_CANCEL_OPTION, null, null, null);
+ pane.setWantsInput(true);
+
+ JDialog dialog = pane.createDialog(null, "My Dialog");
+ dialog.setVisible(true);
+
+ Object result = pane.getValue();
+
+ if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
+ throw new RuntimeException("Invalid result: " + result);
+ }
+
+ System.out.println("Test bug7138665 passed");
+ }
+ });
+
+ SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+ toolkit.realSync();
+
+ Robot robot = new Robot();
+
+ robot.setAutoDelay(100);
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+
+ toolkit.realSync();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JProgressBar/7141573/bug7141573.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,62 @@
+/*
+ * 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 7141573
+ @summary JProgressBar resize exception, if setStringPainted in Windows LAF
+ @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import java.awt.image.BufferedImage;
+
+public class bug7141573 {
+ public static void main(String[] args) throws Exception {
+ try {
+ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+ } catch (Exception e) {
+ System.out.println("WindowsLookAndFeel is not supported. The test bug7141573 is skipped.");
+
+ return;
+ }
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
+
+ JProgressBar bar = new JProgressBar();
+
+ bar.setStringPainted(true);
+
+ bar.setSize(100, 1);
+ bar.paint(image.getGraphics());
+
+ bar.setSize(1, 100);
+ bar.paint(image.getGraphics());
+
+ System.out.println("The test bug7141573 is passed.");
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/4314199/bug4314199.html Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,8 @@
+<html>
+<body>
+Select the last tree node (marked "Here") and click on the menu.
+Look at the vertical line connecting nodes "Bug" and "Here". If
+this line disappears when the menu drops down, test fails.
+<applet code="bug4314199.class" width=200 height=200></applet>
+</body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/4314199/bug4314199.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,92 @@
+/*
+ * 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 4314199
+ * @summary Tests that JTree repaints correctly in a container with a JMenu
+ * @author Peter Zhelezniakov
+ * @run applet/manual=yesno bug4314199.html
+ */
+
+import javax.swing.*;
+import javax.swing.tree.*;
+
+public class bug4314199 extends JApplet {
+
+ public void init() {
+
+ try {
+ UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+ SwingUtilities.invokeAndWait(new Runnable() {
+
+ public void run() {
+ createAndShowGUI();
+ }
+ });
+ } catch (final Exception e) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ createAndShowMessage("Test fails because of exception: "
+ + e.getMessage());
+ }
+ });
+ }
+
+ }
+
+ private void createAndShowMessage(String message) {
+ getContentPane().add(new JLabel(message));
+ }
+
+ private void createAndShowGUI() {
+ JMenuBar mb = new JMenuBar();
+
+ // needed to exactly align left edge of menu and angled line of tree
+ mb.add(Box.createHorizontalStrut(27));
+
+ JMenu mn = new JMenu("Menu");
+ JMenuItem mi = new JMenuItem("MenuItem");
+ mn.add(mi);
+ mb.add(mn);
+ setJMenuBar(mb);
+
+ DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("Root");
+ DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("Duke");
+ n1.add(n2);
+ DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("Bug");
+ n2.add(n3);
+ n3.add(new DefaultMutableTreeNode("Blah"));
+ n3.add(new DefaultMutableTreeNode("Blah"));
+ n3.add(new DefaultMutableTreeNode("Blah"));
+ DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("Here");
+ n2.add(n4);
+
+ JTree tree = new JTree(new DefaultTreeModel(n1));
+ tree.putClientProperty("JTree.lineStyle", "Angled");
+ tree.expandPath(new TreePath(new Object[]{n1, n2, n3}));
+ setContentPane(tree);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,72 @@
+/*
+ * 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 7142955
+ @summary DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property
+ @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class bug7142955 {
+ private static final Color TEST_COLOR = Color.RED;
+
+ public static void main(String[] args) throws Exception {
+ UIManager.put("Tree.rendererFillBackground", Boolean.FALSE);
+ UIManager.put("Tree.textBackground", TEST_COLOR);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ int w = 200;
+ int h = 100;
+
+ BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+
+ Graphics g = image.getGraphics();
+
+ g.setColor(Color.WHITE);
+ g.fillRect(0, 0, image.getWidth(), image.getHeight());
+
+ DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
+
+ renderer.setSize(w, h);
+ renderer.paint(g);
+
+ for (int y = 0; y < h; y++) {
+ for (int x = 0; x < w; x++) {
+ if (image.getRGB(x, y) == TEST_COLOR.getRGB()) {
+ throw new RuntimeException("Test bug7142955 failed");
+ }
+ }
+ }
+
+ System.out.println("Test bug7142955 passed.");
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/net/www/protocol/http/NoCache.java Fri Mar 02 09:13:13 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 7133367
+ * @summary ResponseCache.put should not be called when setUseCaches(false)
+ */
+
+import java.net.*;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+public class NoCache
+{
+ public static void main(String[] args) throws IOException {
+ ResponseCache.setDefault(new ThrowingCache());
+
+ HttpServer server = startHttpServer();
+ try {
+ URL url = new URL("http://" + InetAddress.getLocalHost().getHostAddress()
+ + ":" + server.getAddress().getPort() + "/NoCache/");
+ URLConnection uc = url.openConnection();
+ uc.setUseCaches(false);
+ uc.getInputStream().close();
+ } finally {
+ server.stop(0);
+ // clear the system-wide cache handler, samevm/agentvm mode
+ ResponseCache.setDefault(null);
+ }
+ }
+
+ static class ThrowingCache extends ResponseCache {
+ @Override
+ public CacheResponse get(URI uri, String rqstMethod,
+ Map<String,List<String>> rqstHeaders) {
+ throw new RuntimeException("ResponseCache.get should not be called");
+ }
+
+ @Override
+ public CacheRequest put(URI uri, URLConnection conn) {
+ throw new RuntimeException("ResponseCache.put should not be called");
+ }
+ }
+
+ // HTTP Server
+ static HttpServer startHttpServer() throws IOException {
+ HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0);
+ httpServer.createContext("/NoCache/", new SimpleHandler());
+ httpServer.start();
+ return httpServer;
+ }
+
+ static class SimpleHandler implements HttpHandler {
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ t.sendResponseHeaders(200, -1);
+ t.close();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/EmptyPassword.java Fri Mar 02 09:13:13 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.
+ */
+
+/*
+ * @test
+ * @bug 6879540
+ * @summary enable empty password for kerberos 5
+ * @compile -XDignore.symbol.file EmptyPassword.java
+ * @run main/othervm EmptyPassword
+ */
+
+public class EmptyPassword {
+
+ public static void main(String[] args)
+ throws Exception {
+
+ OneKDC kdc = new OneKDC("aes128-cts");
+ kdc.addPrincipal("empty", "".toCharArray());
+
+ Context c = Context.fromUserPass("empty", "".toCharArray(), false);
+ c.status();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/ktab/FileKeyTab.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,58 @@
+/*
+ * 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 7144530
+ * @summary KeyTab.getInstance(String) no longer handles keyTabNames with "file:" prefix
+ */
+import java.io.File;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.internal.ktab.KeyTab;
+
+public class FileKeyTab {
+ public static void main(String[] args) throws Exception {
+ String name = "ktab";
+ KeyTab kt = KeyTab.create(name);
+ kt.addEntry(new PrincipalName("a@A"), "x".toCharArray(), 1, true);
+ kt.save();
+ check(name);
+ check("FILE:" + name);
+
+ name = new File(name).getAbsolutePath().toString();
+
+ check(name);
+ check("FILE:" + name);
+
+ // The bug reporter uses this style, should only work for
+ // absolute path
+ check("FILE:/" + name);
+ }
+
+ static void check(String file) throws Exception {
+ System.out.println("Checking for " + file + "...");
+ KeyTab kt2 = KeyTab.getInstance(file);
+ if (kt2.isMissing()) {
+ throw new Exception("FILE:ktab cannot be loaded");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs12/Bug6415637.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,313 @@
+/*
+ * 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 6415637
+ * @summary Support PKCS#12 key stores protected with an empty password
+ */
+
+import java.io.ByteArrayInputStream;
+import java.math.BigInteger;
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPrivateCrtKey;
+
+public class Bug6415637 {
+
+ public static void main(String[] args) throws Exception {
+ check(WITH_NULL);
+ check(WITHOUT_NULL);
+ }
+
+ private static void check(String encodedBlob) throws Exception {
+ byte[] blob = new byte[encodedBlob.length() * 2];
+ for (int i = 0; i < blob.length; ) {
+ final char ch = encodedBlob.charAt(i / 2);
+ blob[i++] = (byte) (ch >> 8);
+ blob[i++] = (byte) ch;
+ }
+ KeyStore store = KeyStore.getInstance("PKCS12");
+ store.load(new ByteArrayInputStream(blob), new char[0]);
+ if (!store.aliases().nextElement().equals("test"))
+ throw new Exception("test alias not found");
+ KeyStore.PrivateKeyEntry e =
+ (KeyStore.PrivateKeyEntry) store.getEntry("test",
+ new KeyStore.PasswordProtection(new char[0]));
+ X509Certificate cert = (X509Certificate) e.getCertificateChain()[0];
+ if (!cert.getSubjectDN().toString().equals("CN=Test Key"))
+ throw new Exception("invalid certificate subject DN");
+ RSAPrivateCrtKey key = (RSAPrivateCrtKey) e.getPrivateKey();
+ if (!key.getPublicExponent().equals(BigInteger.valueOf(65537)))
+ throw new Exception("invalid public exponent");
+ }
+
+ private static final String WITH_NULL =
+ "\u3082\u097c\u0201\u0330\u8209\u3606\u092a\u8648\u86f7\u0d01" +
+ "\u0701\ua082\u0927\u0482\u0923\u3082\u091f\u3082\u0564\u0609" +
+ "\u2a86\u4886\uf70d\u0107\u01a0\u8205\u5504\u8205\u5130\u8205" +
+ "\u4d30\u8205\u4906\u0b2a\u8648\u86f7\u0d01\u0c0a\u0102\ua082" +
+ "\u04fa\u3082\u04f6\u3028\u060a\u2a86\u4886\uf70d\u010c\u0103" +
+ "\u301a\u0414\u8317\ucfd6\u89ab\uc03b\u79d6\u4c45\u1b10\uc3bd" +
+ "\u3923\ub806\u0202\u0400\u0482\u04c8\ud51d\uf953\ud79e\u92c6" +
+ "\u83c0\u92dc\ucd05\u69ab\ucc1b\ud538\u2ed9\u7796\ua426\uc14e" +
+ "\udcbf\ue541\u40be\ud264\u3b5b\uf51f\u8e1a\u892f\u2813\ucdd6" +
+ "\uf72e\uef55\u35ef\u4620\ude18\ued5e\ufae0\ubed4\uf84e\u276b" +
+ "\u3596\uc33f\ub251\ue617\u6e00\ua80f\u6c82\u4acd\u7303\u26be" +
+ "\uffb5\u1e49\u5fb1\uf87c\ua873\ue60a\u7415\u655c\u39f1\ucf16" +
+ "\u8f5c\u85c6\u4100\u4130\u565b\u649a\u60d6\u6054\u868d\u7267" +
+ "\u97a8\u8492\uc5a0\udb5e\u2880\udf55\ub0ee\ua641\u8224\u76d2" +
+ "\u9b1e\u2a67\u1e32\ue1fc\u0a77\u435b\u669f\ued00\u6c30\u963f" +
+ "\u7ee3\uc5c8\u198f\u8ede\u30e1\u015d\u1195\uc850\u3371\ub9e5" +
+ "\u6968\u84c3\ub0e4\u22b7\u2a08\u4a9d\u9166\ua9ba\ud945\u0529" +
+ "\ue1e7\u8aba\ub4ef\u7445\udc9a\ucf73\ud77b\ufafe\ue1df\u3180" +
+ "\u9585\ued73\uca40\u06b0\ufdee\u95ba\u1aa3\ubd67\ua5c1\u84b4" +
+ "\u4b50\uc1e1\u4547\ud837\u21bc\uac0d\u0a65\uebb5\u7281\ud9bc" +
+ "\u2e2c\ua9bc\u7714\u0fc0\uab41\uce09\ud5e8\u5f8c\uc35d\uba6e" +
+ "\u98a2\u95c3\u87ff\uba8c\u056a\udc9f\uf254\u3d38\uf40a\u77dd" +
+ "\u4e30\u01de\ubef7\ud288\ue59c\ua143\ub30b\ud0ae\u63b9\u138b" +
+ "\uc793\u3474\u18ca\udeed\u78d9\u2ae8\u63cc\ua5d1\u6779\u0229" +
+ "\u7b72\ucfd4\ueecb\ue167\u08c0\u7556\u181d\u8d62\uc401\ub092" +
+ "\u8cf5\ued71\uf29f\u843e\u13e1\u7e7b\uf589\u0329\u92bd\ud0e3" +
+ "\u8dcc\u7541\uf195\ueef2\u3f3a\ueb01\uf5b0\u1869\u2216\uf351" +
+ "\u488d\udffb\u6243\u1121\u9447\u8a3a\u006f\u008c\ue2b3\ued31" +
+ "\u7f57\u6492\ue02f\u6f68\u387d\u58c0\uaadf\u2ee3\uf304\u3de9" +
+ "\u9741\u47fa\udde8\ufe8a\u679a\u597d\u8c7c\u9c71\u570e\u1dbd" +
+ "\ud555\ue853\uff63\u0fcb\u4b28\u3691\u33c8\uc31f\uc510\u6cba" +
+ "\ud92c\u6462\u733a\u739e\uc792\ud861\u743e\u3bd3\u006b\u2276" +
+ "\u9fb3\u0a31\u1eb3\ub97e\u4a80\uc076\uaabc\u35a0\u678d\u17c3" +
+ "\ua225\ua77c\u7d9c\uef2d\u83e2\u6996\uba70\uf6f8\u79a1\u9399" +
+ "\uc86b\u1cc5\ub2a5\u02c1\ud676\ua274\u4933\u6c60\u6832\ub0be" +
+ "\u5354\u5af9\uae23\u0963\u722d\u9ad2\u4461\ub768\u2068\u0ccb" +
+ "\u94fd\u88ac\u0f58\u3bc0\u212d\u30c8\u8860\uf7c9\u1dde\ub6b4" +
+ "\u3549\u5bcd\ucf83\u9420\u3a40\u16ad\uc4d7\ucd87\ue73a\ue1c7" +
+ "\u21df\u7f4f\u8659\u9f79\u5b36\uf206\uac66\uc9f3\u6336\u164d" +
+ "\u9046\uf4d5\u285d\ufcd8\ubd55\u1fb9\ua533\u9101\u1e87\uc7b0" +
+ "\u64e9\u3817\u216c\u8d41\uba51\u743a\uc74e\ue4ab\u2820\u972f" +
+ "\ue191\u85b4\u0ea7\ud896\u23cf\u7df5\u1653\ua9f3\ub724\ucbc9" +
+ "\u9738\ud2f8\u464e\ucf12\u99b8\u64e0\uf03b\u8d02\u85a8\uab52" +
+ "\u8da3\uea34\ube99\ue5f8\u2b38\ub082\u399d\ue61e\u64a1\u7f90" +
+ "\u26e9\ueb74\u6107\ufe2f\u82ca\u87a5\u3028\u8e1f\ue859\u61d4" +
+ "\ud26d\u23a9\uaadc\u02a7\u8ab2\u43d4\uf6b9\udf7a\u8935\u45a4" +
+ "\ufad6\ue7e4\u92b7\u35d7\u1044\u8ed3\u74ef\uaaa9\u713f\u6ebc" +
+ "\u1158\u5e5c\u7522\ufe17\ua515\u59a1\u75dd\ue7ac\uafd9\u16a9" +
+ "\u190e\u18fc\uc041\ufc9e\u3e16\u60c4\ufe51\u6d53\ufa52\u4c08" +
+ "\uce2a\ue546\u017b\ud96b\ube18\u8cb9\udd50\ued40\u14b0\u7da1" +
+ "\u2f2c\ubf9d\uc7c7\u1b73\ua155\ucaf8\ue54d\uebb0\u160a\ubd64" +
+ "\u5ef7\ue1cf\u4633\u86c1\ubc91\u839d\ub148\u9f31\uf2b1\ud133" +
+ "\u168f\u9374\u4667\u6aa9\u0482\ua2a6\ub5c0\ud9b7\ua070\uf6bd" +
+ "\u16fe\u0f41\u986b\u3d33\u7cb9\u291d\u24f0\u704a\uc946\u10a2" +
+ "\udbcf\u6c5f\u5a83\u5507\u036e\ube9f\uf60a\u9da8\u72dd\u23c9" +
+ "\u8878\udd67\uf486\u1384\u751f\u4694\uee3c\udc2e\ud5d7\ud99a" +
+ "\u5ee2\u5455\ub82d\u1837\u336d\u5724\u635b\ubd0b\u2e7c\u92be" +
+ "\u2110\u9c0e\u1662\u43f6\u62ae\u32e3\uaea4\u1cc5\uadc0\u7511" +
+ "\u6ad4\u0228\ue399\u5741\u2050\ue31a\u7dc8\uf6db\u67bb\u994a" +
+ "\u5b5a\uaac6\u2210\u95b0\u462e\u0684\u335e\uac36\u7ab9\uab1e" +
+ "\u0b75\u0f05\u74c5\ufcb3\ua0a5\ube7e\u45f8\u92d5\u3399\u7dd6" +
+ "\uf96e\u7e01\u7823\u6690\u231c\u4c47\u2d10\u7e7f\u5eb8\u70dd" +
+ "\u98d2\u6204\u3a92\u3990\u502b\u7cdb\u952a\ufa97\uea3b\ud990" +
+ "\u436f\uf33a\u070d\u2aff\u7497\u2591\u37e4\ua590\ue7ba\u2c1e" +
+ "\u53d9\u73fa\udc53\u944f\ua3a5\u5093\u33a4\uf080\u1193\u37f2" +
+ "\u7642\ub033\u7f90\u9b44\uff89\ue6ef\u81be\u9e6e\u68a4\u5a00" +
+ "\u9232\u4372\u40aa\u2748\u229d\u534d\u316b\u6e89\ufcb7\uff2e" +
+ "\ub654\u1649\ucb13\u3c28\u4940\u43aa\uc07d\u247c\u313c\u3017" +
+ "\u0609\u2a86\u4886\uf70d\u0109\u1431\u0a1e\u0800\u7400\u6500" +
+ "\u7300\u7430\u2106\u092a\u8648\u86f7\u0d01\u0915\u3114\u0412" +
+ "\u5469\u6d65\u2031\u3330\u3833\u3132\u3234\u3236\u3437\u3082" +
+ "\u03b3\u0609\u2a86\u4886\uf70d\u0107\u06a0\u8203\ua430\u8203" +
+ "\ua002\u0100\u3082\u0399\u0609\u2a86\u4886\uf70d\u0107\u0130" +
+ "\u2806\u0a2a\u8648\u86f7\u0d01\u0c01\u0630\u1a04\u14de\ud8d8" +
+ "\ua792\uf9d9\u6875\ua51d\u98ec\udf03\uc2b6\u5100\u8a02\u0204" +
+ "\u0080\u8203\u6074\ub909\u3c60\ua522\ue4ac\u0f60\u2396\u7baa" +
+ "\ud208\ub76c\u89a5\ue4ef\u205d\u2062\u4a5b\ua684\uceae\u01b9" +
+ "\u1e7a\u6e03\ud996\u555a\u615b\uba70\u406f\u80a9\u901e\ua947" +
+ "\u5b8f\u73f3\udea3\ud8b1\u9782\uac87\u231a\udcd2\u3ef0\u3a17" +
+ "\u4092\u509f\u0e79\u4cd7\u8516\u5111\uebe1\u86e0\uc548\u5ffc" +
+ "\u9a99\u11ed\uef13\u17af\u2707\u8984\u8770\u7064\u1943\u1dd3" +
+ "\u45cf\u9f80\u65f8\u9b3e\u1f70\u6bd0\uc726\u5506\ufb20\u6bdc" +
+ "\uba8c\u0b19\ucd01\ud0f0\u7040\udf63\u48a5\udf5f\u6559\u1b33" +
+ "\ubdae\u8183\uc13f\ued10\ud6dc\ud0f0\u6a7f\ubc36\uc7ca\u320f" +
+ "\u50b8\ud422\ufd99\u8843\u65e8\ue201\u843b\u64ee\ub891\u3ba2" +
+ "\uecae\ufda0\u72d6\u8394\u2551\ufc44\u3778\u27c3\u061a\u6d3b" +
+ "\ubd80\ue010\u06df\u39e7\u3d6a\u5ae2\u93fa\u4de4\u938f\u6f27" +
+ "\ufd39\u4380\u60da\uf215\u79d4\uf6f1\ua02f\u959a\ua0ea\u1c38" +
+ "\u80e3\u2744\u7506\u54b3\u77ad\u18ce\ucfec\u555e\u7bbe\u2e2f" +
+ "\u9900\ub2ef\ua5b9\ubdf0\u5e15\ua681\u92c7\u4f86\u2e1a\ub893" +
+ "\u01fc\u01d2\ub674\uff19\u04c3\ua1a0\u2cea\u72e0\ua8f1\u1358" +
+ "\ube79\u7caa\u269d\u728a\ue435\u37bd\u6495\uc106\u8830\u9b17" +
+ "\ue16d\uef78\uae2b\u5313\u1c96\uc0ee\u3098\ud743\ucd1c\u7407" +
+ "\uf4f9\uee72\ub95e\u31e7\u6435\u0173\u0336\u93c5\u8a1b\u05b4" +
+ "\u4359\uc4be\ud92b\u8d21\u83a9\u32b7\u6433\ua9bc\u27c2\ud842" +
+ "\ua4f2\u81c5\ua86c\u2fd2\uba30\u53bd\uc277\u659f\u203b\u60e5" +
+ "\u37f7\u0984\u31c2\u838a\u2107\u5840\u6411\u1b8d\u044e\ub0b6" +
+ "\uf558\ue6d3\u62bb\u5464\uf83a\u4d5b\uf153\u9e18\ua353\ubd05" +
+ "\uf204\ud543\u037d\ue5aa\u473a\ueb13\uac19\u0494\ua08e\u76c3" +
+ "\ufbd7\u9f1c\u8ca9\u57ad\ud218\uc018\u67ac\u0ae9\ub559\ufe38" +
+ "\u5641\uec0c\ue0ee\u606c\u1989\ue5a2\uff09\u8c61\u1386\ueb51" +
+ "\u7cbd\u95cd\u80c5\u3532\u8605\u596d\u4cfd\u7797\u1e82\ud2fe" +
+ "\uad6b\ua16e\ub6cf\u8fce\ud5a9\u207f\u1d0a\udabe\uc3a6\u5633" +
+ "\u2023\u925f\u809f\uee7c\u5362\u5fd9\u8dfc\u6b5f\uc95b\u0ae9" +
+ "\u7b26\u9e5b\u97e8\u9d6e\uaf91\u6d1a\u1d19\ufc27\u0815\uccbc" +
+ "\u83d4\u2ce2\ue06e\u21a1\u88da\u09af\u9671\uc510\uac23\u398d" +
+ "\ubea2\ua9a1\uf0d3\u490d\ub94b\u7ff7\u6636\ub1fa\u9b10\u1be3" +
+ "\u179b\u6a8a\u4a6c\ude1f\u5da7\u7c02\u96ec\u70ac\u5045\udd2c" +
+ "\u9f6d\uc37d\u5ba6\u4895\ue142\u0db9\uf2dc\uba2e\ud054\ud33e" +
+ "\u1ed9\u144b\u5d85\u9156\u3a90\ue8cd\u0a01\u67f5\ua81b\u4f56" +
+ "\u99dd\u4950\ua551\uacdb\udf31\u1f05\u7169\u3231\u0071\u80ec" +
+ "\ua4e9\ud74e\u62cf\u8931\u11f1\uc925\u0319\uabd4\ufb86\u73c2" +
+ "\u1479\u005b\uf05d\u4f8d\u44e4\u942b\ud338\ud05d\u2b3b\uf6f5" +
+ "\udc0d\uf741\u798b\ud8e9\u36a5\u577b\u8a95\ud773\uffcb\u17b3" +
+ "\u7174\u9616\u9b5e\ua577\u983c\u6e7a\u6cc8\u4a04\u042b\u503e" +
+ "\ud744\ub65e\ue5de\ufa24\u8c71\u1127\ud47f\ud290\ufd4c\u5cbb" +
+ "\u0e21\u77fd\u6553\ub82b\ucb49\u41e7\u8e3d\u4539\u925d\u6ba9" +
+ "\uae47\u391c\ua79e\ub6e2\u7142\u7cb3\u02f5\u6495\u7a85\u2dea" +
+ "\u787b\u22b7\u6ec2\uea8d\uf930\u3d30\u2130\u0906\u052b\u0e03" +
+ "\u021a\u0500\u0414\ubfef\u99f5\u0bb0\uc9b3\uf96a\ue267\u6bc0" +
+ "\u0202\u6d78\ub923\u0414\u5500\u095a\u2a04\u2d7e\u708d\u9779" +
+ "\u9bdb\u2c4f\u82f2\uf89f\u0202\u0400";
+
+ private static final String WITHOUT_NULL =
+ "\u3082\u097c\u0201\u0330\u8209\u3606\u092a\u8648\u86f7\u0d01" +
+ "\u0701\ua082\u0927\u0482\u0923\u3082\u091f\u3082\u0564\u0609" +
+ "\u2a86\u4886\uf70d\u0107\u01a0\u8205\u5504\u8205\u5130\u8205" +
+ "\u4d30\u8205\u4906\u0b2a\u8648\u86f7\u0d01\u0c0a\u0102\ua082" +
+ "\u04fa\u3082\u04f6\u3028\u060a\u2a86\u4886\uf70d\u010c\u0103" +
+ "\u301a\u0414\ud258\ubbe7\ub641\ud196\u4969\u3c88\u70f1\u8c97" +
+ "\u95b1\u8bf3\u0202\u0400\u0482\u04c8\u096a\u4686\uf519\u61da" +
+ "\u1b3b\uebfd\u89b1\u044b\u3bd8\u79a7\ud022\ud880\ud173\ucde1" +
+ "\ud2c1\u2c5d\u8ebb\u6bd4\u46db\ub90b\u04b9\ub091\ud1f3\ud468" +
+ "\u3e93\u2c88\uca5a\u1c54\u5342\u1eca\u8565\ubbbd\ua022\u1ead" +
+ "\ud0bb\u1a8c\u69cf\uf0f4\ucbfb\u488a\ube99\uf190\ue01c\ud87d" +
+ "\u78ca\u9e5c\u82f9\u76ad\u811f\u37d0\u272b\u0481\u500c\u0a27" +
+ "\u08d3\ub637\u3e39\u6db1\ubcba\ue354\u6924\ua9d5\u3555\u20d6" +
+ "\u4c6b\u3189\u5f91\u382c\uf351\u4de2\ubade\u2a14\uea84\u16b6" +
+ "\uf7f7\u36de\ubba6\ue952\u5f5d\u8243\u2318\ucf3d\u8ac8\u33d3" +
+ "\u706c\ue3db\u6619\u7935\u7300\u89b3\u0bcd\uca9f\u0333\ua450" +
+ "\u1be1\u3e42\ub465\uced5\ub055\u5843\uf40f\ua0f2\u6fea\u94fa" +
+ "\ua51e\u4b5d\u93c9\ucb2e\u977e\uafd9\u2a2f\u784b\u0320\u5550" +
+ "\u273f\u469f\uc42b\u2ce7\uedea\u4e0d\u54a5\u1a25\u4fac\ue346" +
+ "\u2102\u7ab6\uea86\u554f\u7706\u8a80\uf6dd\u04f8\u3b37\u005a" +
+ "\u4562\u2ef8\u59f9\u32b7\u31c0\ue7dc\ucbde\ue0e1\u2fd9\u0960" +
+ "\u3e7a\ub4e5\u2a58\u1e2b\uef14\u9a44\u5444\u806d\uc475\u12ab" +
+ "\ucc3d\ua03b\ubd52\ubf1c\ua9a6\u58aa\uee8b\u96c2\ud0c9\ua029" +
+ "\u1db4\ub118\u4807\uecaa\ue182\uabb7\ud9ed\u66c5\u2c80\uc6a6" +
+ "\u3f54\ubc73\u2632\ue1b0\u0d74\u001c\u5740\uc74b\ufadb\u25b4" +
+ "\ua10e\u3191\u69e6\u0861\u452b\u955c\uac56\ud3c4\u86b7\u45f8" +
+ "\u777a\uc336\u8cc7\ud471\u76b6\u11d8\ueb84\u14e4\uf44f\uc9ff" +
+ "\u8929\u0d84\ubcfe\u8cc2\u9d07\u94e6\u1cf9\u19b5\u773a\u012d" +
+ "\u0453\u4ff3\u40f2\ub144\ufc80\u571c\u0e13\uf890\u9fed\u2045" +
+ "\u7baf\ufd88\u4920\u2b86\u491d\uecf8\ua5d9\u1e12\u48c7\u2c84" +
+ "\u3fbe\u4df5\u11ce\u7b81\u83fc\u3efa\u697d\u1f3d\u8d81\u01b0" +
+ "\u0bf1\u9012\u697f\u3b25\u3574\u5286\udded\u5be0\u7e92\u0a02" +
+ "\ua486\ud19b\ue0b5\ua05c\u5ac2\u0ad5\u0d04\ua763\ub5c8\uf7e6" +
+ "\u6e77\u2df3\ub9e7\uda30\ufccb\u7642\u5dc1\udf1f\uc922\uff69" +
+ "\u4471\u4749\u937a\ud77d\u7c0d\u917c\uf2ef\u122c\u13b2\u8943" +
+ "\u33aa\uad59\u86e8\u21c4\ueaa0\uf200\ue5f3\u6da0\ue8ef\uce7e" +
+ "\u37b2\u3ddf\u0480\u08fc\uf89a\ud927\u3f5b\u75d3\ubdfe\u6ebd" +
+ "\ufab1\u9f54\u1c20\u625b\u1391\u2af0\u43ba\u4395\udf22\u299e" +
+ "\uf3bf\u7750\u5f68\u0120\u0ee0\u6960\ud939\u621f\uf845\u0025" +
+ "\ue33c\u7ed9\ueadf\u0005\u6306\u7274\u5e67\ucf7a\uf3c6\u7371" +
+ "\u487b\u79d7\u2142\ubc1a\ubfe4\u3536\u15db\ufe23\u4352\u6321" +
+ "\u329d\uc251\u84c8\ufc0e\uc0ca\u5be6\uf530\u0177\ud9cb\ud132" +
+ "\uf752\u3f26\uda90\ud9cf\u2e46\u3e09\u5d9a\u6902\udb3e\ub06c" +
+ "\u722d\uf498\u3e93\u6cae\u43b5\u535a\u1cd1\uf0b2\u8d80\u9e53" +
+ "\ue02e\uf782\u01ce\u5063\u73d1\u5571\uf0e7\ufa22\u7e48\u0c31" +
+ "\u4642\u29fd\udcab\ue8d4\u7a77\u0880\u4855\u88c7\u7aa5\u0d9c" +
+ "\uf8b7\uc91c\u127d\u2dd7\ude53\u9d3f\u132b\u965c\ubc80\udd97" +
+ "\u87bf\ua0e8\ub2a2\u4e1f\u98fd\u72f3\u16ea\uc415\u5be3\ue8df" +
+ "\u5681\u1f11\u4e3a\uac5d\u1684\u6602\ueb14\u0a96\ufcef\uaebf" +
+ "\u1f2e\ud1a9\u435c\uf4e5\ub6b4\uaae2\u8244\u96a4\u0d3a\u752f" +
+ "\uce21\u1bc9\u219e\uf17b\ud95e\ucd12\u1b0a\ucb85\ub0cd\u4ecb" +
+ "\u6bb4\u5f7c\u2a93\ubb24\u9d7c\u6822\u80cd\u3f54\u78ad\u4fde" +
+ "\ud57f\uec1d\ub54c\u0d78\u5946\u84c1\ua9ad\u0dea\u0292\ub279" +
+ "\u1c76\u817e\ub910\ub1fa\ub1c0\u839d\u9eca\u6f83\u8211\u4112" +
+ "\u440c\u4fbd\u6ef2\u897d\udfa9\ude9e\u1aef\u0f21\u26fb\uaca4" +
+ "\u637e\ub072\u264f\ud24d\u9357\uc801\u0b84\u2d34\ueddf\u6063" +
+ "\udc5d\u90dd\u5c62\ufb48\u8c5e\u7c4e\u3bdb\ub590\u7a75\udbd1" +
+ "\udd78\uc8be\u5915\u7c8b\u8874\u578d\u3116\ub65a\uab8e\ud2ef" +
+ "\u5d35\ubf8b\u2828\u8983\ua790\uedcf\u9698\ue023\u5786\u627b" +
+ "\u9037\u1db7\u900e\u1f45\u0001\u7cf8\u14fd\ue437\u0dfd\ucacc" +
+ "\u5edf\u1742\u7f6e\u612a\ud57d\udca0\u73a4\ud601\uc7f0\uca0e" +
+ "\u5a44\u00b4\u233a\u84f2\u95b5\u5f16\uc291\u04fb\u369d\u6b99" +
+ "\ue127\u493f\u66be\u86e9\u9672\u2849\u64a7\u851b\ue420\u8491" +
+ "\ueb07\u6563\uc753\uc28e\ucad5\uec05\u6920\u8955\u5605\u25f6" +
+ "\u6193\ubee5\u7a1a\ub73d\ucc27\uc8ce\u7179\u57c1\u7a2a\u37c1" +
+ "\ua6c7\u2d8a\u4025\uc97d\u8c9d\u7b4b\u1ad5\uc6d7\u50fc\u246d" +
+ "\u91a9\ua55d\u677a\udc83\u04c7\u3e14\u9950\u420c\udf02\u749b" +
+ "\ude88\u5459\u2074\ua4ae\ud12d\uaf60\uba98\u630d\u313c\u3017" +
+ "\u0609\u2a86\u4886\uf70d\u0109\u1431\u0a1e\u0800\u7400\u6500" +
+ "\u7300\u7430\u2106\u092a\u8648\u86f7\u0d01\u0915\u3114\u0412" +
+ "\u5469\u6d65\u2031\u3330\u3833\u3132\u3431\u3138\u3238\u3082" +
+ "\u03b3\u0609\u2a86\u4886\uf70d\u0107\u06a0\u8203\ua430\u8203" +
+ "\ua002\u0100\u3082\u0399\u0609\u2a86\u4886\uf70d\u0107\u0130" +
+ "\u2806\u0a2a\u8648\u86f7\u0d01\u0c01\u0630\u1a04\u14af\ud4f5" +
+ "\u0ff4\u0ede\u0da0\u6cc5\ufd9d\u3502\uae5e\u4cef\u3102\u0204" +
+ "\u0080\u8203\u6028\ua7e6\u088b\u56b6\uf453\u9747\u68ec\uc064" +
+ "\u2254\u693f\u25c5\uaa39\u3d87\uc97c\uc558\u5194\u7553\ude3a" +
+ "\u4575\u9d85\ud843\u2bd0\ua2e8\u244f\u8593\uac84\u54b4\ubdc6" +
+ "\ucea6\uba1a\ud3da\ua510\uee9d\uaf31\ub5c2\u3329\u0fed\u0e08" +
+ "\u426b\u46fe\udcc5\u0979\ua9ed\u3123\u9a50\ud222\u3fc0\u771a" +
+ "\u6f55\u9664\ud56f\u6b03\u6020\u78a4\u63b2\ue35e\u0816\u43a7" +
+ "\u1909\u52e1\u8183\u1b8d\u9f5b\u19e4\uad73\u8461\ucc86\u3b49" +
+ "\u322e\ue9d9\u3c66\uea22\u091e\u6621\ua8bf\u0169\u72d0\u535e" +
+ "\u77dc\u1002\ubded\u7a91\u6cee\u58fa\uc295\uae8e\ue009\uabe9" +
+ "\u6638\ucaea\u8bbf\uca27\udef5\u2881\u72ec\u8aa5\u582b\u9d6e" +
+ "\u26bb\u3c70\u8bd6\uf5ec\u34ae\ua967\u5bb1\u22cb\u4b74\u0e50" +
+ "\u5062\uc6f7\u7cb4\u58a3\uf43d\u57c0\u9654\u2f9c\u9308\u4546" +
+ "\u6f4a\u37fe\u8d5d\u1465\u8621\u4cd8\u68d6\u0456\u96a4\ud3e2" +
+ "\u76d1\u2675\u7654\u7649\u10e9\u9d0e\u8b04\uffb6\u020a\u2eb4" +
+ "\uf24f\u150e\u7f0d\uf41b\u2c76\u538f\uc2df\u79dc\u0472\u1119" +
+ "\uc148\ue2e8\u1820\ucd45\u08a7\u6bcd\u6eb0\ubd0a\ufff4\uec28" +
+ "\u819b\u2adb\uefc8\ue8f7\ue233\u6535\uc938\u9771\u3681\u87cf" +
+ "\u3a24\u4c71\ue1df\u3e19\u259c\uae5b\u27ed\u8a67\uf3e6\u7af0" +
+ "\u48e1\uc542\uc471\ud8f4\ue317\u46e9\u0b4f\uec45\ua1d3\u2b88" +
+ "\u8a22\udda1\u7c1a\u273c\ua0f7\u8bac\u3771\u28d2\u6ef8\u28d2" +
+ "\ud83c\u196f\ue3fd\u9c79\u4305\u01b8\u3490\u0a91\ue4f3\uebc6" +
+ "\u25a2\u7dd2\u72db\u7531\ucfca\u432f\u2beb\uc649\uf9c5\uc533" +
+ "\u9f3a\ua611\u935c\ubca6\ud293\u54d6\u0dd1\u0aff\u82fb\u2d69" +
+ "\u3da0\u3b33\u0986\u45b3\u3353\ub968\u7348\u454f\u9117\ub3dc" +
+ "\ud7af\u06ca\ua34a\u9357\ue22f\uad3d\u4c76\ub386\ua8d7\u2a90" +
+ "\u6d17\u9321\u7b00\u21e4\u1994\u9d18\u6439\u04c8\u8282\ub269" +
+ "\uf786\u75c6\ua505\u983a\ua075\uffa0\ud662\u6ae5\ub126\u96d1" +
+ "\u9e5e\u346b\ub7ee\ub0a3\u4ee8\ud204\u77ec\u2325\u5da8\ua326" +
+ "\ua018\u0fd8\ue50e\u93cc\ucc40\u2d89\u2ffb\u54e0\u091a\u19fd" +
+ "\u45d7\uc0ab\u77a2\u66ae\u794b\u6644\u21c3\ud782\u1e9e\u53e5" +
+ "\u782e\u55e8\ud44e\u93e8\u379e\u5aa8\u353b\u95de\u7bc1\ucaf3" +
+ "\u5223\ub5e9\uacbb\ub86b\u6014\u0626\ue7ad\ufd93\ue43a\ud864" +
+ "\u1e6d\u14b2\ua12a\u94c5\u2ed9\ua7f7\u14f4\u0cbd\uca3b\u7c21" +
+ "\ua85a\uf834\u6c99\ue1aa\u3832\u2515\u8170\u3c93\u7def\u94fe" +
+ "\u9c3d\u4ab0\u73ed\u6c72\u8b94\ua407\uc719\uad1e\u6306\u4167" +
+ "\u921e\uae53\u3fd4\uf569\u6f0b\u82b0\u0ca6\ud61f\ud526\u23c9" +
+ "\u168d\u4baf\ucc4f\ud8a2\uc64a\ud649\u55e3\u7019\u8f20\u680c" +
+ "\u5581\u2cb1\ub3a4\u3e37\u5fd3\ua3ca\uc115\u979c\uf910\u3797" +
+ "\u05cb\u51d6\u74a4\uc5c0\u597b\uf27f\ud5e2\ue8ac\u4f3d\uc0c3" +
+ "\u9594\u7799\u6876\ub1a3\u059a\uff03\uc2ee\uc8c2\uf224\u3720" +
+ "\u9177\uabdb\u9202\u18d8\uffbe\u0516\u2a76\uedb5\ufe9e\u6d65" +
+ "\u4c35\ue4cb\u75aa\u02be\ud24c\ua482\ufc67\ue4f9\u70c7\u3567" +
+ "\ufc3f\uaa89\ue80a\u6507\u0a65\u4e18\uf919\u071d\u423c\u1756" +
+ "\u30e5\u37f3\u19b3\u10fb\u6c30\u3d30\u2130\u0906\u052b\u0e03" +
+ "\u021a\u0500\u0414\ufd05\u4444\ud347\u673c\u6da4\udb7c\u0733" +
+ "\ud7bf\ud263\uc6b2\u0414\udd17\u155e\u2d4c\u25cb\ua028\u1a23" +
+ "\ub8b0\uf6be\u925f\ude3a\u0202\u0400";
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/certpath/X509CertPath/ForwardBuildCompromised.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,312 @@
+/*
+ * 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 7123519
+ * @summary Problem with java/classes_security
+ */
+
+import java.net.*;
+import java.util.*;
+import java.io.*;
+import javax.net.ssl.*;
+import java.security.KeyStore;
+import java.security.cert.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+public class ForwardBuildCompromised {
+ // DigiNotar Root CA, untrusted root certificate
+ static String trustedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1\n" +
+ "MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE\n" +
+ "ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j\n" +
+ "b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF\n" +
+ "bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg\n" +
+ "U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA\n" +
+ "A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/\n" +
+ "I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3\n" +
+ "wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC\n" +
+ "AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb\n" +
+ "oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5\n" +
+ "BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p\n" +
+ "dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk\n" +
+ "MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp\n" +
+ "b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu\n" +
+ "dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0\n" +
+ "MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi\n" +
+ "E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa\n" +
+ "MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI\n" +
+ "hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN\n" +
+ "95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd\n" +
+ "2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, untrusted cross-certificate
+ static String untrustedCrossCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFSDCCBLGgAwIBAgIERpwsrzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA3\n" +
+ "MjYxNTU3MzlaFw0xMzA4MjYxNjI3MzlaMF8xCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxGjAYBgNVBAMTEURpZ2lOb3RhciBSb290IENBMSAwHgYJKoZI\n" +
+ "hvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +
+ "ADCCAgoCggIBAKywWMEAvdghCAsrmv5uVjAFnxt3kBBBXMMNhxF3joHxynzpjGrt\n" +
+ "OHQ1u9rf+bvACTe0lnOBfTMamDn3k2+Vfz25sXWHulFI6ItwPpUExdi2wxbZiLCx\n" +
+ "hx1w2oa0DxSLes8Q0XQ2ohJ7d4ZKeeZ73wIRaKVOhq40WJskE3hWIiUeAYtLUXH7\n" +
+ "gsxZlmmIWmhTxbkNAjfLS7xmSpB+KgsFB+0WX1WQddhGyRuD4gi+8SPMmR3WKg+D\n" +
+ "IBVYJ4Iu+uIiwkmxuQGBap1tnUB3aHZOISpthECFTnaZfILz87cCWdQmARuO361T\n" +
+ "BtGuGN3isjrL14g4jqxbKbkZ05j5GAPPSIKGZgsbaQ/J6ziIeiYaBUyS1yTUlvKs\n" +
+ "Ui2jR9VS9j/+zoQGcKaqPqLytlY0GFei5IFt58rwatPHkWsCg0F8Fe9rmmRe49A8\n" +
+ "5bHre12G+8vmd0nNo2Xc97mcuOQLX5PPzDAaMhzOHGOVpfnq4XSLnukrqTB7oBgf\n" +
+ "DhgL5Vup09FsHgdnj5FLqYq80maqkwGIspH6MVzVpsFSCAnNCmOi0yKm6KHZOQaX\n" +
+ "9W6NApCMFHs/gM0bnLrEWHIjr7ZWn8Z6QjMpBz+CyeYfBQ3NTCg2i9PIPhzGiO9e\n" +
+ "7olk6R3r2ol+MqZp0d3MiJ/R0MlmIdwGZ8WUepptYkx9zOBkgLKeR46jAgMBAAGj\n" +
+ "ggEmMIIBIjASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMB\n" +
+ "BggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMDMGCCsGAQUF\n" +
+ "BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD\n" +
+ "VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9zZXJ2ZXIxLmNy\n" +
+ "bDAdBgNVHQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wCwYDVR0PBAQDAgEGMB8G\n" +
+ "A1UdIwQYMBaAFPAXYhNVPbP/CgBr+1CEl/PtYtAaMBkGCSqGSIb2fQdBAAQMMAob\n" +
+ "BFY3LjEDAgCBMA0GCSqGSIb3DQEBBQUAA4GBAEa6RcDNcEIGUlkDJUY/pWTds4zh\n" +
+ "xbVkp3wSmpwPFhx5fxTyF4HD2L60jl3aqjTB7gPpsL2Pk5QZlNsi3t4UkCV70UOd\n" +
+ "ueJRN3o/LOtk4+bjXY2lC0qTHbN80VMLqPjmaf9ghSA9hwhskdtMgRsgfd90q5QP\n" +
+ "ZFdYf+hthc3m6IcJ\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, compromised certificate
+ static String compromisedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFijCCA3KgAwIBAgIQDHbanJEMTiye/hXQWJM8TDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDcwNTE2MTcxOTM2WhcNMjUwMzMxMTgxOTIxWjBfMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdpTm90YXIgUm9vdCBDQTEg\n" +
+ "MB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmwwggIiMA0GCSqGSIb3DQEB\n" +
+ "AQUAA4ICDwAwggIKAoICAQCssFjBAL3YIQgLK5r+blYwBZ8bd5AQQVzDDYcRd46B\n" +
+ "8cp86Yxq7Th0Nbva3/m7wAk3tJZzgX0zGpg595NvlX89ubF1h7pRSOiLcD6VBMXY\n" +
+ "tsMW2YiwsYcdcNqGtA8Ui3rPENF0NqISe3eGSnnme98CEWilToauNFibJBN4ViIl\n" +
+ "HgGLS1Fx+4LMWZZpiFpoU8W5DQI3y0u8ZkqQfioLBQftFl9VkHXYRskbg+IIvvEj\n" +
+ "zJkd1ioPgyAVWCeCLvriIsJJsbkBgWqdbZ1Ad2h2TiEqbYRAhU52mXyC8/O3AlnU\n" +
+ "JgEbjt+tUwbRrhjd4rI6y9eIOI6sWym5GdOY+RgDz0iChmYLG2kPyes4iHomGgVM\n" +
+ "ktck1JbyrFIto0fVUvY//s6EBnCmqj6i8rZWNBhXouSBbefK8GrTx5FrAoNBfBXv\n" +
+ "a5pkXuPQPOWx63tdhvvL5ndJzaNl3Pe5nLjkC1+Tz8wwGjIczhxjlaX56uF0i57p\n" +
+ "K6kwe6AYHw4YC+VbqdPRbB4HZ4+RS6mKvNJmqpMBiLKR+jFc1abBUggJzQpjotMi\n" +
+ "puih2TkGl/VujQKQjBR7P4DNG5y6xFhyI6+2Vp/GekIzKQc/gsnmHwUNzUwoNovT\n" +
+ "yD4cxojvXu6JZOkd69qJfjKmadHdzIif0dDJZiHcBmfFlHqabWJMfczgZICynkeO\n" +
+ "owIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" +
+ "HQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wDQYJKoZIhvcNAQEFBQADggIBADsC\n" +
+ "jcs8MOhuoK3yc7NfniUTBAXT9uOLuwt5zlPe5JbF0a9zvNXD0EBVfEB/zRtfCdXy\n" +
+ "fJ9oHbtdzno5wozWmHvFg1Wo1X1AyuAe94leY12hE8JdiraKfADzI8PthV9xdvBo\n" +
+ "Y6pFITlIYXg23PFDk9Qlx/KAZeFTAnVR/Ho67zerhChXDNjU1JlWbOOi/lmEtDHo\n" +
+ "M/hklJRRl6s5xUvt2t2AC298KQ3EjopyDedTFLJgQT2EkTFoPSdE2+Xe9PpjRchM\n" +
+ "Ppj1P0G6Tss3DbpmmPHdy59c91Q2gmssvBNhl0L4eLvMyKKfyvBovWsdst+Nbwed\n" +
+ "2o5nx0ceyrm/KkKRt2NTZvFCo+H0Wk1Ya7XkpDOtXHAd3ODy63MUkZoDweoAZbwH\n" +
+ "/M8SESIsrqC9OuCiKthZ6SnTGDWkrBFfGbW1G/8iSlzGeuQX7yCpp/Q/rYqnmgQl\n" +
+ "nQ7KN+ZQ/YxCKQSa7LnPS3K94gg2ryMvYuXKAdNw23yCIywWMQzGNgeQerEfZ1jE\n" +
+ "O1hZibCMjFCz2IbLaKPECudpSyDOwR5WS5WpI2jYMNjD67BVUc3l/Su49bsRn1NU\n" +
+ "9jQZjHkJNsphFyUXC4KYcwx3dMPVDceoEkzHp1RxRy4sGn3J4ys7SN4nhKdjNrN9\n" +
+ "j6BkOSQNPXuHr2ZcdBtLc7LljPCGmbjlxd+Ewbfr\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Public CA 2025, intermediate certificate
+ static String intermediateCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIGAzCCA+ugAwIBAgIQHn16Uz1FMEGWQA9xSB9FBDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDYwMjA2MTYwNzAyWhcNMjUwMzI4MTYwNzAyWjBmMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdpTm90YXIgUHVibGljIENB\n" +
+ "IDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5vdGFyLm5sMIIBIjANBgkq\n" +
+ "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs/2eu/I5fMG8lbvPph3e8zfJpZQtg/72\n" +
+ "Yx29+ivtKehiF6A3n785XyoY6IT3vlCrhy1CbMOY3M0x1n4YQlv17B0XZ/DqHyBA\n" +
+ "SQvnDNbkM9j4NoSy/sRtGsP6PetIFFjrhE9whZuvuSUC1PY4PruEEJp8zOCx4+wU\n" +
+ "Zt9xvjy4Xra+bSia5rwccQ/R5FYTGKrYCthOy9C9ud5Fhd++rlVhgdA/78w+Cs2s\n" +
+ "xS4i0MAxG75P3/e/bATJKepbydHdDjkyz9o3RW/wdPUXhzEw4EwUjYg6XJrDzMad\n" +
+ "6aL9M/eaxDjgz6o48EaWRDrGptaE2uJRuErVz7oOO0p/wYKq/BU+/wIDAQABo4IB\n" +
+ "sjCCAa4wOgYIKwYBBQUHAQEELjAsMCoGCCsGAQUFBzABhh5odHRwOi8vdmFsaWRh\n" +
+ "dGlvbi5kaWdpbm90YXIubmwwHwYDVR0jBBgwFoAUiGi/4I41xDs4a2L3KDuEgcgM\n" +
+ "100wEgYDVR0TAQH/BAgwBgEB/wIBADCBxgYDVR0gBIG+MIG7MIG4Bg5ghBABh2kB\n" +
+ "AQEBBQIGBDCBpTAnBggrBgEFBQcCARYbaHR0cDovL3d3dy5kaWdpbm90YXIubmwv\n" +
+ "Y3BzMHoGCCsGAQUFBwICMG4abENvbmRpdGlvbnMsIGFzIG1lbnRpb25lZCBvbiBv\n" +
+ "dXIgd2Vic2l0ZSAod3d3LmRpZ2lub3Rhci5ubCksIGFyZSBhcHBsaWNhYmxlIHRv\n" +
+ "IGFsbCBvdXIgcHJvZHVjdHMgYW5kIHNlcnZpY2VzLjBDBgNVHR8EPDA6MDigNqA0\n" +
+ "hjJodHRwOi8vc2VydmljZS5kaWdpbm90YXIubmwvY3JsL3Jvb3QvbGF0ZXN0Q1JM\n" +
+ "LmNybDAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFN8zwK+S/jf8ttgWFtDZsZHV\n" +
+ "+m6lMA0GCSqGSIb3DQEBBQUAA4ICAQCfV1rmBd9QStEyQ40lT0tqby0/3ez0STuJ\n" +
+ "ESBQLQD56XYdb4VFSuqA6xTtiuSVHLoiv2xyISN9FvX3A5VtifkJ00JEaLQJiSsE\n" +
+ "wGDkYGl1DT7SsqtAVKdMAuCM+e0j0/RV3hZ6kcrM7/wFccHwM+/TiurR9lgZDzB4\n" +
+ "a7++A4XrYyKx9vc9ZwBEnD1nrAe7++gg9cuZgP7e+QL0FBHMjpw+gnCDjr2dzBZC\n" +
+ "4r+b8SOqlbPRPexBuNghlc7PfcPIyFis2LJXDRMWiAd3TcfdALwRsuKMR/T+cwyr\n" +
+ "asy69OEGHplLT57otQ524BDctDXNzlH9bHEh52QzqkWvIDqs42910IUy1nYNPIUG\n" +
+ "yYJV/T7H8Jb6vfMZWe47iUFvtNZCi8+b542gRUwdi+ca+hGviBC9Qr4Wv1pl7CBQ\n" +
+ "Hy1axTkHiQawUo/hgmoetCpftugl9yJTfvsBorUV1ZMxn9B1JLSGtWnbUsFRla7G\n" +
+ "fNa0IsUkzmmha8XCzvNu0d1PDGtcQyUqmDOE1Hx4cIBeuF8ipuIXkrVCr9zAZ4ZC\n" +
+ "hgz6aA1gDTW8whSRJqYEYEQ0pcMEFLyXE+Nz3O8NinO2AuxqKhjMk13203xA7lPY\n" +
+ "MnBQ0v7S3qqbp/pvPMiUhOz/VaYted6QmOY5EATBnFiLCuw87JXoAyp382eJ3WX1\n" +
+ "hOiR4IX9Tg==\n" +
+ "-----END CERTIFICATE-----";
+
+ // The fraudulent certificate issued by above compromised CA
+ static String targetCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFKDCCBBCgAwIBAgIQBeLmpM0J6lTWZbB1/iKiVjANBgkqhkiG9w0BAQUFADBm\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdp\n" +
+ "Tm90YXIgUHVibGljIENBIDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5v\n" +
+ "dGFyLm5sMB4XDTExMDcxMDE5MDYzMFoXDTEzMDcwOTE5MDYzMFowajELMAkGA1UE\n" +
+ "BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxFjAUBgNVBAcTDU1vdW50YWluIFZp\n" +
+ "ZXcxFzAVBgNVBAUTDlBLMDAwMjI5MjAwMDAyMRUwEwYDVQQDEwwqLmdvb2dsZS5j\n" +
+ "b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNbeKubCV0aCxhOiOS\n" +
+ "CSQ/w9HXTYuD5BLKuiqXNw3setdTymeJz2L8aWOHo3nicFNDVwWTgwWomGNr2J6Q\n" +
+ "7g1iINNSW0rR4E1l2szRkcnAY6c6i/Eke93nF4i2hDsnIBveolF5yjpuRm73uQQD\n" +
+ "ulHjA3BFRF/PTi0fw2/Yt+8ieoMuNcMWN6Eou5Gqt5YZkWv176ofeCbsBmMrP87x\n" +
+ "OhhtTDckCapk4VQZG2XrfzZcV6tdzCp5TI8uHdu17cdzXm1imZ8tyvzFeiCEOQN8\n" +
+ "vPNzB/fIr3CJQ5q4uM5aKT3DD5PeVzf4rfJKQNgCTWiIBc9XcWEUuszwAsnmg7e2\n" +
+ "EJRdAgMBAAGjggHMMIIByDA6BggrBgEFBQcBAQQuMCwwKgYIKwYBBQUHMAGGHmh0\n" +
+ "dHA6Ly92YWxpZGF0aW9uLmRpZ2lub3Rhci5ubDAfBgNVHSMEGDAWgBTfM8Cvkv43\n" +
+ "/LbYFhbQ2bGR1fpupTAJBgNVHRMEAjAAMIHGBgNVHSAEgb4wgbswgbgGDmCEEAGH\n" +
+ "aQEBAQIEAQICMIGlMCcGCCsGAQUFBwIBFhtodHRwOi8vd3d3LmRpZ2lub3Rhci5u\n" +
+ "bC9jcHMwegYIKwYBBQUHAgIwbhpsQ29uZGl0aW9ucywgYXMgbWVudGlvbmVkIG9u\n" +
+ "IG91ciB3ZWJzaXRlICh3d3cuZGlnaW5vdGFyLm5sKSwgYXJlIGFwcGxpY2FibGUg\n" +
+ "dG8gYWxsIG91ciBwcm9kdWN0cyBhbmQgc2VydmljZXMuMEkGA1UdHwRCMEAwPqA8\n" +
+ "oDqGOGh0dHA6Ly9zZXJ2aWNlLmRpZ2lub3Rhci5ubC9jcmwvcHVibGljMjAyNS9s\n" +
+ "YXRlc3RDUkwuY3JsMA4GA1UdDwEB/wQEAwIEsDAbBgNVHREEFDASgRBhZG1pbkBn\n" +
+ "b29nbGUuY29tMB0GA1UdDgQWBBQHSn0WJzIo0eMBMQUNsMqN6eF/7TANBgkqhkiG\n" +
+ "9w0BAQUFAAOCAQEAAs5dL7N9wzRJkI4Aq4lC5t8j5ZadqnqUcgYLADzSv4ExytNH\n" +
+ "UY2nH6iVTihC0UPSsILWraoeApdT7Rphz/8DLQEBRGdeKWAptNM3EbiXtQaZT2uB\n" +
+ "pidL8UoafX0kch3f71Y1scpBEjvu5ZZLnjg0A8AL0tnsereOVdDpU98bKqdbbrnM\n" +
+ "FRmBlSf7xdaNca6JJHeEpga4E9Ty683CmccrSGXdU2tTCuHEJww+iOAUtPIZcsum\n" +
+ "U7/eYeY1pMyGLyIjbNgRY7nDzRwvM/BsbL9eh4/mSQj/4nncqJd22sVQpCggQiVK\n" +
+ "baB2sVGcVNBkK55bT8gPqnx8JypubyUvayzZGg==\n" +
+ "-----END CERTIFICATE-----";
+
+ public static void main(String args[]) throws Exception {
+
+ Exception reservedException = null;
+ try {
+ build();
+ } catch (CertPathBuilderException cpbe) {
+ reservedException = cpbe;
+ }
+
+ if (reservedException == null) {
+ throw new Exception("Unable to block fraudulent certificate");
+ }
+
+ System.out.println(
+ "The expected untrusted cert exception: " + reservedException);
+ }
+
+ private static X509CertSelector generateSelector() throws Exception {
+
+ // generate certificate from cert strings
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ X509Certificate target = null;
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(targetCertStr.getBytes())) {
+ target = (X509Certificate)cf.generateCertificate(is);
+ }
+
+ X509CertSelector selector = new X509CertSelector();
+ selector.setCertificate(target);
+
+ return selector;
+ }
+
+
+ private static CertStore generateCertificateStore() throws Exception {
+
+ // generate certificate from cert strings
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ // generate certification path
+ Set<Certificate> entries = new HashSet();
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(targetCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(intermediateCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(compromisedCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(untrustedCrossCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ return CertStore.getInstance("Collection",
+ new CollectionCertStoreParameters(entries));
+ }
+
+ private static Set<TrustAnchor> generateTrustAnchors()
+ throws CertificateException, IOException {
+ // generate certificate from cert string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ Certificate trustedCert = null;
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(trustedCertStr.getBytes())) {
+ trustedCert = cf.generateCertificate(is);
+ }
+
+ // generate a trust anchor
+ TrustAnchor anchor =
+ new TrustAnchor((X509Certificate)trustedCert, null);
+
+ return Collections.singleton(anchor);
+ }
+
+ private static void build() throws Exception {
+ X509CertSelector selector = generateSelector();
+ Set<TrustAnchor> anchors = generateTrustAnchors();
+ CertStore certs = generateCertificateStore();
+
+ PKIXBuilderParameters params =
+ new PKIXBuilderParameters(anchors, selector);
+ params.addCertStore(certs);
+ params.setRevocationEnabled(false);
+ params.setDate(new Date(111, 11, 25)); // 2011-12-25
+
+ CertPathBuilder builder = CertPathBuilder.getInstance("PKIX");
+ PKIXCertPathBuilderResult result =
+ (PKIXCertPathBuilderResult)builder.build(params);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/certpath/X509CertPath/ReverseBuildCompromised.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,315 @@
+/*
+ * 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 7123519
+ * @summary Problem with java/classes_security
+ */
+
+import java.net.*;
+import java.util.*;
+import java.io.*;
+import javax.net.ssl.*;
+import java.security.KeyStore;
+import java.security.cert.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+import sun.security.provider.certpath.SunCertPathBuilderParameters;
+
+public class ReverseBuildCompromised {
+ // DigiNotar Root CA, untrusted root certificate
+ static String trustedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1\n" +
+ "MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE\n" +
+ "ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j\n" +
+ "b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF\n" +
+ "bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg\n" +
+ "U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA\n" +
+ "A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/\n" +
+ "I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3\n" +
+ "wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC\n" +
+ "AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb\n" +
+ "oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5\n" +
+ "BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p\n" +
+ "dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk\n" +
+ "MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp\n" +
+ "b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu\n" +
+ "dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0\n" +
+ "MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi\n" +
+ "E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa\n" +
+ "MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI\n" +
+ "hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN\n" +
+ "95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd\n" +
+ "2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, untrusted cross-certificate
+ static String untrustedCrossCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFSDCCBLGgAwIBAgIERpwsrzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA3\n" +
+ "MjYxNTU3MzlaFw0xMzA4MjYxNjI3MzlaMF8xCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxGjAYBgNVBAMTEURpZ2lOb3RhciBSb290IENBMSAwHgYJKoZI\n" +
+ "hvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +
+ "ADCCAgoCggIBAKywWMEAvdghCAsrmv5uVjAFnxt3kBBBXMMNhxF3joHxynzpjGrt\n" +
+ "OHQ1u9rf+bvACTe0lnOBfTMamDn3k2+Vfz25sXWHulFI6ItwPpUExdi2wxbZiLCx\n" +
+ "hx1w2oa0DxSLes8Q0XQ2ohJ7d4ZKeeZ73wIRaKVOhq40WJskE3hWIiUeAYtLUXH7\n" +
+ "gsxZlmmIWmhTxbkNAjfLS7xmSpB+KgsFB+0WX1WQddhGyRuD4gi+8SPMmR3WKg+D\n" +
+ "IBVYJ4Iu+uIiwkmxuQGBap1tnUB3aHZOISpthECFTnaZfILz87cCWdQmARuO361T\n" +
+ "BtGuGN3isjrL14g4jqxbKbkZ05j5GAPPSIKGZgsbaQ/J6ziIeiYaBUyS1yTUlvKs\n" +
+ "Ui2jR9VS9j/+zoQGcKaqPqLytlY0GFei5IFt58rwatPHkWsCg0F8Fe9rmmRe49A8\n" +
+ "5bHre12G+8vmd0nNo2Xc97mcuOQLX5PPzDAaMhzOHGOVpfnq4XSLnukrqTB7oBgf\n" +
+ "DhgL5Vup09FsHgdnj5FLqYq80maqkwGIspH6MVzVpsFSCAnNCmOi0yKm6KHZOQaX\n" +
+ "9W6NApCMFHs/gM0bnLrEWHIjr7ZWn8Z6QjMpBz+CyeYfBQ3NTCg2i9PIPhzGiO9e\n" +
+ "7olk6R3r2ol+MqZp0d3MiJ/R0MlmIdwGZ8WUepptYkx9zOBkgLKeR46jAgMBAAGj\n" +
+ "ggEmMIIBIjASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMB\n" +
+ "BggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMDMGCCsGAQUF\n" +
+ "BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD\n" +
+ "VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9zZXJ2ZXIxLmNy\n" +
+ "bDAdBgNVHQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wCwYDVR0PBAQDAgEGMB8G\n" +
+ "A1UdIwQYMBaAFPAXYhNVPbP/CgBr+1CEl/PtYtAaMBkGCSqGSIb2fQdBAAQMMAob\n" +
+ "BFY3LjEDAgCBMA0GCSqGSIb3DQEBBQUAA4GBAEa6RcDNcEIGUlkDJUY/pWTds4zh\n" +
+ "xbVkp3wSmpwPFhx5fxTyF4HD2L60jl3aqjTB7gPpsL2Pk5QZlNsi3t4UkCV70UOd\n" +
+ "ueJRN3o/LOtk4+bjXY2lC0qTHbN80VMLqPjmaf9ghSA9hwhskdtMgRsgfd90q5QP\n" +
+ "ZFdYf+hthc3m6IcJ\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, compromised certificate
+ static String compromisedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFijCCA3KgAwIBAgIQDHbanJEMTiye/hXQWJM8TDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDcwNTE2MTcxOTM2WhcNMjUwMzMxMTgxOTIxWjBfMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdpTm90YXIgUm9vdCBDQTEg\n" +
+ "MB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmwwggIiMA0GCSqGSIb3DQEB\n" +
+ "AQUAA4ICDwAwggIKAoICAQCssFjBAL3YIQgLK5r+blYwBZ8bd5AQQVzDDYcRd46B\n" +
+ "8cp86Yxq7Th0Nbva3/m7wAk3tJZzgX0zGpg595NvlX89ubF1h7pRSOiLcD6VBMXY\n" +
+ "tsMW2YiwsYcdcNqGtA8Ui3rPENF0NqISe3eGSnnme98CEWilToauNFibJBN4ViIl\n" +
+ "HgGLS1Fx+4LMWZZpiFpoU8W5DQI3y0u8ZkqQfioLBQftFl9VkHXYRskbg+IIvvEj\n" +
+ "zJkd1ioPgyAVWCeCLvriIsJJsbkBgWqdbZ1Ad2h2TiEqbYRAhU52mXyC8/O3AlnU\n" +
+ "JgEbjt+tUwbRrhjd4rI6y9eIOI6sWym5GdOY+RgDz0iChmYLG2kPyes4iHomGgVM\n" +
+ "ktck1JbyrFIto0fVUvY//s6EBnCmqj6i8rZWNBhXouSBbefK8GrTx5FrAoNBfBXv\n" +
+ "a5pkXuPQPOWx63tdhvvL5ndJzaNl3Pe5nLjkC1+Tz8wwGjIczhxjlaX56uF0i57p\n" +
+ "K6kwe6AYHw4YC+VbqdPRbB4HZ4+RS6mKvNJmqpMBiLKR+jFc1abBUggJzQpjotMi\n" +
+ "puih2TkGl/VujQKQjBR7P4DNG5y6xFhyI6+2Vp/GekIzKQc/gsnmHwUNzUwoNovT\n" +
+ "yD4cxojvXu6JZOkd69qJfjKmadHdzIif0dDJZiHcBmfFlHqabWJMfczgZICynkeO\n" +
+ "owIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" +
+ "HQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wDQYJKoZIhvcNAQEFBQADggIBADsC\n" +
+ "jcs8MOhuoK3yc7NfniUTBAXT9uOLuwt5zlPe5JbF0a9zvNXD0EBVfEB/zRtfCdXy\n" +
+ "fJ9oHbtdzno5wozWmHvFg1Wo1X1AyuAe94leY12hE8JdiraKfADzI8PthV9xdvBo\n" +
+ "Y6pFITlIYXg23PFDk9Qlx/KAZeFTAnVR/Ho67zerhChXDNjU1JlWbOOi/lmEtDHo\n" +
+ "M/hklJRRl6s5xUvt2t2AC298KQ3EjopyDedTFLJgQT2EkTFoPSdE2+Xe9PpjRchM\n" +
+ "Ppj1P0G6Tss3DbpmmPHdy59c91Q2gmssvBNhl0L4eLvMyKKfyvBovWsdst+Nbwed\n" +
+ "2o5nx0ceyrm/KkKRt2NTZvFCo+H0Wk1Ya7XkpDOtXHAd3ODy63MUkZoDweoAZbwH\n" +
+ "/M8SESIsrqC9OuCiKthZ6SnTGDWkrBFfGbW1G/8iSlzGeuQX7yCpp/Q/rYqnmgQl\n" +
+ "nQ7KN+ZQ/YxCKQSa7LnPS3K94gg2ryMvYuXKAdNw23yCIywWMQzGNgeQerEfZ1jE\n" +
+ "O1hZibCMjFCz2IbLaKPECudpSyDOwR5WS5WpI2jYMNjD67BVUc3l/Su49bsRn1NU\n" +
+ "9jQZjHkJNsphFyUXC4KYcwx3dMPVDceoEkzHp1RxRy4sGn3J4ys7SN4nhKdjNrN9\n" +
+ "j6BkOSQNPXuHr2ZcdBtLc7LljPCGmbjlxd+Ewbfr\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Public CA 2025, intermediate certificate
+ static String intermediateCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIGAzCCA+ugAwIBAgIQHn16Uz1FMEGWQA9xSB9FBDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDYwMjA2MTYwNzAyWhcNMjUwMzI4MTYwNzAyWjBmMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdpTm90YXIgUHVibGljIENB\n" +
+ "IDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5vdGFyLm5sMIIBIjANBgkq\n" +
+ "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs/2eu/I5fMG8lbvPph3e8zfJpZQtg/72\n" +
+ "Yx29+ivtKehiF6A3n785XyoY6IT3vlCrhy1CbMOY3M0x1n4YQlv17B0XZ/DqHyBA\n" +
+ "SQvnDNbkM9j4NoSy/sRtGsP6PetIFFjrhE9whZuvuSUC1PY4PruEEJp8zOCx4+wU\n" +
+ "Zt9xvjy4Xra+bSia5rwccQ/R5FYTGKrYCthOy9C9ud5Fhd++rlVhgdA/78w+Cs2s\n" +
+ "xS4i0MAxG75P3/e/bATJKepbydHdDjkyz9o3RW/wdPUXhzEw4EwUjYg6XJrDzMad\n" +
+ "6aL9M/eaxDjgz6o48EaWRDrGptaE2uJRuErVz7oOO0p/wYKq/BU+/wIDAQABo4IB\n" +
+ "sjCCAa4wOgYIKwYBBQUHAQEELjAsMCoGCCsGAQUFBzABhh5odHRwOi8vdmFsaWRh\n" +
+ "dGlvbi5kaWdpbm90YXIubmwwHwYDVR0jBBgwFoAUiGi/4I41xDs4a2L3KDuEgcgM\n" +
+ "100wEgYDVR0TAQH/BAgwBgEB/wIBADCBxgYDVR0gBIG+MIG7MIG4Bg5ghBABh2kB\n" +
+ "AQEBBQIGBDCBpTAnBggrBgEFBQcCARYbaHR0cDovL3d3dy5kaWdpbm90YXIubmwv\n" +
+ "Y3BzMHoGCCsGAQUFBwICMG4abENvbmRpdGlvbnMsIGFzIG1lbnRpb25lZCBvbiBv\n" +
+ "dXIgd2Vic2l0ZSAod3d3LmRpZ2lub3Rhci5ubCksIGFyZSBhcHBsaWNhYmxlIHRv\n" +
+ "IGFsbCBvdXIgcHJvZHVjdHMgYW5kIHNlcnZpY2VzLjBDBgNVHR8EPDA6MDigNqA0\n" +
+ "hjJodHRwOi8vc2VydmljZS5kaWdpbm90YXIubmwvY3JsL3Jvb3QvbGF0ZXN0Q1JM\n" +
+ "LmNybDAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFN8zwK+S/jf8ttgWFtDZsZHV\n" +
+ "+m6lMA0GCSqGSIb3DQEBBQUAA4ICAQCfV1rmBd9QStEyQ40lT0tqby0/3ez0STuJ\n" +
+ "ESBQLQD56XYdb4VFSuqA6xTtiuSVHLoiv2xyISN9FvX3A5VtifkJ00JEaLQJiSsE\n" +
+ "wGDkYGl1DT7SsqtAVKdMAuCM+e0j0/RV3hZ6kcrM7/wFccHwM+/TiurR9lgZDzB4\n" +
+ "a7++A4XrYyKx9vc9ZwBEnD1nrAe7++gg9cuZgP7e+QL0FBHMjpw+gnCDjr2dzBZC\n" +
+ "4r+b8SOqlbPRPexBuNghlc7PfcPIyFis2LJXDRMWiAd3TcfdALwRsuKMR/T+cwyr\n" +
+ "asy69OEGHplLT57otQ524BDctDXNzlH9bHEh52QzqkWvIDqs42910IUy1nYNPIUG\n" +
+ "yYJV/T7H8Jb6vfMZWe47iUFvtNZCi8+b542gRUwdi+ca+hGviBC9Qr4Wv1pl7CBQ\n" +
+ "Hy1axTkHiQawUo/hgmoetCpftugl9yJTfvsBorUV1ZMxn9B1JLSGtWnbUsFRla7G\n" +
+ "fNa0IsUkzmmha8XCzvNu0d1PDGtcQyUqmDOE1Hx4cIBeuF8ipuIXkrVCr9zAZ4ZC\n" +
+ "hgz6aA1gDTW8whSRJqYEYEQ0pcMEFLyXE+Nz3O8NinO2AuxqKhjMk13203xA7lPY\n" +
+ "MnBQ0v7S3qqbp/pvPMiUhOz/VaYted6QmOY5EATBnFiLCuw87JXoAyp382eJ3WX1\n" +
+ "hOiR4IX9Tg==\n" +
+ "-----END CERTIFICATE-----";
+
+ // The fraudulent certificate issued by above compromised CA
+ static String targetCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFKDCCBBCgAwIBAgIQBeLmpM0J6lTWZbB1/iKiVjANBgkqhkiG9w0BAQUFADBm\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdp\n" +
+ "Tm90YXIgUHVibGljIENBIDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5v\n" +
+ "dGFyLm5sMB4XDTExMDcxMDE5MDYzMFoXDTEzMDcwOTE5MDYzMFowajELMAkGA1UE\n" +
+ "BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxFjAUBgNVBAcTDU1vdW50YWluIFZp\n" +
+ "ZXcxFzAVBgNVBAUTDlBLMDAwMjI5MjAwMDAyMRUwEwYDVQQDEwwqLmdvb2dsZS5j\n" +
+ "b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNbeKubCV0aCxhOiOS\n" +
+ "CSQ/w9HXTYuD5BLKuiqXNw3setdTymeJz2L8aWOHo3nicFNDVwWTgwWomGNr2J6Q\n" +
+ "7g1iINNSW0rR4E1l2szRkcnAY6c6i/Eke93nF4i2hDsnIBveolF5yjpuRm73uQQD\n" +
+ "ulHjA3BFRF/PTi0fw2/Yt+8ieoMuNcMWN6Eou5Gqt5YZkWv176ofeCbsBmMrP87x\n" +
+ "OhhtTDckCapk4VQZG2XrfzZcV6tdzCp5TI8uHdu17cdzXm1imZ8tyvzFeiCEOQN8\n" +
+ "vPNzB/fIr3CJQ5q4uM5aKT3DD5PeVzf4rfJKQNgCTWiIBc9XcWEUuszwAsnmg7e2\n" +
+ "EJRdAgMBAAGjggHMMIIByDA6BggrBgEFBQcBAQQuMCwwKgYIKwYBBQUHMAGGHmh0\n" +
+ "dHA6Ly92YWxpZGF0aW9uLmRpZ2lub3Rhci5ubDAfBgNVHSMEGDAWgBTfM8Cvkv43\n" +
+ "/LbYFhbQ2bGR1fpupTAJBgNVHRMEAjAAMIHGBgNVHSAEgb4wgbswgbgGDmCEEAGH\n" +
+ "aQEBAQIEAQICMIGlMCcGCCsGAQUFBwIBFhtodHRwOi8vd3d3LmRpZ2lub3Rhci5u\n" +
+ "bC9jcHMwegYIKwYBBQUHAgIwbhpsQ29uZGl0aW9ucywgYXMgbWVudGlvbmVkIG9u\n" +
+ "IG91ciB3ZWJzaXRlICh3d3cuZGlnaW5vdGFyLm5sKSwgYXJlIGFwcGxpY2FibGUg\n" +
+ "dG8gYWxsIG91ciBwcm9kdWN0cyBhbmQgc2VydmljZXMuMEkGA1UdHwRCMEAwPqA8\n" +
+ "oDqGOGh0dHA6Ly9zZXJ2aWNlLmRpZ2lub3Rhci5ubC9jcmwvcHVibGljMjAyNS9s\n" +
+ "YXRlc3RDUkwuY3JsMA4GA1UdDwEB/wQEAwIEsDAbBgNVHREEFDASgRBhZG1pbkBn\n" +
+ "b29nbGUuY29tMB0GA1UdDgQWBBQHSn0WJzIo0eMBMQUNsMqN6eF/7TANBgkqhkiG\n" +
+ "9w0BAQUFAAOCAQEAAs5dL7N9wzRJkI4Aq4lC5t8j5ZadqnqUcgYLADzSv4ExytNH\n" +
+ "UY2nH6iVTihC0UPSsILWraoeApdT7Rphz/8DLQEBRGdeKWAptNM3EbiXtQaZT2uB\n" +
+ "pidL8UoafX0kch3f71Y1scpBEjvu5ZZLnjg0A8AL0tnsereOVdDpU98bKqdbbrnM\n" +
+ "FRmBlSf7xdaNca6JJHeEpga4E9Ty683CmccrSGXdU2tTCuHEJww+iOAUtPIZcsum\n" +
+ "U7/eYeY1pMyGLyIjbNgRY7nDzRwvM/BsbL9eh4/mSQj/4nncqJd22sVQpCggQiVK\n" +
+ "baB2sVGcVNBkK55bT8gPqnx8JypubyUvayzZGg==\n" +
+ "-----END CERTIFICATE-----";
+
+ public static void main(String args[]) throws Exception {
+
+ Exception reservedException = null;
+ try {
+ build();
+ } catch (CertPathBuilderException cpbe) {
+ reservedException = cpbe;
+ }
+
+ if (reservedException == null) {
+ throw new Exception("Unable to block fraudulent certificate");
+ }
+
+ System.out.println(
+ "The expected untrusted cert exception: " + reservedException);
+ }
+
+ private static X509CertSelector generateSelector() throws Exception {
+
+ // generate certificate from cert strings
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ X509Certificate target = null;
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(targetCertStr.getBytes())) {
+ target = (X509Certificate)cf.generateCertificate(is);
+ }
+
+ X509CertSelector selector = new X509CertSelector();
+ selector.setCertificate(target);
+ selector.setSubject(target.getSubjectX500Principal());
+
+ return selector;
+ }
+
+
+ private static CertStore generateCertificateStore() throws Exception {
+
+ // generate certificate from cert strings
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ // generate certification path
+ Set<Certificate> entries = new HashSet();
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(targetCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(intermediateCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(compromisedCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(untrustedCrossCertStr.getBytes())) {
+ entries.add(cf.generateCertificate(is));
+ }
+
+ return CertStore.getInstance("Collection",
+ new CollectionCertStoreParameters(entries));
+ }
+
+ private static Set<TrustAnchor> generateTrustAnchors()
+ throws CertificateException, IOException {
+ // generate certificate from cert string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ Certificate trustedCert = null;
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(trustedCertStr.getBytes())) {
+ trustedCert = cf.generateCertificate(is);
+ }
+
+ // generate a trust anchor
+ TrustAnchor anchor =
+ new TrustAnchor((X509Certificate)trustedCert, null);
+
+ return Collections.singleton(anchor);
+ }
+
+ private static void build() throws Exception {
+ X509CertSelector selector = generateSelector();
+ Set<TrustAnchor> anchors = generateTrustAnchors();
+ CertStore certs = generateCertificateStore();
+
+ SunCertPathBuilderParameters params =
+ new SunCertPathBuilderParameters(anchors, selector);
+ params.setBuildForward(false);
+ params.addCertStore(certs);
+ params.setRevocationEnabled(false);
+ params.setDate(new Date(111, 11, 25)); // 2011-12-25
+
+ CertPathBuilder builder = CertPathBuilder.getInstance("PKIX");
+ PKIXCertPathBuilderResult result =
+ (PKIXCertPathBuilderResult)builder.build(params);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/provider/certpath/X509CertPath/ValidateCompromised.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,297 @@
+/*
+ * 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 7123519
+ * @summary Problem with java/classes_security
+ */
+
+import java.net.*;
+import java.util.*;
+import java.io.*;
+import javax.net.ssl.*;
+import java.security.KeyStore;
+import java.security.cert.*;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+public class ValidateCompromised {
+ // DigiNotar Root CA, untrusted root certificate
+ static String trustedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1\n" +
+ "MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE\n" +
+ "ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j\n" +
+ "b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF\n" +
+ "bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg\n" +
+ "U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA\n" +
+ "A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/\n" +
+ "I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3\n" +
+ "wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC\n" +
+ "AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb\n" +
+ "oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5\n" +
+ "BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p\n" +
+ "dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk\n" +
+ "MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp\n" +
+ "b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu\n" +
+ "dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0\n" +
+ "MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi\n" +
+ "E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa\n" +
+ "MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI\n" +
+ "hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN\n" +
+ "95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd\n" +
+ "2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, untrusted cross-certificate
+ static String untrustedCrossCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFSDCCBLGgAwIBAgIERpwsrzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA3\n" +
+ "MjYxNTU3MzlaFw0xMzA4MjYxNjI3MzlaMF8xCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxGjAYBgNVBAMTEURpZ2lOb3RhciBSb290IENBMSAwHgYJKoZI\n" +
+ "hvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +
+ "ADCCAgoCggIBAKywWMEAvdghCAsrmv5uVjAFnxt3kBBBXMMNhxF3joHxynzpjGrt\n" +
+ "OHQ1u9rf+bvACTe0lnOBfTMamDn3k2+Vfz25sXWHulFI6ItwPpUExdi2wxbZiLCx\n" +
+ "hx1w2oa0DxSLes8Q0XQ2ohJ7d4ZKeeZ73wIRaKVOhq40WJskE3hWIiUeAYtLUXH7\n" +
+ "gsxZlmmIWmhTxbkNAjfLS7xmSpB+KgsFB+0WX1WQddhGyRuD4gi+8SPMmR3WKg+D\n" +
+ "IBVYJ4Iu+uIiwkmxuQGBap1tnUB3aHZOISpthECFTnaZfILz87cCWdQmARuO361T\n" +
+ "BtGuGN3isjrL14g4jqxbKbkZ05j5GAPPSIKGZgsbaQ/J6ziIeiYaBUyS1yTUlvKs\n" +
+ "Ui2jR9VS9j/+zoQGcKaqPqLytlY0GFei5IFt58rwatPHkWsCg0F8Fe9rmmRe49A8\n" +
+ "5bHre12G+8vmd0nNo2Xc97mcuOQLX5PPzDAaMhzOHGOVpfnq4XSLnukrqTB7oBgf\n" +
+ "DhgL5Vup09FsHgdnj5FLqYq80maqkwGIspH6MVzVpsFSCAnNCmOi0yKm6KHZOQaX\n" +
+ "9W6NApCMFHs/gM0bnLrEWHIjr7ZWn8Z6QjMpBz+CyeYfBQ3NTCg2i9PIPhzGiO9e\n" +
+ "7olk6R3r2ol+MqZp0d3MiJ/R0MlmIdwGZ8WUepptYkx9zOBkgLKeR46jAgMBAAGj\n" +
+ "ggEmMIIBIjASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMB\n" +
+ "BggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMDMGCCsGAQUF\n" +
+ "BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD\n" +
+ "VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9zZXJ2ZXIxLmNy\n" +
+ "bDAdBgNVHQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wCwYDVR0PBAQDAgEGMB8G\n" +
+ "A1UdIwQYMBaAFPAXYhNVPbP/CgBr+1CEl/PtYtAaMBkGCSqGSIb2fQdBAAQMMAob\n" +
+ "BFY3LjEDAgCBMA0GCSqGSIb3DQEBBQUAA4GBAEa6RcDNcEIGUlkDJUY/pWTds4zh\n" +
+ "xbVkp3wSmpwPFhx5fxTyF4HD2L60jl3aqjTB7gPpsL2Pk5QZlNsi3t4UkCV70UOd\n" +
+ "ueJRN3o/LOtk4+bjXY2lC0qTHbN80VMLqPjmaf9ghSA9hwhskdtMgRsgfd90q5QP\n" +
+ "ZFdYf+hthc3m6IcJ\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, compromised certificate
+ static String compromisedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFijCCA3KgAwIBAgIQDHbanJEMTiye/hXQWJM8TDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDcwNTE2MTcxOTM2WhcNMjUwMzMxMTgxOTIxWjBfMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdpTm90YXIgUm9vdCBDQTEg\n" +
+ "MB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmwwggIiMA0GCSqGSIb3DQEB\n" +
+ "AQUAA4ICDwAwggIKAoICAQCssFjBAL3YIQgLK5r+blYwBZ8bd5AQQVzDDYcRd46B\n" +
+ "8cp86Yxq7Th0Nbva3/m7wAk3tJZzgX0zGpg595NvlX89ubF1h7pRSOiLcD6VBMXY\n" +
+ "tsMW2YiwsYcdcNqGtA8Ui3rPENF0NqISe3eGSnnme98CEWilToauNFibJBN4ViIl\n" +
+ "HgGLS1Fx+4LMWZZpiFpoU8W5DQI3y0u8ZkqQfioLBQftFl9VkHXYRskbg+IIvvEj\n" +
+ "zJkd1ioPgyAVWCeCLvriIsJJsbkBgWqdbZ1Ad2h2TiEqbYRAhU52mXyC8/O3AlnU\n" +
+ "JgEbjt+tUwbRrhjd4rI6y9eIOI6sWym5GdOY+RgDz0iChmYLG2kPyes4iHomGgVM\n" +
+ "ktck1JbyrFIto0fVUvY//s6EBnCmqj6i8rZWNBhXouSBbefK8GrTx5FrAoNBfBXv\n" +
+ "a5pkXuPQPOWx63tdhvvL5ndJzaNl3Pe5nLjkC1+Tz8wwGjIczhxjlaX56uF0i57p\n" +
+ "K6kwe6AYHw4YC+VbqdPRbB4HZ4+RS6mKvNJmqpMBiLKR+jFc1abBUggJzQpjotMi\n" +
+ "puih2TkGl/VujQKQjBR7P4DNG5y6xFhyI6+2Vp/GekIzKQc/gsnmHwUNzUwoNovT\n" +
+ "yD4cxojvXu6JZOkd69qJfjKmadHdzIif0dDJZiHcBmfFlHqabWJMfczgZICynkeO\n" +
+ "owIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" +
+ "HQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wDQYJKoZIhvcNAQEFBQADggIBADsC\n" +
+ "jcs8MOhuoK3yc7NfniUTBAXT9uOLuwt5zlPe5JbF0a9zvNXD0EBVfEB/zRtfCdXy\n" +
+ "fJ9oHbtdzno5wozWmHvFg1Wo1X1AyuAe94leY12hE8JdiraKfADzI8PthV9xdvBo\n" +
+ "Y6pFITlIYXg23PFDk9Qlx/KAZeFTAnVR/Ho67zerhChXDNjU1JlWbOOi/lmEtDHo\n" +
+ "M/hklJRRl6s5xUvt2t2AC298KQ3EjopyDedTFLJgQT2EkTFoPSdE2+Xe9PpjRchM\n" +
+ "Ppj1P0G6Tss3DbpmmPHdy59c91Q2gmssvBNhl0L4eLvMyKKfyvBovWsdst+Nbwed\n" +
+ "2o5nx0ceyrm/KkKRt2NTZvFCo+H0Wk1Ya7XkpDOtXHAd3ODy63MUkZoDweoAZbwH\n" +
+ "/M8SESIsrqC9OuCiKthZ6SnTGDWkrBFfGbW1G/8iSlzGeuQX7yCpp/Q/rYqnmgQl\n" +
+ "nQ7KN+ZQ/YxCKQSa7LnPS3K94gg2ryMvYuXKAdNw23yCIywWMQzGNgeQerEfZ1jE\n" +
+ "O1hZibCMjFCz2IbLaKPECudpSyDOwR5WS5WpI2jYMNjD67BVUc3l/Su49bsRn1NU\n" +
+ "9jQZjHkJNsphFyUXC4KYcwx3dMPVDceoEkzHp1RxRy4sGn3J4ys7SN4nhKdjNrN9\n" +
+ "j6BkOSQNPXuHr2ZcdBtLc7LljPCGmbjlxd+Ewbfr\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Public CA 2025, intermediate certificate
+ static String intermediateCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIGAzCCA+ugAwIBAgIQHn16Uz1FMEGWQA9xSB9FBDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDYwMjA2MTYwNzAyWhcNMjUwMzI4MTYwNzAyWjBmMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdpTm90YXIgUHVibGljIENB\n" +
+ "IDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5vdGFyLm5sMIIBIjANBgkq\n" +
+ "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs/2eu/I5fMG8lbvPph3e8zfJpZQtg/72\n" +
+ "Yx29+ivtKehiF6A3n785XyoY6IT3vlCrhy1CbMOY3M0x1n4YQlv17B0XZ/DqHyBA\n" +
+ "SQvnDNbkM9j4NoSy/sRtGsP6PetIFFjrhE9whZuvuSUC1PY4PruEEJp8zOCx4+wU\n" +
+ "Zt9xvjy4Xra+bSia5rwccQ/R5FYTGKrYCthOy9C9ud5Fhd++rlVhgdA/78w+Cs2s\n" +
+ "xS4i0MAxG75P3/e/bATJKepbydHdDjkyz9o3RW/wdPUXhzEw4EwUjYg6XJrDzMad\n" +
+ "6aL9M/eaxDjgz6o48EaWRDrGptaE2uJRuErVz7oOO0p/wYKq/BU+/wIDAQABo4IB\n" +
+ "sjCCAa4wOgYIKwYBBQUHAQEELjAsMCoGCCsGAQUFBzABhh5odHRwOi8vdmFsaWRh\n" +
+ "dGlvbi5kaWdpbm90YXIubmwwHwYDVR0jBBgwFoAUiGi/4I41xDs4a2L3KDuEgcgM\n" +
+ "100wEgYDVR0TAQH/BAgwBgEB/wIBADCBxgYDVR0gBIG+MIG7MIG4Bg5ghBABh2kB\n" +
+ "AQEBBQIGBDCBpTAnBggrBgEFBQcCARYbaHR0cDovL3d3dy5kaWdpbm90YXIubmwv\n" +
+ "Y3BzMHoGCCsGAQUFBwICMG4abENvbmRpdGlvbnMsIGFzIG1lbnRpb25lZCBvbiBv\n" +
+ "dXIgd2Vic2l0ZSAod3d3LmRpZ2lub3Rhci5ubCksIGFyZSBhcHBsaWNhYmxlIHRv\n" +
+ "IGFsbCBvdXIgcHJvZHVjdHMgYW5kIHNlcnZpY2VzLjBDBgNVHR8EPDA6MDigNqA0\n" +
+ "hjJodHRwOi8vc2VydmljZS5kaWdpbm90YXIubmwvY3JsL3Jvb3QvbGF0ZXN0Q1JM\n" +
+ "LmNybDAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFN8zwK+S/jf8ttgWFtDZsZHV\n" +
+ "+m6lMA0GCSqGSIb3DQEBBQUAA4ICAQCfV1rmBd9QStEyQ40lT0tqby0/3ez0STuJ\n" +
+ "ESBQLQD56XYdb4VFSuqA6xTtiuSVHLoiv2xyISN9FvX3A5VtifkJ00JEaLQJiSsE\n" +
+ "wGDkYGl1DT7SsqtAVKdMAuCM+e0j0/RV3hZ6kcrM7/wFccHwM+/TiurR9lgZDzB4\n" +
+ "a7++A4XrYyKx9vc9ZwBEnD1nrAe7++gg9cuZgP7e+QL0FBHMjpw+gnCDjr2dzBZC\n" +
+ "4r+b8SOqlbPRPexBuNghlc7PfcPIyFis2LJXDRMWiAd3TcfdALwRsuKMR/T+cwyr\n" +
+ "asy69OEGHplLT57otQ524BDctDXNzlH9bHEh52QzqkWvIDqs42910IUy1nYNPIUG\n" +
+ "yYJV/T7H8Jb6vfMZWe47iUFvtNZCi8+b542gRUwdi+ca+hGviBC9Qr4Wv1pl7CBQ\n" +
+ "Hy1axTkHiQawUo/hgmoetCpftugl9yJTfvsBorUV1ZMxn9B1JLSGtWnbUsFRla7G\n" +
+ "fNa0IsUkzmmha8XCzvNu0d1PDGtcQyUqmDOE1Hx4cIBeuF8ipuIXkrVCr9zAZ4ZC\n" +
+ "hgz6aA1gDTW8whSRJqYEYEQ0pcMEFLyXE+Nz3O8NinO2AuxqKhjMk13203xA7lPY\n" +
+ "MnBQ0v7S3qqbp/pvPMiUhOz/VaYted6QmOY5EATBnFiLCuw87JXoAyp382eJ3WX1\n" +
+ "hOiR4IX9Tg==\n" +
+ "-----END CERTIFICATE-----";
+
+ // The fraudulent certificate issued by above compromised CA
+ static String targetCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFKDCCBBCgAwIBAgIQBeLmpM0J6lTWZbB1/iKiVjANBgkqhkiG9w0BAQUFADBm\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdp\n" +
+ "Tm90YXIgUHVibGljIENBIDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5v\n" +
+ "dGFyLm5sMB4XDTExMDcxMDE5MDYzMFoXDTEzMDcwOTE5MDYzMFowajELMAkGA1UE\n" +
+ "BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxFjAUBgNVBAcTDU1vdW50YWluIFZp\n" +
+ "ZXcxFzAVBgNVBAUTDlBLMDAwMjI5MjAwMDAyMRUwEwYDVQQDEwwqLmdvb2dsZS5j\n" +
+ "b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNbeKubCV0aCxhOiOS\n" +
+ "CSQ/w9HXTYuD5BLKuiqXNw3setdTymeJz2L8aWOHo3nicFNDVwWTgwWomGNr2J6Q\n" +
+ "7g1iINNSW0rR4E1l2szRkcnAY6c6i/Eke93nF4i2hDsnIBveolF5yjpuRm73uQQD\n" +
+ "ulHjA3BFRF/PTi0fw2/Yt+8ieoMuNcMWN6Eou5Gqt5YZkWv176ofeCbsBmMrP87x\n" +
+ "OhhtTDckCapk4VQZG2XrfzZcV6tdzCp5TI8uHdu17cdzXm1imZ8tyvzFeiCEOQN8\n" +
+ "vPNzB/fIr3CJQ5q4uM5aKT3DD5PeVzf4rfJKQNgCTWiIBc9XcWEUuszwAsnmg7e2\n" +
+ "EJRdAgMBAAGjggHMMIIByDA6BggrBgEFBQcBAQQuMCwwKgYIKwYBBQUHMAGGHmh0\n" +
+ "dHA6Ly92YWxpZGF0aW9uLmRpZ2lub3Rhci5ubDAfBgNVHSMEGDAWgBTfM8Cvkv43\n" +
+ "/LbYFhbQ2bGR1fpupTAJBgNVHRMEAjAAMIHGBgNVHSAEgb4wgbswgbgGDmCEEAGH\n" +
+ "aQEBAQIEAQICMIGlMCcGCCsGAQUFBwIBFhtodHRwOi8vd3d3LmRpZ2lub3Rhci5u\n" +
+ "bC9jcHMwegYIKwYBBQUHAgIwbhpsQ29uZGl0aW9ucywgYXMgbWVudGlvbmVkIG9u\n" +
+ "IG91ciB3ZWJzaXRlICh3d3cuZGlnaW5vdGFyLm5sKSwgYXJlIGFwcGxpY2FibGUg\n" +
+ "dG8gYWxsIG91ciBwcm9kdWN0cyBhbmQgc2VydmljZXMuMEkGA1UdHwRCMEAwPqA8\n" +
+ "oDqGOGh0dHA6Ly9zZXJ2aWNlLmRpZ2lub3Rhci5ubC9jcmwvcHVibGljMjAyNS9s\n" +
+ "YXRlc3RDUkwuY3JsMA4GA1UdDwEB/wQEAwIEsDAbBgNVHREEFDASgRBhZG1pbkBn\n" +
+ "b29nbGUuY29tMB0GA1UdDgQWBBQHSn0WJzIo0eMBMQUNsMqN6eF/7TANBgkqhkiG\n" +
+ "9w0BAQUFAAOCAQEAAs5dL7N9wzRJkI4Aq4lC5t8j5ZadqnqUcgYLADzSv4ExytNH\n" +
+ "UY2nH6iVTihC0UPSsILWraoeApdT7Rphz/8DLQEBRGdeKWAptNM3EbiXtQaZT2uB\n" +
+ "pidL8UoafX0kch3f71Y1scpBEjvu5ZZLnjg0A8AL0tnsereOVdDpU98bKqdbbrnM\n" +
+ "FRmBlSf7xdaNca6JJHeEpga4E9Ty683CmccrSGXdU2tTCuHEJww+iOAUtPIZcsum\n" +
+ "U7/eYeY1pMyGLyIjbNgRY7nDzRwvM/BsbL9eh4/mSQj/4nncqJd22sVQpCggQiVK\n" +
+ "baB2sVGcVNBkK55bT8gPqnx8JypubyUvayzZGg==\n" +
+ "-----END CERTIFICATE-----";
+
+ public static void main(String args[]) throws Exception {
+
+ Exception reservedException = null;
+ try {
+ validate();
+ } catch (CertPathValidatorException cpve) {
+ reservedException = cpve;
+ }
+
+ if (reservedException == null) {
+ throw new Exception("Unable to block fraudulent certificate");
+ }
+
+ System.out.println(
+ "The expected untrusted cert exception: " + reservedException);
+ }
+
+ private static CertPath generateCertificatePath()
+ throws CertificateException, IOException {
+
+ // generate certificate from cert strings
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ // generate certification path
+ List<Certificate> list = new ArrayList();
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(targetCertStr.getBytes())) {
+ list.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(intermediateCertStr.getBytes())) {
+ list.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(compromisedCertStr.getBytes())) {
+ list.add(cf.generateCertificate(is));
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(untrustedCrossCertStr.getBytes())) {
+ list.add(cf.generateCertificate(is));
+ }
+
+ return cf.generateCertPath(list);
+ }
+
+ private static Set<TrustAnchor> generateTrustAnchors()
+ throws CertificateException, IOException {
+ // generate certificate from cert string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ Certificate trustedCert = null;
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(trustedCertStr.getBytes())) {
+ trustedCert = cf.generateCertificate(is);
+ }
+
+ // generate a trust anchor
+ TrustAnchor anchor =
+ new TrustAnchor((X509Certificate)trustedCert, null);
+
+ return Collections.singleton(anchor);
+ }
+
+ private static void validate()
+ throws CertPathValidatorException, Exception {
+
+ CertPath path = generateCertificatePath();
+ Set<TrustAnchor> anchors = generateTrustAnchors();
+
+ PKIXParameters params = new PKIXParameters(anchors);
+
+ // disable certificate revocation checking
+ params.setRevocationEnabled(false);
+
+ // set the validation time
+ params.setDate(new Date(111, 11, 25)); // 2011-12-25
+
+ CertPathValidator validator = CertPathValidator.getInstance("PKIX");
+
+ validator.validate(path, params);
+ }
+}
+
--- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java Fri Mar 02 09:13:13 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
--- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh Fri Mar 02 09:13:13 2012 -0800
@@ -1,7 +1,7 @@
#! /bin/sh
#
-# 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/X509TrustManagerImpl/ComodoHacker.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,305 @@
+/*
+ * 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 7123519
+ * @summary Problem with java/classes_security
+ * @run main/othervm ComodoHacker PKIX
+ * @run main/othervm ComodoHacker SunX509
+ */
+
+import java.net.*;
+import java.util.*;
+import java.io.*;
+import javax.net.ssl.*;
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.security.cert.CertificateException;
+import java.security.spec.*;
+import java.security.interfaces.*;
+
+public class ComodoHacker {
+ // DigiNotar Root CA, untrusted root certificate
+ static String trustedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1\n" +
+ "MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE\n" +
+ "ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j\n" +
+ "b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF\n" +
+ "bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg\n" +
+ "U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA\n" +
+ "A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/\n" +
+ "I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3\n" +
+ "wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC\n" +
+ "AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb\n" +
+ "oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5\n" +
+ "BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p\n" +
+ "dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk\n" +
+ "MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp\n" +
+ "b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu\n" +
+ "dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0\n" +
+ "MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi\n" +
+ "E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa\n" +
+ "MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI\n" +
+ "hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN\n" +
+ "95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd\n" +
+ "2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, untrusted cross-certificate
+ static String untrustedCrossCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFSDCCBLGgAwIBAgIERpwsrzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\n" +
+ "VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\n" +
+ "ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\n" +
+ "KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\n" +
+ "ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNzA3\n" +
+ "MjYxNTU3MzlaFw0xMzA4MjYxNjI3MzlaMF8xCzAJBgNVBAYTAk5MMRIwEAYDVQQK\n" +
+ "EwlEaWdpTm90YXIxGjAYBgNVBAMTEURpZ2lOb3RhciBSb290IENBMSAwHgYJKoZI\n" +
+ "hvcNAQkBFhFpbmZvQGRpZ2lub3Rhci5ubDCCAiIwDQYJKoZIhvcNAQEBBQADggIP\n" +
+ "ADCCAgoCggIBAKywWMEAvdghCAsrmv5uVjAFnxt3kBBBXMMNhxF3joHxynzpjGrt\n" +
+ "OHQ1u9rf+bvACTe0lnOBfTMamDn3k2+Vfz25sXWHulFI6ItwPpUExdi2wxbZiLCx\n" +
+ "hx1w2oa0DxSLes8Q0XQ2ohJ7d4ZKeeZ73wIRaKVOhq40WJskE3hWIiUeAYtLUXH7\n" +
+ "gsxZlmmIWmhTxbkNAjfLS7xmSpB+KgsFB+0WX1WQddhGyRuD4gi+8SPMmR3WKg+D\n" +
+ "IBVYJ4Iu+uIiwkmxuQGBap1tnUB3aHZOISpthECFTnaZfILz87cCWdQmARuO361T\n" +
+ "BtGuGN3isjrL14g4jqxbKbkZ05j5GAPPSIKGZgsbaQ/J6ziIeiYaBUyS1yTUlvKs\n" +
+ "Ui2jR9VS9j/+zoQGcKaqPqLytlY0GFei5IFt58rwatPHkWsCg0F8Fe9rmmRe49A8\n" +
+ "5bHre12G+8vmd0nNo2Xc97mcuOQLX5PPzDAaMhzOHGOVpfnq4XSLnukrqTB7oBgf\n" +
+ "DhgL5Vup09FsHgdnj5FLqYq80maqkwGIspH6MVzVpsFSCAnNCmOi0yKm6KHZOQaX\n" +
+ "9W6NApCMFHs/gM0bnLrEWHIjr7ZWn8Z6QjMpBz+CyeYfBQ3NTCg2i9PIPhzGiO9e\n" +
+ "7olk6R3r2ol+MqZp0d3MiJ/R0MlmIdwGZ8WUepptYkx9zOBkgLKeR46jAgMBAAGj\n" +
+ "ggEmMIIBIjASBgNVHRMBAf8ECDAGAQH/AgEBMCcGA1UdJQQgMB4GCCsGAQUFBwMB\n" +
+ "BggrBgEFBQcDAgYIKwYBBQUHAwQwEQYDVR0gBAowCDAGBgRVHSAAMDMGCCsGAQUF\n" +
+ "BwEBBCcwJTAjBggrBgEFBQcwAYYXaHR0cDovL29jc3AuZW50cnVzdC5uZXQwMwYD\n" +
+ "VR0fBCwwKjAooCagJIYiaHR0cDovL2NybC5lbnRydXN0Lm5ldC9zZXJ2ZXIxLmNy\n" +
+ "bDAdBgNVHQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wCwYDVR0PBAQDAgEGMB8G\n" +
+ "A1UdIwQYMBaAFPAXYhNVPbP/CgBr+1CEl/PtYtAaMBkGCSqGSIb2fQdBAAQMMAob\n" +
+ "BFY3LjEDAgCBMA0GCSqGSIb3DQEBBQUAA4GBAEa6RcDNcEIGUlkDJUY/pWTds4zh\n" +
+ "xbVkp3wSmpwPFhx5fxTyF4HD2L60jl3aqjTB7gPpsL2Pk5QZlNsi3t4UkCV70UOd\n" +
+ "ueJRN3o/LOtk4+bjXY2lC0qTHbN80VMLqPjmaf9ghSA9hwhskdtMgRsgfd90q5QP\n" +
+ "ZFdYf+hthc3m6IcJ\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Root CA, compromised certificate
+ static String compromisedCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFijCCA3KgAwIBAgIQDHbanJEMTiye/hXQWJM8TDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDcwNTE2MTcxOTM2WhcNMjUwMzMxMTgxOTIxWjBfMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdpTm90YXIgUm9vdCBDQTEg\n" +
+ "MB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmwwggIiMA0GCSqGSIb3DQEB\n" +
+ "AQUAA4ICDwAwggIKAoICAQCssFjBAL3YIQgLK5r+blYwBZ8bd5AQQVzDDYcRd46B\n" +
+ "8cp86Yxq7Th0Nbva3/m7wAk3tJZzgX0zGpg595NvlX89ubF1h7pRSOiLcD6VBMXY\n" +
+ "tsMW2YiwsYcdcNqGtA8Ui3rPENF0NqISe3eGSnnme98CEWilToauNFibJBN4ViIl\n" +
+ "HgGLS1Fx+4LMWZZpiFpoU8W5DQI3y0u8ZkqQfioLBQftFl9VkHXYRskbg+IIvvEj\n" +
+ "zJkd1ioPgyAVWCeCLvriIsJJsbkBgWqdbZ1Ad2h2TiEqbYRAhU52mXyC8/O3AlnU\n" +
+ "JgEbjt+tUwbRrhjd4rI6y9eIOI6sWym5GdOY+RgDz0iChmYLG2kPyes4iHomGgVM\n" +
+ "ktck1JbyrFIto0fVUvY//s6EBnCmqj6i8rZWNBhXouSBbefK8GrTx5FrAoNBfBXv\n" +
+ "a5pkXuPQPOWx63tdhvvL5ndJzaNl3Pe5nLjkC1+Tz8wwGjIczhxjlaX56uF0i57p\n" +
+ "K6kwe6AYHw4YC+VbqdPRbB4HZ4+RS6mKvNJmqpMBiLKR+jFc1abBUggJzQpjotMi\n" +
+ "puih2TkGl/VujQKQjBR7P4DNG5y6xFhyI6+2Vp/GekIzKQc/gsnmHwUNzUwoNovT\n" +
+ "yD4cxojvXu6JZOkd69qJfjKmadHdzIif0dDJZiHcBmfFlHqabWJMfczgZICynkeO\n" +
+ "owIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNV\n" +
+ "HQ4EFgQUiGi/4I41xDs4a2L3KDuEgcgM100wDQYJKoZIhvcNAQEFBQADggIBADsC\n" +
+ "jcs8MOhuoK3yc7NfniUTBAXT9uOLuwt5zlPe5JbF0a9zvNXD0EBVfEB/zRtfCdXy\n" +
+ "fJ9oHbtdzno5wozWmHvFg1Wo1X1AyuAe94leY12hE8JdiraKfADzI8PthV9xdvBo\n" +
+ "Y6pFITlIYXg23PFDk9Qlx/KAZeFTAnVR/Ho67zerhChXDNjU1JlWbOOi/lmEtDHo\n" +
+ "M/hklJRRl6s5xUvt2t2AC298KQ3EjopyDedTFLJgQT2EkTFoPSdE2+Xe9PpjRchM\n" +
+ "Ppj1P0G6Tss3DbpmmPHdy59c91Q2gmssvBNhl0L4eLvMyKKfyvBovWsdst+Nbwed\n" +
+ "2o5nx0ceyrm/KkKRt2NTZvFCo+H0Wk1Ya7XkpDOtXHAd3ODy63MUkZoDweoAZbwH\n" +
+ "/M8SESIsrqC9OuCiKthZ6SnTGDWkrBFfGbW1G/8iSlzGeuQX7yCpp/Q/rYqnmgQl\n" +
+ "nQ7KN+ZQ/YxCKQSa7LnPS3K94gg2ryMvYuXKAdNw23yCIywWMQzGNgeQerEfZ1jE\n" +
+ "O1hZibCMjFCz2IbLaKPECudpSyDOwR5WS5WpI2jYMNjD67BVUc3l/Su49bsRn1NU\n" +
+ "9jQZjHkJNsphFyUXC4KYcwx3dMPVDceoEkzHp1RxRy4sGn3J4ys7SN4nhKdjNrN9\n" +
+ "j6BkOSQNPXuHr2ZcdBtLc7LljPCGmbjlxd+Ewbfr\n" +
+ "-----END CERTIFICATE-----";
+
+ // DigiNotar Public CA 2025, intermediate certificate
+ static String intermediateCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIGAzCCA+ugAwIBAgIQHn16Uz1FMEGWQA9xSB9FBDANBgkqhkiG9w0BAQUFADBf\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMRowGAYDVQQDExFEaWdp\n" +
+ "Tm90YXIgUm9vdCBDQTEgMB4GCSqGSIb3DQEJARYRaW5mb0BkaWdpbm90YXIubmww\n" +
+ "HhcNMDYwMjA2MTYwNzAyWhcNMjUwMzI4MTYwNzAyWjBmMQswCQYDVQQGEwJOTDES\n" +
+ "MBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdpTm90YXIgUHVibGljIENB\n" +
+ "IDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5vdGFyLm5sMIIBIjANBgkq\n" +
+ "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs/2eu/I5fMG8lbvPph3e8zfJpZQtg/72\n" +
+ "Yx29+ivtKehiF6A3n785XyoY6IT3vlCrhy1CbMOY3M0x1n4YQlv17B0XZ/DqHyBA\n" +
+ "SQvnDNbkM9j4NoSy/sRtGsP6PetIFFjrhE9whZuvuSUC1PY4PruEEJp8zOCx4+wU\n" +
+ "Zt9xvjy4Xra+bSia5rwccQ/R5FYTGKrYCthOy9C9ud5Fhd++rlVhgdA/78w+Cs2s\n" +
+ "xS4i0MAxG75P3/e/bATJKepbydHdDjkyz9o3RW/wdPUXhzEw4EwUjYg6XJrDzMad\n" +
+ "6aL9M/eaxDjgz6o48EaWRDrGptaE2uJRuErVz7oOO0p/wYKq/BU+/wIDAQABo4IB\n" +
+ "sjCCAa4wOgYIKwYBBQUHAQEELjAsMCoGCCsGAQUFBzABhh5odHRwOi8vdmFsaWRh\n" +
+ "dGlvbi5kaWdpbm90YXIubmwwHwYDVR0jBBgwFoAUiGi/4I41xDs4a2L3KDuEgcgM\n" +
+ "100wEgYDVR0TAQH/BAgwBgEB/wIBADCBxgYDVR0gBIG+MIG7MIG4Bg5ghBABh2kB\n" +
+ "AQEBBQIGBDCBpTAnBggrBgEFBQcCARYbaHR0cDovL3d3dy5kaWdpbm90YXIubmwv\n" +
+ "Y3BzMHoGCCsGAQUFBwICMG4abENvbmRpdGlvbnMsIGFzIG1lbnRpb25lZCBvbiBv\n" +
+ "dXIgd2Vic2l0ZSAod3d3LmRpZ2lub3Rhci5ubCksIGFyZSBhcHBsaWNhYmxlIHRv\n" +
+ "IGFsbCBvdXIgcHJvZHVjdHMgYW5kIHNlcnZpY2VzLjBDBgNVHR8EPDA6MDigNqA0\n" +
+ "hjJodHRwOi8vc2VydmljZS5kaWdpbm90YXIubmwvY3JsL3Jvb3QvbGF0ZXN0Q1JM\n" +
+ "LmNybDAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFN8zwK+S/jf8ttgWFtDZsZHV\n" +
+ "+m6lMA0GCSqGSIb3DQEBBQUAA4ICAQCfV1rmBd9QStEyQ40lT0tqby0/3ez0STuJ\n" +
+ "ESBQLQD56XYdb4VFSuqA6xTtiuSVHLoiv2xyISN9FvX3A5VtifkJ00JEaLQJiSsE\n" +
+ "wGDkYGl1DT7SsqtAVKdMAuCM+e0j0/RV3hZ6kcrM7/wFccHwM+/TiurR9lgZDzB4\n" +
+ "a7++A4XrYyKx9vc9ZwBEnD1nrAe7++gg9cuZgP7e+QL0FBHMjpw+gnCDjr2dzBZC\n" +
+ "4r+b8SOqlbPRPexBuNghlc7PfcPIyFis2LJXDRMWiAd3TcfdALwRsuKMR/T+cwyr\n" +
+ "asy69OEGHplLT57otQ524BDctDXNzlH9bHEh52QzqkWvIDqs42910IUy1nYNPIUG\n" +
+ "yYJV/T7H8Jb6vfMZWe47iUFvtNZCi8+b542gRUwdi+ca+hGviBC9Qr4Wv1pl7CBQ\n" +
+ "Hy1axTkHiQawUo/hgmoetCpftugl9yJTfvsBorUV1ZMxn9B1JLSGtWnbUsFRla7G\n" +
+ "fNa0IsUkzmmha8XCzvNu0d1PDGtcQyUqmDOE1Hx4cIBeuF8ipuIXkrVCr9zAZ4ZC\n" +
+ "hgz6aA1gDTW8whSRJqYEYEQ0pcMEFLyXE+Nz3O8NinO2AuxqKhjMk13203xA7lPY\n" +
+ "MnBQ0v7S3qqbp/pvPMiUhOz/VaYted6QmOY5EATBnFiLCuw87JXoAyp382eJ3WX1\n" +
+ "hOiR4IX9Tg==\n" +
+ "-----END CERTIFICATE-----";
+
+ // The fraudulent certificate issued by above compromised CA
+ static String targetCertStr =
+ "-----BEGIN CERTIFICATE-----\n" +
+ "MIIFKDCCBBCgAwIBAgIQBeLmpM0J6lTWZbB1/iKiVjANBgkqhkiG9w0BAQUFADBm\n" +
+ "MQswCQYDVQQGEwJOTDESMBAGA1UEChMJRGlnaU5vdGFyMSEwHwYDVQQDExhEaWdp\n" +
+ "Tm90YXIgUHVibGljIENBIDIwMjUxIDAeBgkqhkiG9w0BCQEWEWluZm9AZGlnaW5v\n" +
+ "dGFyLm5sMB4XDTExMDcxMDE5MDYzMFoXDTEzMDcwOTE5MDYzMFowajELMAkGA1UE\n" +
+ "BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxFjAUBgNVBAcTDU1vdW50YWluIFZp\n" +
+ "ZXcxFzAVBgNVBAUTDlBLMDAwMjI5MjAwMDAyMRUwEwYDVQQDEwwqLmdvb2dsZS5j\n" +
+ "b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDNbeKubCV0aCxhOiOS\n" +
+ "CSQ/w9HXTYuD5BLKuiqXNw3setdTymeJz2L8aWOHo3nicFNDVwWTgwWomGNr2J6Q\n" +
+ "7g1iINNSW0rR4E1l2szRkcnAY6c6i/Eke93nF4i2hDsnIBveolF5yjpuRm73uQQD\n" +
+ "ulHjA3BFRF/PTi0fw2/Yt+8ieoMuNcMWN6Eou5Gqt5YZkWv176ofeCbsBmMrP87x\n" +
+ "OhhtTDckCapk4VQZG2XrfzZcV6tdzCp5TI8uHdu17cdzXm1imZ8tyvzFeiCEOQN8\n" +
+ "vPNzB/fIr3CJQ5q4uM5aKT3DD5PeVzf4rfJKQNgCTWiIBc9XcWEUuszwAsnmg7e2\n" +
+ "EJRdAgMBAAGjggHMMIIByDA6BggrBgEFBQcBAQQuMCwwKgYIKwYBBQUHMAGGHmh0\n" +
+ "dHA6Ly92YWxpZGF0aW9uLmRpZ2lub3Rhci5ubDAfBgNVHSMEGDAWgBTfM8Cvkv43\n" +
+ "/LbYFhbQ2bGR1fpupTAJBgNVHRMEAjAAMIHGBgNVHSAEgb4wgbswgbgGDmCEEAGH\n" +
+ "aQEBAQIEAQICMIGlMCcGCCsGAQUFBwIBFhtodHRwOi8vd3d3LmRpZ2lub3Rhci5u\n" +
+ "bC9jcHMwegYIKwYBBQUHAgIwbhpsQ29uZGl0aW9ucywgYXMgbWVudGlvbmVkIG9u\n" +
+ "IG91ciB3ZWJzaXRlICh3d3cuZGlnaW5vdGFyLm5sKSwgYXJlIGFwcGxpY2FibGUg\n" +
+ "dG8gYWxsIG91ciBwcm9kdWN0cyBhbmQgc2VydmljZXMuMEkGA1UdHwRCMEAwPqA8\n" +
+ "oDqGOGh0dHA6Ly9zZXJ2aWNlLmRpZ2lub3Rhci5ubC9jcmwvcHVibGljMjAyNS9s\n" +
+ "YXRlc3RDUkwuY3JsMA4GA1UdDwEB/wQEAwIEsDAbBgNVHREEFDASgRBhZG1pbkBn\n" +
+ "b29nbGUuY29tMB0GA1UdDgQWBBQHSn0WJzIo0eMBMQUNsMqN6eF/7TANBgkqhkiG\n" +
+ "9w0BAQUFAAOCAQEAAs5dL7N9wzRJkI4Aq4lC5t8j5ZadqnqUcgYLADzSv4ExytNH\n" +
+ "UY2nH6iVTihC0UPSsILWraoeApdT7Rphz/8DLQEBRGdeKWAptNM3EbiXtQaZT2uB\n" +
+ "pidL8UoafX0kch3f71Y1scpBEjvu5ZZLnjg0A8AL0tnsereOVdDpU98bKqdbbrnM\n" +
+ "FRmBlSf7xdaNca6JJHeEpga4E9Ty683CmccrSGXdU2tTCuHEJww+iOAUtPIZcsum\n" +
+ "U7/eYeY1pMyGLyIjbNgRY7nDzRwvM/BsbL9eh4/mSQj/4nncqJd22sVQpCggQiVK\n" +
+ "baB2sVGcVNBkK55bT8gPqnx8JypubyUvayzZGg==\n" +
+ "-----END CERTIFICATE-----";
+
+ private static String tmAlgorithm; // trust manager
+
+ public static void main(String args[]) throws Exception {
+ // Get the customized arguments.
+ parseArguments(args);
+
+ X509TrustManager tm = getTrustManager();
+ X509Certificate[] chain = getFraudulentChain();
+
+ Exception reservedException = null;
+ try {
+ tm.checkClientTrusted(chain, "RSA");
+ } catch (CertificateException ce) {
+ reservedException = ce;
+ }
+
+ if (reservedException == null) {
+ throw new Exception("Unable to block fraudulent certificate");
+ }
+
+ reservedException = null;
+ try {
+ tm.checkServerTrusted(chain, "RSA");
+ } catch (CertificateException ce) {
+ reservedException = ce;
+ }
+
+ if (reservedException == null) {
+ throw new Exception("Unable to block fraudulent certificate");
+ }
+
+ System.out.println(
+ "The expected untrusted cert exception: " + reservedException);
+ }
+
+ private static void parseArguments(String[] args) {
+ tmAlgorithm = args[0];
+ }
+
+ private static X509TrustManager getTrustManager() throws Exception {
+ // generate certificate from cert string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ // create a key store
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(null, null);
+
+ // import the trusted cert
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(trustedCertStr.getBytes())) {
+ Certificate trustedCert = cf.generateCertificate(is);
+ ks.setCertificateEntry("RSA Export Signer", trustedCert);
+ }
+
+ // create the trust manager
+ TrustManagerFactory tmf = TrustManagerFactory.getInstance(tmAlgorithm);
+ tmf.init(ks);
+
+ return (X509TrustManager)tmf.getTrustManagers()[0];
+ }
+
+ private static X509Certificate[] getFraudulentChain() throws Exception {
+ // generate certificate from cert string
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+ X509Certificate[] chain = new X509Certificate[4];
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(targetCertStr.getBytes())) {
+ chain[0] = (X509Certificate)cf.generateCertificate(is);
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(intermediateCertStr.getBytes())) {
+ chain[1] = (X509Certificate)cf.generateCertificate(is);
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(compromisedCertStr.getBytes())) {
+ chain[2] = (X509Certificate)cf.generateCertificate(is);
+ }
+
+ try (ByteArrayInputStream is =
+ new ByteArrayInputStream(untrustedCrossCertStr.getBytes())) {
+ chain[3] = (X509Certificate)cf.generateCertificate(is);
+ }
+
+ return chain;
+ }
+}
+
--- a/jdk/test/sun/security/tools/jarsigner/ec.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/ec.sh Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 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,8 @@
$KT -alias a -dname CN=a -keyalg ec -genkey -validity 300 || exit 11
$KT -alias b -dname CN=b -keyalg ec -genkey -validity 300 || exit 12
-$KT -alias c -dname CN=c -keyalg ec -genkey -validity 300 || exit 13
+# Ensure that key length is sufficient for the intended hash (SHA512withECDSA)
+$KT -alias c -dname CN=c -keyalg ec -genkey -validity 300 -keysize 521 || exit 13
$KT -alias x -dname CN=x -keyalg ec -genkey -validity 300 || exit 14
$JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 21
--- a/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/tools/jcmd/jcmd-Defaults.sh Fri Mar 02 09:13:13 2012 -0800
@@ -28,6 +28,6 @@
JCMD="${TESTJAVA}/bin/jcmd"
-${JCMD} 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
+${JCMD} -J-XX:+UsePerfData 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
-${JCMD} -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
+${JCMD} -J-XX:+UsePerfData -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
--- a/jdk/test/sun/tools/jcmd/jcmd-f.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/tools/jcmd/jcmd-f.sh Fri Mar 02 09:13:13 2012 -0800
@@ -46,7 +46,7 @@
# -f <script>
rm -f jcmd.out 2>/dev/null
-${JCMD} $appJavaPid -f ${TESTSRC}/dcmd-script.txt | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
+${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-script.txt | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
echo jcmd.out
diff -w jcmd.out ${TESTSRC}/help_help.out
if [ $? != 0 ]; then
--- a/jdk/test/sun/tools/jcmd/jcmd-help-help.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/tools/jcmd/jcmd-help-help.sh Fri Mar 02 09:13:13 2012 -0800
@@ -46,7 +46,7 @@
# help help
rm -f jcmd.out 2>/dev/null
-${JCMD} $appJavaPid help help | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
+${JCMD} -J-XX:+UsePerfData $appJavaPid help help | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
echo jcmd.out
diff -w jcmd.out ${TESTSRC}/help_help.out
if [ $? != 0 ]; then
--- a/jdk/test/sun/tools/jcmd/jcmd-help.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/tools/jcmd/jcmd-help.sh Fri Mar 02 09:13:13 2012 -0800
@@ -29,7 +29,7 @@
JCMD="${TESTJAVA}/bin/jcmd"
rm -f jcmd.out 2>/dev/null
-${JCMD} -h > jcmd.out 2>&1
+${JCMD} -J-XX:+UsePerfData -h > jcmd.out 2>&1
diff -w jcmd.out ${TESTSRC}/usage.out
if [ $? != 0 ]
@@ -40,7 +40,7 @@
fi
rm -f jcmd.out 2>/dev/null
-${JCMD} -help > jcmd.out 2>&1
+${JCMD} -J-XX:+UsePerfData -help > jcmd.out 2>&1
diff -w jcmd.out ${TESTSRC}/usage.out
if [ $? != 0 ]
--- a/jdk/test/sun/tools/jcmd/jcmd-pid.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/tools/jcmd/jcmd-pid.sh Fri Mar 02 09:13:13 2012 -0800
@@ -45,11 +45,11 @@
failed=0
# help command
-${JCMD} $appJavaPid help 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output1.awk
+${JCMD} -J-XX:+UsePerfData $appJavaPid help 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output1.awk
if [ $? != 0 ]; then failed=1; fi
# PerfCounter.list option
-${JCMD} $appJavaPid PerfCounter.print 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output2.awk
+${JCMD} -J-XX:+UsePerfData $appJavaPid PerfCounter.print 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output2.awk
if [ $? != 0 ]; then failed=1; fi
set -e
--- a/jdk/test/sun/tools/jcmd/jcmd_Output1.awk Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/sun/tools/jcmd/jcmd_Output1.awk Fri Mar 02 09:13:13 2012 -0800
@@ -1,26 +1,26 @@
#
BEGIN {
- totallines=0; matched=0
+ totallines=0; matched=0; current=0
}
# match on a main class name followed by arbitrary arguments
/^[0-9]+ [a-z|A-Z][a-z|A-Z|0-9|\.]*($| .*$)/ {
- matched++;
+ current=1;
}
# or match on a path name to a jar file followed by arbitraty arguments
# - note, jar files ending with ".jar" is only a convention, not a requirement.
#Theoretically, any valid file name could occur here.
/^[0-9]+ .*\.jar($| .*$)/ {
- matched++;
+ current=1;
}
# or match on the condition that the class name is not available
/^[0-9]+ -- process information unavailable$/ {
- matched++;
+ current=1;
}
- { totallines++; print $0 }
+ { totallines++; matched+=current; current=0; print $0 }
END {
if ((totallines > 0) && (matched == totallines)) {
--- a/jdk/test/tools/launcher/Arrrghs.java Thu Mar 01 15:31:33 2012 -0800
+++ b/jdk/test/tools/launcher/Arrrghs.java Fri Mar 02 09:13:13 2012 -0800
@@ -24,7 +24,7 @@
/**
* @test
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
- * 6894719 6968053 7067922
+ * 6894719 6968053
* @summary Argument parsing validation.
* @compile -XDignore.symbol.file Arrrghs.java
* @run main Arrrghs
@@ -373,21 +373,6 @@
System.out.println(tr);
}
- /*
- * a missing manifest entry 7067922, we ignore this test for locales
- * which are localized, thus the testing is limited to English locales.
- */
- static void test7067922() {
- if (!isEnglishLocale()) {
- return;
- }
- TestResult tr = null;
- createJar("cvf", "missingmainentry.jar", ".");
- tr = doExec(javaCmd, "-jar", "missingmainentry.jar");
- tr.contains("no main manifest attribute");
- System.out.println(tr);
- }
-
/**
* @param args the command line arguments
* @throws java.io.FileNotFoundException
@@ -400,7 +385,6 @@
runBasicErrorMessageTests();
runMainMethodTests();
test6894719();
- test7067922();
runDiagOptionTests();
if (testExitValue > 0) {
System.out.println("Total of " + testExitValue + " failed");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/MainClassAttributeTest.java Fri Mar 02 09:13:13 2012 -0800
@@ -0,0 +1,103 @@
+/*
+ * 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 7067922
+ * @author sogoel
+ * @summary Test negative scenarios for main class attribute
+ * @build MainClassAttributeTest
+ * @run main MainClassAttributeTest
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/*
+ * This tests negative scenarios for Main class entry in a jar file.
+ * An error should be thrown for each of the test cases when such a
+ * jar is executed.
+ */
+
+public class MainClassAttributeTest extends TestHelper {
+
+ /*
+ * These tests compare messages which could be localized, therefore
+ * these tests compare messages only with English locales, and
+ * for all other locales, the exit values are checked.
+ */
+ static void runTest(File jarFile, String expectedErrorMessage) {
+ TestResult tr = doExec(TestHelper.javaCmd,
+ "-jar", jarFile.getAbsolutePath());
+ if (isEnglishLocale() && !tr.contains(expectedErrorMessage)) {
+ System.out.println(tr);
+ throw new RuntimeException("expected string not found");
+ }
+ if (tr.isOK()) {
+ System.out.println(tr);
+ throw new RuntimeException("test exit with status 0");
+ }
+ }
+
+ // Missing manifest entry
+ static void test1() throws IOException {
+ File jarFile = new File("missingmainentry.jar");
+ createJar("cvf", jarFile.getName(), ".");
+ runTest(jarFile, "no main manifest attribute");
+ }
+
+ // Entry point in manifest file has .class extension
+ static void test2() throws IOException {
+ File jarFile = new File("extensionmainentry.jar");
+ createJar("Foo.class", jarFile, new File("Foo"), (String[])null);
+ runTest(jarFile, "Error: Could not find or load main class");
+ }
+
+ // Entry point in manifest file is misspelled
+ static void test3() throws IOException {
+ File jarFile = new File("misspelledmainentry.jar");
+ createJar("FooMIS", jarFile, new File("Foo"), (String[])null);
+ runTest(jarFile, "Error: Could not find or load main class");
+ }
+
+ // Main-Class attribute is misspelled in manifest file
+ static void test4() throws IOException {
+ File jarFile = new File("misspelledMainAttribute.jar");
+ File manifestFile = new File("manifest.txt");
+ List<String> contents = new ArrayList<>();
+ contents.add("MainClassName: Foo");
+ createFile(manifestFile, contents);
+ createJar("-cmf", manifestFile.getName(), jarFile.getName());
+ runTest(jarFile, "no main manifest attribute");
+ }
+
+ public static void main(String[] args) throws IOException {
+ test1();
+ test2();
+ test3();
+ test4();
+ }
+}
--- a/langtools/.hgtags Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/.hgtags Fri Mar 02 09:13:13 2012 -0800
@@ -147,3 +147,5 @@
601ffcc6551d5414ef871be306c3a26396cf16a7 jdk8-b23
6c9d21ca92c41ff5fcfa76c5b7fafe0f042f4aef jdk8-b24
520c30f85bb529a3daf5d7623764c2464f00fd19 jdk8-b25
+b556aa8a99c358469861770aebdce884e06fa178 jdk8-b26
+be456f9c64e818161c789252145d4ddc292ae863 jdk8-b27
--- a/langtools/make/Makefile-classic Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/make/Makefile-classic Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 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
@@ -115,7 +115,6 @@
JAVADOC_JAR = $(LIB_DIR)/javadoc.jar
JAVAH_JAR = $(LIB_DIR)/javah.jar
JAVAP_JAR = $(LIB_DIR)/javap.jar
-APT_JAR = $(LIB_DIR)/apt.jar
CLASSES_JAR = $(DIST_DIR)/classes.jar
SRC_ZIP = $(DIST_DIR)/src.zip
@@ -163,7 +162,7 @@
#----- useful macros
-TOOLS = javac javadoc javah javap apt
+TOOLS = javac javadoc javah javap
SOURCE_LEVEL = 5
BOOTSTRAP_TARGET_LEVEL = 5
@@ -319,28 +318,6 @@
( $(ECHO) Main-Class: sun.tools.javap.Main ) > $(BUILD_DIR)/javap.mf
$(BOOTJAR) -cfm $@ $(BUILD_DIR)/javap.mf $(patsubst %,-C $(CLASSES_DIR) %, $(JAVAP_DIRS))
-#----- apt
-
-APT_DIRS = \
- com/sun/mirror \
- com/sun/tools/apt
-
-APT_RESOURCE_FILES = \
- $(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.properties -print )
-
-APT_JAVA_FILES = \
- $(shell find $(patsubst %,$(SRC_CLASSES_DIR)/%,$(APT_DIRS)) -name SCCS -prune -o -name \*.java -print ) \
- $(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
-
-$(APT_JAR): $(APT_JAVA_FILES) $(JAVAC_JAR) \
- $(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
- $(MKDIR) -p $(CLASSES_DIR) $(@D)
- $(BOOT_JAVAC) -sourcepath "" -classpath $(CLASSES_DIR) -d $(CLASSES_DIR) -target $(TARGET_LEVEL) $(NO_PROPRIETARY_API_WARNINGS) \
- $(APT_JAVA_FILES) \
- $(patsubst $(SRC_CLASSES_DIR)/%.properties,$(GENSRC_DIR)/%.java,$(APT_RESOURCE_FILES))
- ( $(ECHO) Main-Class: com.sun.tools.apt.Main ; $(ECHO) Class-Path: javac.jar ) > $(BUILD_DIR)/apt.mf
- $(BOOTJAR) -cfm $@ $(BUILD_DIR)/apt.mf $(patsubst %,-C $(CLASSES_DIR) %, $(APT_DIRS))
-
#-----
build-tools: $(BUILDTOOLCLASSES_DIR)/CompileProperties/CompileProperties.class
@@ -366,7 +343,7 @@
#----- all classes
-$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR) $(APT_JAR)
+$(DIST_DIR)/%/classes.jar: $(JAVAC_JAR) $(JAVADOC_JAR) $(JAVAH_JAR) $(JAVAP_JAR)
$(MKDIR) -p $(@D)
$(BOOTJAR) -cf $@ -C $(CLASSES_DIR) .
@@ -401,7 +378,6 @@
- $(TESTJAVA) -jar $(JAVADOC_JAR) -version
$(TESTJAVA) -jar $(JAVAH_JAR) -version
- $(TESTJAVA) -jar $(JAVAP_JAR) -version
- $(TESTJAVA) -jar $(APT_JAR) -version
#-----
--- a/langtools/make/build.properties Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/make/build.properties Fri Mar 02 09:13:13 2012 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 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
@@ -159,15 +159,6 @@
#
-apt.includes = \
- com/sun/mirror/ \
- com/sun/tools/apt/
-
-apt.tests = \
- tools/apt/
-
-#
-
# The following files require the latest JDK to be available.
# The API can be provided by using a suitable boot.java.home
# or by setting import.jdk
--- a/langtools/make/build.xml Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/make/build.xml Fri Mar 02 09:13:13 2012 -0800
@@ -83,7 +83,7 @@
- global property definitions
- general top level targets
- general diagnostic/debugging targets
- - groups of targets for each tool: javac, javadoc, doclets, javah, javap, apt
+ - groups of targets for each tool: javac, javadoc, doclets, javah, javap
Within each group, the following targets are provided, where applicable
build-bootstrap-TOOL build the bootstrap version of the tool
build-classes-TOOL build the classes for the tool
@@ -245,11 +245,11 @@
/>
<target name="build-all-tools"
- depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap,build-apt"
+ depends="build-javac,build-javadoc,build-doclets,build-javah,build-javap"
/>
<target name="build-all-classes" depends="build-bootstrap-javac,-create-import-jdk-stubs">
- <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes} ${apt.includes}"/>
+ <build-classes includes="${javac.includes} ${javadoc.includes} ${doclets.includes} ${javah.includes} ${javap.includes}"/>
</target>
<!-- clean -->
@@ -657,42 +657,6 @@
<!--
- **** apt targets.
- -->
-
- <target name="build-bootstrap-apt" depends="build-bootstrap-javac">
- <build-bootstrap-classes includes="${apt.includes}"/>
- <build-bootstrap-jar name="apt" includes="${apt.includes}"
- jarclasspath="javac.jar"/>
- <build-bootstrap-tool name="apt"/>
- </target>
-
- <target name="build-apt" depends="build-javac,build-classes-apt">
- <build-jar name="apt" includes="${apt.includes}" jarclasspath="javac.jar"/>
- <build-tool name="apt"/>
- </target>
-
- <target name="build-classes-apt" depends="build-classes-javac">
- <build-classes includes="${apt.includes}"/>
- </target>
-
- <target name="javadoc-apt" depends="build-apt,-def-javadoc-tool">
- <javadoc-tool name="apt" includes="${apt.includes}"/>
- </target>
-
-
- <target name="jtreg-apt" depends="build-apt,-def-jtreg">
- <jtreg-tool name="apt" tests="${apt.tests}"/>
- </target>
-
- <target name="findbugs-apt" depends="build-apt,-def-findbugs">
- <findbugs-tool name="apt"/>
- </target>
-
- <target name="apt" depends="build-apt,jtreg-apt,findbugs-apt"/>
-
-
- <!--
**** Create import JDK stubs.
-->
@@ -967,7 +931,6 @@
<filename name="java/"/>
<filename name="javax/"/>
<filename name="com/sun/javadoc/"/>
- <filename name="com/sun/mirror/"/>
<filename name="com/sun/source/"/>
</or>
</packageset>
@@ -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}">
<arg line="@{keywords}"/>
<arg line="@{options}"/>
<arg line="@{tests}"/>
--- a/langtools/make/netbeans/README Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/make/netbeans/README Fri Mar 02 09:13:13 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.
--- a/langtools/make/test/lib/apt.sh Thu Mar 01 15:31:33 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
--- a/langtools/make/test/lib/src.gold.txt Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/make/test/lib/src.gold.txt Fri Mar 02 09:13:13 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
--- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessor.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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}.
- *
- * <p> 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorEnvironment.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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 <i>specified</i> types.
- * The type declarations said to be <i>included</i> in this invocation
- * consist of the specified types and any types nested within them.
- *
- * <p> {@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 <tt>"-encoding"</tt>) to option value.
- * For an option with no value (such as <tt>"-help"</tt>), the
- * corresponding value in the map is <tt>null</tt>.
- *
- * <p> Options beginning with <tt>"-A"</tt> are <i>processor-specific.</i>
- * Such options are unrecognized by the tool, but intended to be used by
- * some annotation processor.
- *
- * @return the options passed to the tool
- */
- Map<String,String> 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<TypeDeclaration> 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 <i>included</i>}
- * 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<TypeDeclaration> getTypeDeclarations();
-
- /**
- * Returns the declarations annotated with the given annotation type.
- * Only declarations of the types
- * {@linkplain AnnotationProcessorEnvironment <i>included</i>}
- * 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<Declaration> 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorFactory.java Thu Mar 01 15:31:33 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 <i>support</i> these types.
- *
- * <p> Each implementation of an <tt>AnnotationProcessorFactory</tt>
- * 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 <tt>"-A"</tt>. For example, if this factory recognizes
- * options such as <tt>-Adebug -Aloglevel=3</tt>, it will
- * return the strings <tt>"-Adebug"</tt> and <tt>"-Aloglevel"</tt>.
- *
- * <p> 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<String> 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
- * <tt>"<i>name</i>.*"</tt>
- * representing the set of all annotation types
- * with canonical names beginning with <tt>"<i>name</i>."</tt>
- * Finally, <tt>"*"</tt> by itself represents the set of all
- * annotation types.
- *
- * @return the names of the annotation types supported by this factory
- */
- Collection<String> supportedAnnotationTypes();
-
- /**
- * Returns an annotation processor for a set of annotation
- * types. The set will be empty if the factory supports
- * "<tt>*</tt>" 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
- * <tt>AnnotationProcessorFactory</tt> 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 <tt>null</tt> if the types are not supported or the
- * processor cannot be created
- */
- AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env);
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessorListener.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/src/share/classes/com/sun/mirror/apt/AnnotationProcessors.java Thu Mar 01 15:31:33 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<AnnotationProcessor> aps =
- new LinkedList<AnnotationProcessor>();
-
- /**
- * Constructs a new composite annotation processor.
- * @param aps the component annotation processors
- */
- public CompositeAnnotationProcessor(Collection<AnnotationProcessor> 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 <tt>process</tt> 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<AnnotationProcessor> aps) {
- return new CompositeAnnotationProcessor(aps);
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/Filer.java Thu Mar 01 15:31:33 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 <i>auxiliary</i> files.
- *
- * <p> 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 <tt>-s</tt> and <tt>-d</tt>.)
- * Auxiliary files may be created in either location.
- *
- * <p> 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.
- *
- * <p> The {@linkplain java.nio.charset.Charset charset} used to
- * encode the file is determined by the implementation.
- * An annotation processing tool may have an <tt>-encoding</tt>
- * 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
- * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
- *
- * <p> 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
- * <tt>loc</tt>, <tt>pkg</tt>, and <tt>relPath</tt>.
- *
- * @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
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/Messager.java Thu Mar 01 15:31:33 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 <tt>Messager</tt> 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 <tt>printError(null, msg)</tt>.
- * @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 <tt>printWarning(null, msg)</tt>.
- * @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 <tt>printNotice(null, msg)</tt>.
- * @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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteEvent.java Thu Mar 01 15:31:33 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.
- *
- * <p>While this class extends the serializable <tt>EventObject</tt>, 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 <tt>AnnotationProcessorEnvironment</tt> 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();
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/RoundCompleteListener.java Thu Mar 01 15:31:33 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/RoundState.java Thu Mar 01 15:31:33 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 <tt>true</tt> if this was the last round of annotation
- * processing; returns <tt>false</tt> if there will be a subsequent round.
- */
- boolean finalRound();
-
- /**
- * Returns <tt>true</tt> if an error was raised in this round of processing;
- * returns <tt>false</tt> otherwise.
- */
- boolean errorRaised();
-
- /**
- * Returns <tt>true</tt> if new source files were created in this round of
- * processing; returns <tt>false</tt> otherwise.
- */
- boolean sourceFilesCreated();
-
- /**
- * Returns <tt>true</tt> if new class files were created in this round of
- * processing; returns <tt>false</tt> otherwise.
- */
- boolean classFilesCreated();
-}
--- a/langtools/src/share/classes/com/sun/mirror/apt/package-info.java Thu Mar 01 15:31:33 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.
- *
- * <p>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;
--- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationMirror.java Thu Mar 01 15:31:33 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.
- *
- * <p> Annotations should not be compared using reference-equality
- * ("<tt>==</tt>"). 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.
- *
- * <p>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<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeDeclaration.java Thu Mar 01 15:31:33 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<AnnotationTypeElementDeclaration> getMethods();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationTypeElementDeclaration.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/AnnotationValue.java Thu Mar 01 15:31:33 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:
- * <ul><li> a wrapper class (such as {@link Integer}) for a primitive type
- * <li> {@code String}
- * <li> {@code TypeMirror}
- * <li> {@code EnumConstantDeclaration}
- * <li> {@code AnnotationMirror}
- * <li> {@code Collection<AnnotationValue>}
- * (representing the elements, in order, if the value is an array)
- * </ul>
- *
- * @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.
- *
- * <p>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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/ClassDeclaration.java Thu Mar 01 15:31:33 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.
- *
- * <p> While a <tt>ClassDeclaration</tt> represents the <i>declaration</i>
- * of a class, a {@link ClassType} represents a class <i>type</i>.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * <p> {@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 <tt>java.lang.Object</tt>,
- * 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<ConstructorDeclaration> getConstructors();
-
- /**
- * {@inheritDoc}
- */
- Collection<MethodDeclaration> getMethods();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/ConstructorDeclaration.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/Declaration.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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 <tt>true</tt> 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 <tt>null</tt>
- * 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<AnnotationMirror> getAnnotationMirrors();
-
- /**
- * Returns the annotation of this declaration having the specified
- * type. The annotation may be either inherited or directly
- * present on this declaration.
- *
- * <p> The annotation returned by this method could contain an element
- * whose value is of type <tt>Class</tt>.
- * 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 <tt>Class</tt> 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 <tt>Class[]</tt>-valued element
- * will result in a {@link MirroredTypesException}.
- *
- * <blockquote>
- * <i>Note:</i> 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.
- * </blockquote>
- *
- * @param <A> the annotation type
- * @param annotationType the <tt>Class</tt> object corresponding to
- * the annotation type
- * @return the annotation of this declaration having the specified type
- *
- * @see #getAnnotationMirrors()
- */
- <A extends Annotation> A getAnnotation(Class<A> annotationType);
-
- /**
- * Returns the modifiers of this declaration, excluding annotations.
- * Implicit modifiers, such as the <tt>public</tt> and <tt>static</tt>
- * modifiers of interface members, are included.
- *
- * @return the modifiers of this declaration in undefined order;
- * an empty collection if there are none
- */
- Collection<Modifier> 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<E>} is <tt>"Set"</tt>.
- * 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 <tt>null</tt> if the position is unknown or not applicable.
- *
- * <p> 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/EnumConstantDeclaration.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/EnumDeclaration.java Thu Mar 01 15:31:33 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<EnumConstantDeclaration> getEnumConstants();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/ExecutableDeclaration.java Thu Mar 01 15:31:33 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 <tt>true</tt> if this method or constructor accepts a variable
- * number of arguments.
- *
- * @return <tt>true</tt> 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<TypeParameterDeclaration> 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<ParameterDeclaration> getParameters();
-
- /**
- * Returns the exceptions and other throwables listed in this
- * method or constructor's <tt>throws</tt> clause.
- *
- * @return the exceptions and other throwables listed in the
- * <tt>throws</tt> clause, or an empty collection if there are none
- */
- Collection<ReferenceType> getThrownTypes();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/FieldDeclaration.java Thu Mar 01 15:31:33 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 <tt>null</tt> otherwise.
- * The value will be of a primitive type or <tt>String</tt>.
- * 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 <tt>null</tt> otherwise
- */
- Object getConstantValue();
-
- /**
- * Returns the text of a <i>constant expression</i> representing the
- * value of this field if this field is a compile-time constant.
- * Returns <tt>null</tt> otherwise.
- * The value will be of a primitive type or <tt>String</tt>.
- * 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 <tt>null</tt> otherwise
- */
- String getConstantExpression();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/InterfaceDeclaration.java Thu Mar 01 15:31:33 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.
- *
- * <p> While an <tt>InterfaceDeclaration</tt> represents the
- * <i>declaration</i> of an interface, an {@link InterfaceType}
- * represents an interface <i>type</i>.
- * 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 {
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/MemberDeclaration.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/MethodDeclaration.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/Modifier.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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 <tt>public</tt> */ PUBLIC,
- /** The modifier <tt>protected</tt> */ PROTECTED,
- /** The modifier <tt>private</tt> */ PRIVATE,
- /** The modifier <tt>abstract</tt> */ ABSTRACT,
- /** The modifier <tt>static</tt> */ STATIC,
- /** The modifier <tt>final</tt> */ FINAL,
- /** The modifier <tt>transient</tt> */ TRANSIENT,
- /** The modifier <tt>volatile</tt> */ VOLATILE,
- /** The modifier <tt>synchronized</tt> */ SYNCHRONIZED,
- /** The modifier <tt>native</tt> */ NATIVE,
- /** The modifier <tt>strictfp</tt> */ 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;
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/PackageDeclaration.java Thu Mar 01 15:31:33 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.
- *
- * <p> {@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 <i>canonical</i> 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<ClassDeclaration> 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<EnumDeclaration> 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<InterfaceDeclaration> 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<AnnotationTypeDeclaration> getAnnotationTypes();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/ParameterDeclaration.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/TypeDeclaration.java Thu Mar 01 15:31:33 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.
- *
- * <p> <a name="DECL_VS_TYPE"></a>
- * While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
- * of a class or interface, a {@link DeclaredType} represents a class
- * or interface <i>type</i>, the latter being a use
- * (or <i>invocation</i>) 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<String>} and {@code java.util.Set<Number>}
- * (and many others), and to the raw type {@code java.util.Set}.
- *
- * <p> {@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 <i>canonical</i>
- * 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<E>} is <tt>"java.util.Set"</tt>.
- *
- * @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<TypeParameterDeclaration> 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<InterfaceType> 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<FieldDeclaration> 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
- * <tt>toString</tt>, that correspond to the methods of
- * <tt>java.lang.Object</tt>.
- *
- * @return the methods that are directly declared,
- * or an empty collection if there are none
- *
- * @see com.sun.mirror.util.DeclarationFilter
- */
- Collection<? extends MethodDeclaration> 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<TypeDeclaration> getNestedTypes();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/TypeParameterDeclaration.java Thu Mar 01 15:31:33 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 <i>extends</i> clause.
- * If there is no explicit <i>extends</i> clause, then
- * <tt>java.lang.Object</tt> is considered to be the sole bound.
- *
- * @return the bounds of this type parameter
- */
- Collection<ReferenceType> 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/declaration/package-info.java Thu Mar 01 15:31:33 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}.
- *
- * <p>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;
--- a/langtools/src/share/classes/com/sun/mirror/overview.html Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-
-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.
--->
-</head>
-
-<body bgcolor="white">
-
-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.
-
-<p> 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.
-
-
-<h4> Characteristics of the API </h4>
-
-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.
-
-<p> 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.
-
-<p> The API does not provide direct support for generating new code.
-
-
-<h4> Declarations and Types </h4>
-
-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 <tt>Declaration</tt> represents a
-program element such as a package, class, or method.
-The interface hierarchy is depicted
-<a href="com/sun/mirror/declaration/package-tree.html"> here</a>.
-
-<p> 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
-<a href="com/sun/mirror/type/package-tree.html"> here</a>.
-
-<p> 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
-<tt>java.util.Set</tt> defines the raw type <tt>java.util.Set</tt>,
-the parameterized type {@code java.util.Set<String>},
-and much more. Only the declaration can be annotated, for example,
-and only a type can appear in a method signature.
-
-<p> 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.
-
-
-<h4> Utilities and Tool Support </h4>
-
-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.
-
-<p> 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
-
-</body>
-</html>
--- a/langtools/src/share/classes/com/sun/mirror/type/AnnotationType.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/ArrayType.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/ClassType.java Thu Mar 01 15:31:33 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.
- *
- * <p> While a {@link ClassDeclaration} represents the <i>declaration</i>
- * of a class, a <tt>ClassType</tt> represents a class <i>type</i>.
- * 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 <tt>java.lang.Object</tt>,
- * for which this method returns <tt>null</tt>.
- *
- * <p> For example, the class type extended by
- * {@code java.util.TreeSet<String>} is
- * {@code java.util.AbstractSet<String>}.
- *
- * @return the class type that is a direct supertype of this one,
- * or <tt>null</tt> if there is none
- */
- ClassType getSuperclass();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/DeclaredType.java Thu Mar 01 15:31:33 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<String>}
- * as well as raw types.
- *
- * <p> While a <tt>TypeDeclaration</tt> represents the <i>declaration</i>
- * of a class or interface, a <tt>DeclaredType</tt> represents a class
- * or interface <i>type</i>, the latter being a use of the former.
- * See {@link TypeDeclaration} for more on this distinction.
- *
- * <p> A <tt>DeclaredType</tt> may represent a type
- * for which details (declaration, supertypes, <i>etc.</i>) are unknown.
- * This may be the result of a processing error, such as a missing class file,
- * and is indicated by {@link #getDeclaration()} returning <tt>null</tt>.
- * 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.
- *
- * <p> 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 <tt>null</tt> if this is a top-level type.
- *
- * <p> For example, the containing type of {@code O.I<S>}
- * is the type {@code O}, and the containing type of
- * {@code O<T>.I<S>} is the type {@code O<T>}.
- *
- * @return the type that contains this type,
- * or <tt>null</tt> 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<String>.Inner<Number>}), 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<TypeMirror> 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.
- *
- * <p> For example, the interface type extended by
- * {@code java.util.Set<String>} is {@code java.util.Collection<String>}.
- *
- * @return the interface types that are direct supertypes of this type,
- * or an empty collection if there are none
- */
- Collection<InterfaceType> getSuperinterfaces();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/EnumType.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/InterfaceType.java Thu Mar 01 15:31:33 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.
- *
- * <p> While an {@link InterfaceDeclaration} represents the
- * <i>declaration</i> of an interface, an <tt>InterfaceType</tt>
- * represents an interface <i>type</i>.
- * 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/MirroredTypeException.java Thu Mar 01 15:31:33 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 <tt>null</tt> 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 <tt>"void"</tt> for
- * the pseudo-type representing the type of <tt>void</tt>.
- *
- * @return the fully qualified name of the type being accessed
- */
- public String getQualifiedName() {
- return name;
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/MirroredTypesException.java Thu Mar 01 15:31:33 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<TypeMirror> types; // cannot be serialized
- private Collection<String> 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<TypeMirror> types) {
- super("Attempt to access Class objects for TypeMirrors " + types);
- this.types = types;
- names = new ArrayList<String>();
- 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 <tt>null</tt> if unavailable
- */
- public Collection<TypeMirror> 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 <tt>"void"</tt> for
- * the pseudo-type representing the type of <tt>void</tt>.
- *
- * @return the fully qualified names, in order, of the types being
- * accessed
- */
- public Collection<String> getQualifiedNames() {
- return Collections.unmodifiableCollection(names);
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/PrimitiveType.java Thu Mar 01 15:31:33 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
- * <tt>boolean</tt>, <tt>byte</tt>, <tt>short</tt>, <tt>int</tt>,
- * <tt>long</tt>, <tt>char</tt>, <tt>float</tt>, and <tt>double</tt>.
- *
- * @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 <tt>boolean</tt> */ BOOLEAN,
- /** The primitive type <tt>byte</tt> */ BYTE,
- /** The primitive type <tt>short</tt> */ SHORT,
- /** The primitive type <tt>int</tt> */ INT,
- /** The primitive type <tt>long</tt> */ LONG,
- /** The primitive type <tt>char</tt> */ CHAR,
- /** The primitive type <tt>float</tt> */ FLOAT,
- /** The primitive type <tt>double</tt> */ DOUBLE
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/ReferenceType.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/TypeMirror.java Thu Mar 01 15:31:33 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 <tt>void</tt>, are represented
- * by type mirrors as well.
- *
- * <p> 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 <tt>true</tt> 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/TypeVariable.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/VoidType.java Thu Mar 01 15:31:33 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 <tt>void</tt>.
- *
- * @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 {
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/WildcardType.java Thu Mar 01 15:31:33 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: <pre><tt>
- * ?
- * ? extends Number
- * ? super T
- * </tt></pre>
- *
- * <p> A wildcard may have its upper bound explicitly set by an
- * <tt>extends</tt> clause, its lower bound explicitly set by a
- * <tt>super</tt> 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<ReferenceType> 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<ReferenceType> getLowerBounds();
-}
--- a/langtools/src/share/classes/com/sun/mirror/type/package-info.java Thu Mar 01 15:31:33 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}.
- *
- * <p>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;
--- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationFilter.java Thu Mar 01 15:31:33 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 <i>select</i> or to <i>match</i> 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.
- *
- * <p> A subclass can create an arbitrary filter simply by implementing
- * the {@link #matches(Declaration)} method.
- *
- * <p> Examples.
- * <p> Selecting the <tt>public</tt> declarations from a collection:
- * <blockquote><pre>
- * result = FILTER_PUBLIC.filter(decls); </pre></blockquote>
- * Selecting class declarations (including enums):
- * <blockquote><pre>
- * classFilter = DeclarationFilter.getFilter(ClassDeclaration.class);
- * result = classFilter.filter(decls); </pre></blockquote>
- * Selecting class declarations but excluding enums:
- * <blockquote><pre>
- * enumFilter = DeclarationFilter.getFilter(EnumDeclaration.class);
- * compoundFilter = classFilter.and(enumFilter.not());
- * result = compoundFilter.filter(decls); </pre></blockquote>
- * Selecting declarations named "Bob":
- * <blockquote><pre>
- * nameFilter = new DeclarationFilter() {
- * public boolean matches(Declaration d) {
- * return d.getSimpleName().equals("Bob");
- * }
- * };
- * result = nameFilter.filter(decls); </pre></blockquote>
- *
- * @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 <tt>public</tt> declarations.
- */
- public static final DeclarationFilter FILTER_PUBLIC =
- new AccessFilter(PUBLIC);
-
- /**
- * A filter that selects only <tt>protected</tt> declarations.
- */
- public static final DeclarationFilter FILTER_PROTECTED =
- new AccessFilter(PROTECTED);
-
- /**
- * A filter that selects only <tt>public</tt> or <tt>protected</tt>
- * declarations.
- */
- public static final DeclarationFilter FILTER_PUBLIC_OR_PROTECTED =
- new AccessFilter(PUBLIC, PROTECTED);
-
- /**
- * A filter that selects only package-private (<i>default</i>)
- * declarations.
- */
- public static final DeclarationFilter FILTER_PACKAGE =
- new AccessFilter();
-
- /**
- * A filter that selects only <tt>private</tt> 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 <tt>mods</tt>
- */
- public static DeclarationFilter getFilter(
- final Collection<Modifier> 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<? extends Declaration> 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 <tt>true</tt>;
- * subclasses should override this.
- *
- * @param decl the declaration to match
- * @return <tt>true</tt> 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 <tt>filter</tt> offers control over the result type.
- *
- * @param <D> type of the declarations being filtered
- * @param decls declarations being filtered
- * @return the declarations matched by this filter
- */
- public <D extends Declaration> Collection<D> filter(Collection<D> decls) {
- ArrayList<D> res = new ArrayList<D>(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 <tt>filter</tt>, but the result type is specified explicitly.
- *
- * @param <D> type of the declarations being returned
- * @param decls declarations being filtered
- * @param resType type of the declarations being returned --
- * the reflective view of <tt>D</tt>
- * @return the declarations matched by this filter, restricted to those
- * of the specified type
- */
- public <D extends Declaration> Collection<D>
- filter(Collection<? extends Declaration> decls, Class<D> resType) {
- ArrayList<D> res = new ArrayList<D>(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<Modifier> 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));
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationScanner.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationVisitor.java Thu Mar 01 15:31:33 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
- * <tt>visit<i>Xxx</i></tt> 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/DeclarationVisitors.java Thu Mar 01 15:31:33 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 <tt>DeclarationVisitor</tt> 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 <tt>DeclarationVisitor</tt> 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.
- *
- * <p>The <tt>pre</tt> and <tt>post</tt>
- * <tt>DeclarationVisitor</tt> 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 <tt>DeclarationVisitor</tt> 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.
- *
- * <p>The <tt>pre</tt> and <tt>post</tt>
- * <tt>DeclarationVisitor</tt> 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/Declarations.java Thu Mar 01 15:31:33 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 <tt>true</tt> 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 <i>implement</i> the latter.
- *
- * @param sub the first method
- * @param sup the second method
- * @return <tt>true</tt> if and only if the first method overrides
- * the second
- */
- boolean overrides(MethodDeclaration sub, MethodDeclaration sup);
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/SimpleDeclarationVisitor.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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 <tt>SimpleDeclarationVisitor</tt>.
- */
- 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/SimpleTypeVisitor.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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 <tt>SimpleTypeVisitor</tt>.
- */
- 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/SourceOrderDeclScanner.java Thu Mar 01 15:31:33 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<Declaration> {
- 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<Declaration> 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<Declaration> decls = new
- TreeSet<Declaration>(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<Declaration> decls = new
- TreeSet<Declaration>(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<Declaration> decls = new
- TreeSet<Declaration>(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);
- }
-
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/SourcePosition.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/TypeVisitor.java Thu Mar 01 15:31:33 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 <tt>visit<i>Xxx</i></tt> 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/Types.java Thu Mar 01 15:31:33 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 <tt>true</tt> 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 <tt>true</tt> 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 <tt>void</tt>.
- *
- * @return the pseudo-type representing the type of <tt>void</tt>
- */
- 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<ReferenceType> upperBounds,
- Collection<ReferenceType> lowerBounds);
-
- /**
- * Returns the type corresponding to a type declaration and
- * actual type arguments.
- * Given the declaration for <tt>String</tt>, for example, this
- * method may be used to get the <tt>String</tt> type. It may
- * then be invoked a second time, with the declaration for <tt>Set</tt>,
- * to make the parameterized type {@code Set<String>}.
- *
- * <p> 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.
- *
- * <p> If a parameterized type is being returned, its declaration
- * must not be contained within a generic outer class.
- * The parameterized type {@code Outer<String>.Inner<Number>},
- * for example, may be constructed by first using this
- * method to get the type {@code Outer<String>}, 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<String>.Inner<Number>},
- * for example, may be constructed by first using
- * {@link #getDeclaredType(TypeDeclaration, TypeMirror...)}
- * to get the type {@code Outer<String>}, and then invoking
- * this method.
- *
- * <p> 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 <tt>null</tt>, this method is
- * equivalent to <tt>getDeclaredType(decl, typeArgs)</tt>.
- *
- * @param containing the containing type, or <tt>null</tt> 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);
-}
--- a/langtools/src/share/classes/com/sun/mirror/util/package-info.java Thu Mar 01 15:31:33 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}.
- *
- * <p>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;
--- a/langtools/src/share/classes/com/sun/tools/apt/Main.java Thu Mar 01 15:31:33 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.
- *
- * <p>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 <tt>null</tt>, a
- * <tt>NullPointerException</tt> is thrown.
- * @param args The command line parameters.
- */
- public static void main(String... args) {
- System.exit(process(args));
- }
-
- /** Programatic interface. If args is <tt>null</tt>, a
- * <tt>NullPointerException</tt> is thrown.
- * Output is directed to <tt>System.err</tt>.
- * @param args The command line parameters.
- */
- public static int process(String... args) {
- return processing(null, null, args);
- }
-
- /** Programmatic interface. If any argument
- * is <tt>null</tt>, a <tt>NullPointerException</tt> 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 <tt>factory</tt> or <tt>args</tt>
- * is <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
- * The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
- * command line parameters are ignored by this entry point.
- * Output is directed to <tt>System.err</tt>.
- *
- * @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 <tt>null</tt>, a <tt>NullPointerException</tt> is thrown.
- * The "<tt>-factory</tt>" and "<tt>-factorypath</tt>"
- * 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/comp/AnnotationProcessingError.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/comp/Apt.java Thu Mar 01 15:31:33 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.
- *
- * <p><b>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.</b>
- */
-@SuppressWarnings("deprecation")
-public class Apt extends ListBuffer<Env<AttrContext>> {
- java.util.Set<String> genSourceFileNames = new java.util.LinkedHashSet<String>();
- public java.util.Set<String> getSourceFileNames() {
- return genSourceFileNames;
- }
-
- /** List of names of generated class files.
- */
- java.util.Set<String> genClassFileNames = new java.util.LinkedHashSet<String>();
- public java.util.Set<String> getClassFileNames() {
- return genClassFileNames;
- }
-
- /* AptEnvironment */
- AptEnv aptenv;
-
- private Context context;
-
- /** The context key for the todo list. */
-
- protected static final Context.Key<Apt> aptKey =
- new Context.Key<Apt>();
-
- /** 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:
- *
- * <ul>
- *
- * <li> Generate list of canonical names of annotation types that
- * appear in source files given on the command line
- *
- * <li> Collect list of javac symbols representing source files
- * given on the command line
- *
- * </ul>
- */
- static class AptTreeScanner extends TreeScanner {
-
- // Set of fully qualified names of annotation types present in
- // examined source
- private Set<String> annotationSet;
-
- // Symbols to build bootstrapping declaration list
- private Collection<ClassSymbol> specifiedDeclCollection;
- private Collection<ClassSymbol> declCollection;
-
- public Set<String> getAnnotationSet() {
- return annotationSet;
- }
-
- public AptTreeScanner() {
- annotationSet = new LinkedHashSet<String>();
- specifiedDeclCollection = new LinkedHashSet<ClassSymbol>();
- declCollection = new LinkedHashSet<ClassSymbol>();
- }
-
- 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<String> computeAnnotationSet(Collection<ClassSymbol> classSymbols) {
- Set<String> annotationSet = new HashSet<String>();
-
- for(ClassSymbol classSymbol: classSymbols) {
- computeAnnotationSet(classSymbol, annotationSet);
- }
- return annotationSet;
- }
-
- void computeAnnotationSet(Symbol symbol, Set<String> 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<JCTree.JCCompilationUnit> treeList,
- ListBuffer<ClassSymbol> classes,
- Map<String, String> origOptions,
- ClassLoader aptCL,
- AnnotationProcessorFactory providedFactory,
- java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories) {
- Bark bark = Bark.instance(context);
- java.io.PrintWriter out = bark.getWriter(Log.WriterKind.WARNING);
- Options options = Options.instance(context);
-
- Collection<TypeDeclaration> spectypedecls = new LinkedHashSet<TypeDeclaration>();
- Collection<TypeDeclaration> typedecls = new LinkedHashSet<TypeDeclaration>();
- Set<String> unmatchedAnnotations = new LinkedHashSet<String>();
- Set<AnnotationTypeDeclaration> emptyATDS = Collections.emptySet();
- Set<Class<? extends AnnotationProcessorFactory> > currentRoundFactories =
- new LinkedHashSet<Class<? extends AnnotationProcessorFactory> >();
-
- // 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<String>(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<AnnotationTypeDeclaration>(),
- trivAPE);
- proc.process();
- } else {
- // Discovery process
-
- // List of annotation processory factory instances
- java.util.Iterator<AnnotationProcessorFactory> 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<AnnotationProcessorFactory> list =
- new LinkedList<AnnotationProcessorFactory>();
- 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<AnnotationProcessorFactory> iter =
- sun.misc.Service.providers(AnnotationProcessorFactory.class, aptCL);
- providers = iter;
-
- }
- }
-
- java.util.Map<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> factoryToAnnotation =
- new LinkedHashMap<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>>();
-
- 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<String> emptyStringSet = new HashSet<String>();
- emptyStringSet.add("");
- emptyStringSet = Collections.unmodifiableSet(emptyStringSet);
-
- while (providers.hasNext() ) {
- Object provider = providers.next();
- try {
- Set<String> matchedStrings = new HashSet<String>();
-
- AnnotationProcessorFactory apf = (AnnotationProcessorFactory) provider;
- Collection<String> supportedTypes = apf.supportedAnnotationTypes();
-
- Collection<Pattern> supportedTypePatterns = new LinkedList<Pattern>();
- 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<AnnotationTypeDeclaration> atds = new HashSet<AnnotationTypeDeclaration>();
-
- // 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<Class<? extends AnnotationProcessorFactory> > neglectedFactories =
- new LinkedHashSet<Class<? extends AnnotationProcessorFactory>>(productiveFactories);
- neglectedFactories.removeAll(currentRoundFactories);
- for(Class<? extends AnnotationProcessorFactory> 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<AnnotationProcessor> processors = new LinkedHashSet<AnnotationProcessor>();
-
- // 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<AnnotationProcessorFactory, Set<AnnotationTypeDeclaration>> 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<AnnotationProcessor> temp = new LinkedList<AnnotationProcessor>();
- 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;
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/comp/BootstrapAPF.java Thu Mar 01 15:31:33 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<String> supportedOptions =
- Collections.unmodifiableSet(new HashSet<String>());
-
- static Collection<String> supportedAnnotations;
- static {
- Collection<String> c = new HashSet<String>();
- c.add("*");
- supportedAnnotations = Collections.unmodifiableCollection(c);
- }
-
- public BootstrapAPF(){}
-
- public Collection<String> supportedOptions() {
- return BootstrapAPF.supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new PrintAP(env);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/comp/PrintAP.java Thu Mar 01 15:31:33 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<Modifier> EMPTY_ELIDES = Collections.emptySet();
- static Set<Modifier> INTERFACE_ELIDES = EnumSet.of(ABSTRACT);
- static Set<Modifier> ENUM_ELIDES = EnumSet.of(FINAL, ABSTRACT);
- static Set<Modifier> 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<EnumDeclaration, Integer> enumCardinality = new HashMap<EnumDeclaration, Integer>();
- Map<EnumDeclaration, Integer> enumConstVisited = new HashMap<EnumDeclaration, Integer>();
-
- 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<AnnotationMirror> annots) {
-
- for(AnnotationMirror annot: annots) {
- System.out.print(this.indent());
- System.out.print(annot.toString());
- System.out.println();
- }
- }
-
- private void printAnnotationsInline(Collection<AnnotationMirror> annots) {
-
- for(AnnotationMirror annot: annots) {
- System.out.print(annot);
- System.out.print(" ");
- }
- }
-
-
- private void printParameters(ExecutableDeclaration ex) {
-
- Collection<ParameterDeclaration> 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<Modifier> 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<Modifier> elides) {
- printAnnotationsInline(d.getAnnotationMirrors());
-
- for(Modifier m: adjustModifiers(d.getModifiers(), elides) ) {
- System.out.print(m.toString() + " ");
- }
- }
-
- private Collection<Modifier> adjustModifiers(Collection<Modifier> mods,
- Collection<Modifier> elides) {
- if (elides.isEmpty())
- return mods;
- else {
- Collection<Modifier> newMods = new LinkedHashSet<Modifier>();
- 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<TypeParameterDeclaration> 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<InterfaceType> 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<InterfaceType> interfaces = new HashSet<InterfaceType>(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<ReferenceType> 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<TypeDeclaration> typedecls = env.getSpecifiedTypeDeclarations();
-
- for (TypeDeclaration td: typedecls)
- td.accept((new PrintingVisitors(env)).getPrintingVisitor());
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/comp/UsageMessageNeededException.java Thu Mar 01 15:31:33 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;
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java Thu Mar 01 15:31:33 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;
-
-/**
- * <p><b>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.</b>
- */
-@SuppressWarnings("deprecation")
-public class AptJavaCompiler extends com.sun.tools.javac.main.JavaCompiler {
- /** The context key for the compiler. */
- protected static final Context.Key<AptJavaCompiler> compilerKey =
- new Context.Key<AptJavaCompiler>();
-
- /** 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<String> genSourceFileNames;
- java.util.Set<String> genClassFileNames;
-
- public java.util.Set<String> getSourceFileNames() {
- return genSourceFileNames;
- }
-
- /** List of names of generated class files.
- */
- public java.util.Set<String> getClassFileNames() {
- return genClassFileNames;
- }
-
- java.util.Set<java.io.File> aggregateGenFiles = java.util.Collections.emptySet();
-
- public java.util.Set<java.io.File> 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<String>();
- genClassFileNames = new java.util.LinkedHashSet<String>();
-
- // 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<ClassSymbol> compile(List<String> filenames,
- Map<String, String> origOptions,
- ClassLoader aptCL,
- AnnotationProcessorFactory providedFactory,
- java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories,
- java.util.Set<java.io.File> 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<ClassSymbol> classes = new ListBuffer<ClassSymbol>();
- try {
- JavacFileManager fm = (JavacFileManager)fileManager;
- //parse all files
- ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>();
- for (List<String> 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<JCCompilationUnit> 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();
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/main/CommandLine.java Thu Mar 01 15:31:33 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.
- *
- * <p><b>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.</b>
- */
-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<String> newArgs = new ListBuffer<String>();
- 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<String> 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();
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/main/Main.java Thu Mar 01 15:31:33 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.
- *
- * <p><b>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.</b>
- */
-@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<String,String> origOptions = new HashMap<String, String>();
-
- /** 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<String> sourceFileNames = new java.util.LinkedList<String>();
-
- /** The list of class files to process
- */
- java.util.List<String> classFileNames = new java.util.LinkedList<String>();
-
- /** List of top level names of generated source files from most recent apt round.
- */
- java.util.Set<String> genSourceFileNames = new java.util.LinkedHashSet<String>();
-
- /** List of names of generated class files from most recent apt round.
- */
- java.util.Set<String> genClassFileNames = new java.util.LinkedHashSet<String>();
-
- /**
- * List of all the generated source file names across all apt rounds.
- */
- java.util.Set<String> aggregateGenSourceFileNames = new java.util.LinkedHashSet<String>();
-
- /**
- * List of all the generated class file names across all apt rounds.
- */
- java.util.Set<String> aggregateGenClassFileNames = new java.util.LinkedHashSet<String>();
-
- /**
- * List of all the generated file names across all apt rounds.
- */
- java.util.Set<java.io.File> aggregateGenFiles = new java.util.LinkedHashSet<java.io.File>();
-
- /**
- * Set of all factories that have provided a processor on some apt round.
- */
- java.util.Set<Class<? extends AnnotationProcessorFactory> > productiveFactories =
- new java.util.LinkedHashSet<Class<? extends AnnotationProcessorFactory> >();
-
-
-
- /** 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<recognizedOptions.length; i++) {
- recognizedOptions[i].xhelp();
- }
- out.println();
- Bark.printRawLines(out, getLocalizedString("msg.usage.nonstandard.footer"));
- }
-
- /** Report a usage error.
- */
- void error(String key, Object... args) {
- warning(key, args);
- help();
- }
-
- /** Report a warning.
- */
- void warning(String key, Object... args) {
- Bark.printRawLines(out, ownName + ": "
- + getLocalizedString(key, args));
- }
-
- /** Process command line arguments: store all command line options
- * in `options' table and return all source filenames.
- * @param args The array of command line arguments.
- */
- protected java.util.List<String> 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<String> 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<String, String>(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<? extends File> 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<String> nameList = new java.util.LinkedList<String>();
- nameList.addAll(sourceFileNames);
- if (options.get("-XclassesAsDecls") != null)
- nameList.addAll(classFileNames);
-
- List<Symbol.ClassSymbol> 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<String>();
- classFileNames = new java.util.LinkedList<String>();
- }
- 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);
- }
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/AptEnv.java Thu Mar 01 15:31:33 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<AptEnv> aptEnvKey =
- new Context.Key<AptEnv>();
-
- 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.
- }
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/AnnotationProcessorEnvironmentImpl.java Thu Mar 01 15:31:33 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<TypeDeclaration> spectypedecls;
- Collection<TypeDeclaration> typedecls;
- Map<String, String> origOptions;
- DeclarationMaker declMaker;
- Declarations declUtils;
- Types typeUtils;
- Messager messager;
- FilerImpl filer;
- Bark bark;
- Set<RoundCompleteListener> roundCompleteListeners;
-
- public AnnotationProcessorEnvironmentImpl(Collection<TypeDeclaration> spectypedecls,
- Collection<TypeDeclaration> typedecls,
- Map<String, String> 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<RoundCompleteListener>();
- }
-
- public Map<String,String> getOptions() {
- return origOptions;
- }
-
- public Messager getMessager() {
- return messager;
- }
-
- public Filer getFiler() {
- return filer;
- }
-
- public Collection<TypeDeclaration> getSpecifiedTypeDeclarations() {
- return spectypedecls;
- }
-
- public PackageDeclaration getPackage(String name) {
- return declMaker.getPackageDeclaration(name);
- }
-
- public TypeDeclaration getTypeDeclaration(String name) {
- return declMaker.getTypeDeclaration(name);
- }
-
- public Collection<TypeDeclaration> getTypeDeclarations() {
- return typedecls;
- }
-
- public Collection<Declaration> 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<Declaration> decls;
- AnnotationTypeDeclaration atd;
- CollectingAP(AnnotationProcessorEnvironment env,
- AnnotationTypeDeclaration atd) {
- this.env = env;
- this.atd = atd;
- decls = new HashSet<Declaration>();
- }
-
- 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/FilerImpl.java Thu Mar 01 15:31:33 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<Location, File> locations; // where new files go
-
-
- private static final Context.Key<FilerImpl> filerKey =
- new Context.Key<FilerImpl>();
-
- // Set of files opened.
- private Collection<Flushable> wc;
-
- private Bark bark;
-
- // All created files.
- private final Set<File> filesCreated;
-
- // Names of newly created source files
- private HashSet<String> sourceFileNames = new HashSet<String>();
-
- // Names of newly created class files
- private HashSet<String> classFileNames = new HashSet<String>();
-
- 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<Flushable>();
-
- // Locations
- locations = new EnumMap<Location, File>(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<String> getSourceFileNames() {
- return sourceFileNames;
- }
-
- public Set<String> 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);
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/MessagerImpl.java Thu Mar 01 15:31:33 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<MessagerImpl> messagerKey =
- new Context.Key<MessagerImpl>();
-
- 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundCompleteEventImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/apt/RoundStateImpl.java Thu Mar 01 15:31:33 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<String,String> 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 + "]";
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationMirrorImpl.java Thu Mar 01 15:31:33 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<MethodSymbol, Attribute> 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<AnnotationTypeElementDeclaration, AnnotationValue>
- getElementValues() {
- Map<AnnotationTypeElementDeclaration, AnnotationValue> res =
- new LinkedHashMap<AnnotationTypeElementDeclaration,
- AnnotationValue>(); // whew!
- for (Pair<MethodSymbol, Attribute> 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java Thu Mar 01 15:31:33 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.
- *
- * <p> 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<? extends Annotation> annoType;
-
-
- private AnnotationProxyMaker(AptEnv env,
- Attribute.Compound attrs,
- Class<? extends Annotation> annoType) {
- this.env = env;
- this.attrs = attrs;
- this.annoType = annoType;
- }
-
-
- /**
- * Returns a dynamic proxy for an annotation mirror.
- */
- public static <A extends Annotation> A generateAnnotation(
- AptEnv env, Attribute.Compound attrs, Class<A> 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<String, Object> getAllReflectedValues() {
- Map<String, Object> res = new LinkedHashMap<String, Object>();
-
- for (Map.Entry<MethodSymbol, Attribute> 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<MethodSymbol, Attribute> getAllValues() {
- Map<MethodSymbol, Attribute> res =
- new LinkedHashMap<MethodSymbol, Attribute>();
-
- // 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<MethodSymbol, Attribute> 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<TypeMirror> elems = new ArrayList<TypeMirror>();
- 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<Enum<?>>)runtimeType, constName);
- }
- } else {
- value = null; // indicates a type mismatch
- }
- }
-
- public void visitCompound(Attribute.Compound c) {
- try {
- Class<? extends Annotation> 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 "<error>"; // eg: @Anno(value=<error>)
- }
- 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<TypeMirror> 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<TypeMirror> ts = ex.getTypeMirrors();
- return (ts != null)
- ? ts.hashCode()
- : ex.getQualifiedNames().hashCode();
- }
-
- public boolean equals(Object obj) {
- Collection<TypeMirror> ts = ex.getTypeMirrors();
- return ts != null &&
- obj instanceof MirroredTypesExceptionProxy &&
- ts.equals(
- ((MirroredTypesExceptionProxy) obj).ex.getTypeMirrors());
- }
-
- protected RuntimeException generateException() {
- return (RuntimeException) ex.fillInStackTrace();
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeDeclarationImpl.java Thu Mar 01 15:31:33 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<AnnotationTypeElementDeclaration> getMethods() {
- return identityFilter.filter(super.getMethods(),
- AnnotationTypeElementDeclaration.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public void accept(DeclarationVisitor v) {
- v.visitAnnotationTypeDeclaration(this);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationTypeElementDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationValueImpl.java Thu Mar 01 15:31:33 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<AnnotationValue> vals =
- new ArrayList<AnnotationValue>(a.values.length);
- for (Attribute elem : a.values) {
- vals.add(new AnnotationValueImpl(env, elem, annotation));
- }
- value = vals;
- }
-
- public void visitError(Attribute.Error e) {
- value = "<error>"; // javac will already have logged an error msg
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ClassDeclarationImpl.java Thu Mar 01 15:31:33 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 extends Annotation> A getAnnotation(Class<A> 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<ConstructorDeclaration> getConstructors() {
- ArrayList<ConstructorDeclaration> res =
- new ArrayList<ConstructorDeclaration>();
- for (Symbol s : getMembers(true)) {
- if (s.isConstructor()) {
- MethodSymbol m = (MethodSymbol) s;
- res.add((ConstructorDeclaration)
- env.declMaker.getExecutableDeclaration(m));
- }
- }
- return res;
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<MethodDeclaration> getMethods() {
- return identityFilter.filter(super.getMethods(),
- MethodDeclaration.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public void accept(DeclarationVisitor v) {
- v.visitClassDeclaration(this);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/Constants.java Thu Mar 01 15:31:33 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
- * <tt>getFormatter(new StringBuilder())</tt>.
- */
- 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 <= '~';
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ConstructorDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationImpl.java Thu Mar 01 15:31:33 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}
- * <p> 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}
- * <p> 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<AttrContext> enterEnv = getEnterEnv();
- if (enterEnv == null)
- return null;
- JCTree tree = TreeInfo.declarationFor(sym, enterEnv.tree);
- return enterEnv.toplevel.docComments.get(tree);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<AnnotationMirror> getAnnotationMirrors() {
- Collection<AnnotationMirror> res =
- new ArrayList<AnnotationMirror>();
- for (Attribute.Compound a : sym.getAnnotationMirrors()) {
- res.add(env.declMaker.getAnnotationMirror(a, this));
- }
- return res;
- }
-
- /**
- * {@inheritDoc}
- * Overridden by ClassDeclarationImpl to handle @Inherited.
- */
- public <A extends Annotation> A getAnnotation(Class<A> annoType) {
- return getAnnotation(annoType, sym);
- }
-
- protected <A extends Annotation> A getAnnotation(Class<A> 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<Modifier> modifiers = null;
-
- /**
- * {@inheritDoc}
- */
- public Collection<Modifier> 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<AttrContext> 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<Symbol> 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<Symbol> getMembers(boolean cache) {
- if (members != null) {
- return members;
- }
- LinkedList<Symbol> res = new LinkedList<Symbol>();
- 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<AttrContext> 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;
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/DeclarationMaker.java Thu Mar 01 15:31:33 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<DeclarationMaker> declarationMakerKey =
- new Context.Key<DeclarationMaker>();
-
- 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<PackageSymbol, PackageDeclaration> packageDecls =
- new HashMap<PackageSymbol, PackageDeclaration>();
-
- /**
- * 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<ClassSymbol, TypeDeclaration> typeDecls =
- new HashMap<ClassSymbol, TypeDeclaration>();
-
- /**
- * 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<MethodSymbol, ExecutableDeclaration> executableDecls =
- new HashMap<MethodSymbol, ExecutableDeclaration>();
-
- /**
- * 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<VarSymbol, FieldDeclaration> fieldDecls =
- new HashMap<VarSymbol, FieldDeclaration>();
-
- /**
- * 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumConstantDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/EnumDeclarationImpl.java Thu Mar 01 15:31:33 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<EnumConstantDeclaration> getEnumConstants() {
- return identityFilter.filter(getFields(),
- EnumConstantDeclaration.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public void accept(DeclarationVisitor v) {
- v.visitEnumDeclaration(this);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ExecutableDeclarationImpl.java Thu Mar 01 15:31:33 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<ParameterDeclaration> getParameters() {
- Collection<ParameterDeclaration> res =
- new ArrayList<ParameterDeclaration>();
- for (VarSymbol param : sym.params())
- res.add(env.declMaker.getParameterDeclaration(param));
- return res;
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<ReferenceType> getThrownTypes() {
- ArrayList<ReferenceType> res = new ArrayList<ReferenceType>();
- for (Type t : sym.type.getThrownTypes()) {
- res.add((ReferenceType) env.typeMaker.getType(t));
- }
- return res;
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/FieldDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/InterfaceDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/MemberDeclarationImpl.java Thu Mar 01 15:31:33 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<TypeParameterDeclaration> getFormalTypeParameters() {
- ArrayList<TypeParameterDeclaration> res =
- new ArrayList<TypeParameterDeclaration>();
- 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();
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/MethodDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/PackageDeclarationImpl.java Thu Mar 01 15:31:33 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<ClassDeclaration> getClasses() {
- return identityFilter.filter(getAllTypes(),
- ClassDeclaration.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<EnumDeclaration> getEnums() {
- return identityFilter.filter(getAllTypes(),
- EnumDeclaration.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<InterfaceDeclaration> getInterfaces() {
- return identityFilter.filter(getAllTypes(),
- InterfaceDeclaration.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<AnnotationTypeDeclaration> 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<TypeDeclaration> allTypes = null;
-
- /**
- * Caches and returns all top-level type declarations in this package.
- * Omits synthetic types.
- */
- private Collection<TypeDeclaration> getAllTypes() {
- if (allTypes != null) {
- return allTypes;
- }
- allTypes = new ArrayList<TypeDeclaration>();
- for (Symbol s : getMembers(false)) {
- allTypes.add(env.declMaker.getTypeDeclaration((ClassSymbol) s));
- }
- return allTypes;
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/ParameterDeclarationImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeDeclarationImpl.java Thu Mar 01 15:31:33 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<InterfaceType> getSuperinterfaces() {
- return env.typeMaker.getTypes(env.jctypes.interfaces(sym.type),
- InterfaceType.class);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<FieldDeclaration> getFields() {
- ArrayList<FieldDeclaration> res = new ArrayList<FieldDeclaration>();
- for (Symbol s : getMembers(true)) {
- if (s.kind == Kinds.VAR) {
- res.add(env.declMaker.getFieldDeclaration((VarSymbol) s));
- }
- }
- return res;
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<? extends MethodDeclaration> getMethods() {
- ArrayList<MethodDeclaration> res = new ArrayList<MethodDeclaration>();
- 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<TypeDeclaration> getNestedTypes() {
- ArrayList<TypeDeclaration> res = new ArrayList<TypeDeclaration>();
- 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();
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/declaration/TypeParameterDeclarationImpl.java Thu Mar 01 15:31:33 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<ReferenceType> getBounds() {
- ArrayList<ReferenceType> res = new ArrayList<ReferenceType>();
- 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<Type> getExtendsBounds(AptEnv env,
- Type.TypeVar tv) {
- return (tv.getUpperBound().tsym == env.symtab.objectType.tsym)
- ? com.sun.tools.javac.util.List.<Type>nil()
- : env.jctypes.getBounds(tv);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/AnnotationTypeImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/ArrayTypeImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/ClassTypeImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/DeclaredTypeImpl.java Thu Mar 01 15:31:33 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<TypeMirror> getActualTypeArguments() {
- return env.typeMaker.getTypes(type.getTypeArguments());
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<InterfaceType> 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();
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/EnumTypeImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/InterfaceTypeImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/PrimitiveTypeImpl.java Thu Mar 01 15:31:33 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();
- }
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeMaker.java Thu Mar 01 15:31:33 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<TypeMaker> typeMakerKey =
- new Context.Key<TypeMaker>();
-
- 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<TypeMirror> getTypes(Iterable<Type> 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 <T extends TypeMirror> Collection<T> getTypes(Iterable<Type> types,
- Class<T> resType) {
- ArrayList<T> res = new ArrayList<T>();
- 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeMirrorImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/TypeVariableImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/VoidTypeImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/type/WildcardTypeImpl.java Thu Mar 01 15:31:33 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<ReferenceType> getUpperBounds() {
- return type.isSuperBound()
- ? Collections.<ReferenceType>emptyList()
- : typeToCollection(type.type);
- }
-
- /**
- * {@inheritDoc}
- */
- public Collection<ReferenceType> getLowerBounds() {
- return type.isExtendsBound()
- ? Collections.<ReferenceType>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<ReferenceType> typeToCollection(Type type) {
- ArrayList<ReferenceType> res = new ArrayList<ReferenceType>(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();
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/util/DeclarationsImpl.java Thu Mar 01 15:31:33 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<Declarations> declarationsKey =
- new Context.Key<Declarations>();
-
- 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
- * <cite>The Java™ Language Specification</cite>
- */
- 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
- * <cite>The Java™ Language Specification</cite>
- */
- 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/util/SourcePositionImpl.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/mirror/util/TypesImpl.java Thu Mar 01 15:31:33 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<Types> typesKey =
- new Context.Key<Types>();
-
- 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<ReferenceType> upperBounds,
- Collection<ReferenceType> 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<Type> targs = new ListBuffer<Type>();
- 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));
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/apt/resources/apt.properties Thu Mar 01 15:31:33 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} <apt and javac options> <source files>\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=\
- <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.
--- a/langtools/src/share/classes/com/sun/tools/apt/resources/apt_ja.properties Thu Mar 01 15:31:33 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} <apt and javac options> <source files>\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=<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
--- a/langtools/src/share/classes/com/sun/tools/apt/resources/apt_zh_CN.properties Thu Mar 01 15:31:33 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} <apt and javac options> <source files>\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
--- a/langtools/src/share/classes/com/sun/tools/apt/util/Bark.java Thu Mar 01 15:31:33 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.
- *
- * <p><b>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.</b>
- */
-public class Bark extends Log {
- /** The context key for the bark. */
- protected static final Context.Key<Bark> barkKey =
- new Context.Key<Bark>();
-
- /**
- * 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<Bark>() {
- public Bark make(Context c) {
- return new Bark(c);
- }
- });
- context.put(Log.logKey, new Context.Factory<Log>() {
- 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));
- }
-}
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Mar 02 09:13:13 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;
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Mar 02 09:13:13 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;
--- a/langtools/test/tools/apt/Basics/Aggregate.java Thu Mar 01 15:31:33 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.");
- }
-}
--- a/langtools/test/tools/apt/Basics/ClassAnnotations.java Thu Mar 01 15:31:33 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;
- }
-}
--- a/langtools/test/tools/apt/Basics/FreshnessApf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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.");
- }
- }
-}
--- a/langtools/test/tools/apt/Basics/GenClass.java Thu Mar 01 15:31:33 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<T> {
-}
--- a/langtools/test/tools/apt/Basics/Indirect.java Thu Mar 01 15:31:33 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;
-}
--- a/langtools/test/tools/apt/Basics/Lacuna.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/test/tools/apt/Basics/MethodAnnotations.java Thu Mar 01 15:31:33 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;
- }
-}
--- a/langtools/test/tools/apt/Basics/Milk.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Basics/MisMatch.java Thu Mar 01 15:31:33 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;
-}
--- a/langtools/test/tools/apt/Basics/Misc.java Thu Mar 01 15:31:33 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<T> implements Marker2, Marker3 {
- private static final long longConstant = Long.MAX_VALUE;
-
- private static final String asciispecials = "\t\n\u0007";
-
- public void covar(Collection<? extends T> s) {return;}
-
- public void contravar(Collection<? super T> s) {return;}
-
- public <S> S varUse(int i) {return null;}
-
- Object o = (new Object() {}); // verify fix for 5019108
-}
-
-interface Marker1 {}
-
-interface Marker2 extends Marker1 {}
-
-interface Marker3 {}
--- a/langtools/test/tools/apt/Basics/MyMarker.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Basics/MySimple.java Thu Mar 01 15:31:33 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";
-}
--- a/langtools/test/tools/apt/Basics/NestedClassAnnotations.java Thu Mar 01 15:31:33 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;
- }
-}
--- a/langtools/test/tools/apt/Basics/ParameterAnnotations.java Thu Mar 01 15:31:33 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;
- }
-}
--- a/langtools/test/tools/apt/Basics/StaticFieldAnnotations.java Thu Mar 01 15:31:33 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;
- }
-}
--- a/langtools/test/tools/apt/Basics/StaticMethodAnnotations.java Thu Mar 01 15:31:33 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;
- }
-}
--- a/langtools/test/tools/apt/Basics/TestGetPackageApf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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.");
- }
- }
-}
--- a/langtools/test/tools/apt/Basics/TestGetTypeDeclarationApf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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 + "''.");
- }
- }
-
- }
- }
-}
--- a/langtools/test/tools/apt/Basics/annot/AnnotMarker.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Basics/annot/AnnotShangri_la.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Basics/annot/AnnotSimple.java Thu Mar 01 15:31:33 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";
-}
--- a/langtools/test/tools/apt/Basics/annot/annot2/AnnotMarker2.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Basics/annot/annot2/AnnotSimple2.java Thu Mar 01 15:31:33 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";
-}
--- a/langtools/test/tools/apt/Basics/apt.sh Thu Mar 01 15:31:33 2012 -0800
+++ b/langtools/test/tools/apt/Basics/apt.sh Fri Mar 02 09:13:13 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
--- a/langtools/test/tools/apt/Basics/com.sun.mirror.apt.AnnotationProcessorFactory Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-NullAPF
--- a/langtools/test/tools/apt/Basics/foo/bar/Baz.java Thu Mar 01 15:31:33 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 {
- }
- }
-
-}
--- a/langtools/test/tools/apt/Basics/foo/bar/Quux.java Thu Mar 01 15:31:33 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 {
- }
- }
-
-}
--- a/langtools/test/tools/apt/Basics/golden.txt Thu Mar 01 15:31:33 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]
--- a/langtools/test/tools/apt/Basics/goldenAggregate.txt Thu Mar 01 15:31:33 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();
-}
--- a/langtools/test/tools/apt/Basics/p1/p2.java Thu Mar 01 15:31:33 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 {}
-}
--- a/langtools/test/tools/apt/Basics/p1/p2/C1.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Basics/print.sh Thu Mar 01 15:31:33 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
--- a/langtools/test/tools/apt/Compile/ClassDeclApf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 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();
- }
-
- }
-
- }
-}
--- a/langtools/test/tools/apt/Compile/ClassDeclApf2.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 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);
- }
- }
- }
-}
--- a/langtools/test/tools/apt/Compile/Dummy1.java Thu Mar 01 15:31:33 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{}
--- a/langtools/test/tools/apt/Compile/ErrorAPF.java Thu Mar 01 15:31:33 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new ErrorAP(env);
- }
-}
--- a/langtools/test/tools/apt/Compile/HelloAnnotation.java Thu Mar 01 15:31:33 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);
-}
--- a/langtools/test/tools/apt/Compile/HelloWorld.java Thu Mar 01 15:31:33 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.");
- }
-}
--- a/langtools/test/tools/apt/Compile/Round1Apf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("Round1"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- private static int round = 0;
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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");
- }
- }
-}
--- a/langtools/test/tools/apt/Compile/Round2Apf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("Round2"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- private static int round = 0;
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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);
- }
- }
-}
--- a/langtools/test/tools/apt/Compile/Round3Apf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("Round3"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- private static int round = 0;
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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);
- }
- }
-}
--- a/langtools/test/tools/apt/Compile/Round4Apf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("Round4"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- private static int round = 0;
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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");
- }
- }
- }
-}
--- a/langtools/test/tools/apt/Compile/Rounds.java Thu Mar 01 15:31:33 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{}
--- a/langtools/test/tools/apt/Compile/StaticApf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 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();
- }
-
- }
-
- }
-}
--- a/langtools/test/tools/apt/Compile/WarnAPF.java Thu Mar 01 15:31:33 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<AnnotationTypeElementDeclaration,AnnotationValue> 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<AnnotationTypeElementDeclaration> 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = unmodifiableCollection(Arrays.asList(types));
- }
- public Collection<String> supportedAnnotationTypes() {return supportedTypes;}
-
- static final Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = unmodifiableCollection(Arrays.asList(options));
- }
- public Collection<String> supportedOptions() {return supportedOptions;}
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new WarnAP(env);
- }
-}
--- a/langtools/test/tools/apt/Compile/WrappedStaticApf.java Thu Mar 01 15:31:33 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));
- }
-}
--- a/langtools/test/tools/apt/Compile/compile.sh Thu Mar 01 15:31:33 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
--- a/langtools/test/tools/apt/Compile/golden.txt Thu Mar 01 15:31:33 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
--- a/langtools/test/tools/apt/Compile/goldenFactory.txt Thu Mar 01 15:31:33 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
--- a/langtools/test/tools/apt/Compile/goldenWarn.txt Thu Mar 01 15:31:33 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
--- a/langtools/test/tools/apt/Compile/servicesRound1 Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Round1Apf
--- a/langtools/test/tools/apt/Compile/servicesRound2 Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Round2Apf
--- a/langtools/test/tools/apt/Compile/servicesRound3 Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Round3Apf
--- a/langtools/test/tools/apt/Compile/servicesRound4 Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Round4Apf
--- a/langtools/test/tools/apt/Compile/servicesStaticApf Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-StaticApf
--- a/langtools/test/tools/apt/Compile/src/AhOneClass.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/test/tools/apt/Compile/src/AndAhTwoClass.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/test/tools/apt/Compile/src/Round1Class.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/test/tools/apt/Discovery/Dee.java Thu Mar 01 15:31:33 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<String> supportedTypes;
- static {
- String types[] = {"dum"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new DeeProc(env);
- }
-}
--- a/langtools/test/tools/apt/Discovery/Dum.java Thu Mar 01 15:31:33 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<String> supportedTypes;
- static {
- String types[] = {"dee"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new DumProc(env);
- }
-}
--- a/langtools/test/tools/apt/Discovery/Empty.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Discovery/PhantomTouch.java Thu Mar 01 15:31:33 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<String> supportedOptions;
- static final Collection<String> supportedTypes;
-
- static {
- String options[] = {""};
- supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
-
- String types[] = {"*"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- public Collection<String> supportedAnnotationTypes() {return supportedTypes;}
- public Collection<String> supportedOptions() {return supportedOptions;}
-
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new PhantomTouchProc(env);
- }
-}
--- a/langtools/test/tools/apt/Discovery/PhantomUpdate.java Thu Mar 01 15:31:33 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<? extends TypeElement> 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<String, String> actualOptions = processingEnv.getOptions();
- Map<String, String> expectedOptions = new LinkedHashMap<String, String>();
- 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);
- }
- }
-}
--- a/langtools/test/tools/apt/Discovery/Touch.java Thu Mar 01 15:31:33 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<TypeDeclaration> 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new TouchProc(env);
- }
-}
--- a/langtools/test/tools/apt/Discovery/discovery.sh Thu Mar 01 15:31:33 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;
--- a/langtools/test/tools/apt/Discovery/servicesBadTouch Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Touche
--- a/langtools/test/tools/apt/Discovery/servicesPhantomTouch Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-PhantomTouch
--- a/langtools/test/tools/apt/Discovery/servicesTouch Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Touch
--- a/langtools/test/tools/apt/Discovery/servicesTweedle Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Dee
-Dum
--- a/langtools/test/tools/apt/Misc/Marked.java Thu Mar 01 15:31:33 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 {};
-
-}
--- a/langtools/test/tools/apt/Misc/Marker.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/test/tools/apt/Misc/Misc.java Thu Mar 01 15:31:33 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<Declaration> 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- Collection<String> supportedOptions =
- Collections.unmodifiableCollection(new HashSet<String>());
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment ape) {
- return new MiscCheck(ape);
- }
-}
--- a/langtools/test/tools/apt/Misc/misc.sh Thu Mar 01 15:31:33 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;
--- a/langtools/test/tools/apt/Misc/servicesMisc Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Misc
-
--- a/langtools/test/tools/apt/Options/Marked.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/Options/Marker.java Thu Mar 01 15:31:33 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 {}
--- a/langtools/test/tools/apt/Options/OptionChecker.java Thu Mar 01 15:31:33 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<String, String> 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {"-Afoo", "-Abar"};
- supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- /*
- * Return the same processor independent of what annotations are
- * present, if any.
- */
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> 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);
- }
- }
-}
--- a/langtools/test/tools/apt/Options/options.sh Thu Mar 01 15:31:33 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;
--- a/langtools/test/tools/apt/Options/servicesOptions Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-OptionChecker
--- a/langtools/test/tools/apt/Scanners/Counter.java Thu Mar 01 15:31:33 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new CounterProc(env);
- }
-
-}
--- a/langtools/test/tools/apt/Scanners/MemberOrderApf.java Thu Mar 01 15:31:33 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<String> supportedAnnotations
- = unmodifiableCollection(Arrays.asList("*"));
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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<? extends Declaration> 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());
- }
- }
- }
-}
--- a/langtools/test/tools/apt/Scanners/Order.java Thu Mar 01 15:31:33 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();}
-}
--- a/langtools/test/tools/apt/Scanners/Scanner.java Thu Mar 01 15:31:33 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<AnnotationMirror> 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<AnnotationTypeElementDeclaration,AnnotationValue> 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<String> supportedTypes;
- static {
- String types[] = {"*"};
- supportedTypes = Collections.unmodifiableCollection(Arrays.asList(types));
- }
-
- static Collection<String> supportedOptions;
- static {
- String options[] = {""};
- supportedOptions = Collections.unmodifiableCollection(Arrays.asList(options));
- }
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedTypes;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
- AnnotationProcessorEnvironment env) {
- return new ScannerProc(env);
- }
-
-}
--- a/langtools/test/tools/apt/Scanners/TestEnum.java Thu Mar 01 15:31:33 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;
-}
--- a/langtools/test/tools/apt/Scanners/VisitOrder.java Thu Mar 01 15:31:33 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();
-}
--- a/langtools/test/tools/apt/Scanners/scanner.sh Thu Mar 01 15:31:33 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;
--- a/langtools/test/tools/apt/Scanners/servicesScanner Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Scanner
--- a/langtools/test/tools/apt/lib/Ignore.java Thu Mar 01 15:31:33 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 "";
-}
--- a/langtools/test/tools/apt/lib/Test.java Thu Mar 01 15:31:33 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;
-}
--- a/langtools/test/tools/apt/lib/TestProcessor.java Thu Mar 01 15:31:33 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);
- }
-}
--- a/langtools/test/tools/apt/lib/TestProcessorFactory.java Thu Mar 01 15:31:33 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<String> supportedOptions() {
- return new ArrayList<String>();
- }
-
- public Collection<String> supportedAnnotationTypes() {
- ArrayList<String> res = new ArrayList<String>();
- res.add("Test");
- res.add("Ignore");
- return res;
- }
-
- public AnnotationProcessor getProcessorFor(
- Set<AnnotationTypeDeclaration> 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);
- }
- }
-}
--- a/langtools/test/tools/apt/lib/Tester.java Thu Mar 01 15:31:33 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<String> as = new ArrayList<String>();
- 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;
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/AnnoMirror.java Thu Mar 01 15:31:33 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<AnnotationMirror> 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();
-}
--- a/langtools/test/tools/apt/mirror/declaration/AnnoTypeDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationTypeElementDeclaration> getMethods() {
- return at.getMethods();
- }
-}
-
-
-// An annotation type to use for testing.
-
-@interface AT {
- String s();
-}
--- a/langtools/test/tools/apt/mirror/declaration/AnnoTypeElemDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> getAnnotationMirrors() {
- return elem1.getAnnotationMirrors();
- }
-
- @Test(result=" Sed Quis custodiet ipsos custodes?\n")
- String getDocComment() {
- return elem1.getDocComment();
- }
-
- @Test(result={"public", "abstract"})
- Collection<Modifier> 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<TypeParameterDeclaration> getFormalTypeParameters() {
- return elem1.getFormalTypeParameters();
- }
-
- @Test(result={})
- Collection<ParameterDeclaration> getParameters() {
- return elem1.getParameters();
- }
-
- @Test(result={})
- Collection<ReferenceType> 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 {
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/AnnoVal.java Thu Mar 01 15:31:33 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<String> getValue() {
- Collection<String> res = new ArrayList<String>();
- AnnotationMirror anno = getAnno("getValue", "AT2");
-
- for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> 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<? extends java.lang.Number> 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<String> toStringTests() {
- Collection<String> res = new ArrayList<String>();
- AnnotationMirror anno = getAnno("getValue", "AT2");
-
- for (Map.Entry<AnnotationTypeElementDeclaration,AnnotationValue> 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<String> toStringFancy() {
- Collection<String> res = new ArrayList<String>();
- AnnotationMirror anno = getAnno("toStringFancy", "AT3");
-
- for (Map.Entry<AnnotationTypeElementDeclaration,AnnotationValue> 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<? extends Number> 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();
-}
--- a/langtools/test/tools/apt/mirror/declaration/ClassDecl.java Thu Mar 01 15:31:33 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<T> 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> getAnnotationMirrors() {
- return thisClassDecl.getAnnotationMirrors();
- }
-
- @Test(result=" Sed Quis custodiet ipsos custodes?\n")
- String getDocComment() {
- return thisClassDecl.getDocComment();
- }
-
- @Test(result={"public"})
- Collection<Modifier> 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<Modifier> 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<FieldDeclaration> getFields() {
- return thisClassDecl.getFields();
- }
-
- @Test(result={})
- Collection<TypeParameterDeclaration> getFormalTypeParameters1() {
- return thisClassDecl.getFormalTypeParameters();
- }
-
- @Test(result="T")
- Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
- return nested.getFormalTypeParameters();
- }
-
- @Test(result="ClassDecl.NestedClass<T>")
- Collection<TypeDeclaration> 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<InterfaceType> getSuperinterfaces() {
- return nested.getSuperinterfaces();
- }
-
-
- // ClassDeclaration methods
-
- @Test(result={"ClassDecl()", "ClassDecl(int)"})
- Collection<ConstructorDeclaration> getConstructors1() {
- return thisClassDecl.getConstructors();
- }
-
- // Check for default constructor.
- // 4997614: visitConstructionDeclaration reports info when there is no ctor
- @Test(result={"NestedClass()"})
- Collection<ConstructorDeclaration> getConstructors2() {
- return nested.getConstructors();
- }
-
- @Test(result={"m1()", "m2()", "m2(int)"})
- Collection<MethodDeclaration> 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/ConstExpr.java Thu Mar 01 15:31:33 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<String> getConstantExpression() {
- final Collection<String> res = new ArrayList<String>();
-
- thisClassDecl.accept(
- DeclarationVisitors.getSourceOrderDeclarationScanner(
- NO_OP,
- new SimpleDeclarationVisitor() {
- public void visitFieldDeclaration(FieldDeclaration f) {
- res.add(f.getConstantExpression());
- }
- }));
- return res;
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/ConstructorDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> getAnnotationMirrors() {
- return ctor.getAnnotationMirrors();
- }
-
- @Test(result=" Sed Quis custodiet ipsos custodes?\n")
- String getDocComment() {
- return ctor.getDocComment();
- }
-
- @Test(result={"public"})
- Collection<Modifier> 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<TypeParameterDeclaration> getFormalTypeParameters1() {
- return ctor.getFormalTypeParameters();
- }
-
- @Test(result={"N extends java.lang.Number"})
- Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
- return ctorInner.getFormalTypeParameters();
- }
-
- @Test(result={})
- Collection<ParameterDeclaration> 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<ParameterDeclaration> getParameters2() {
- return ctorInner.getParameters();
- }
-
- @Test(result={"java.lang.Throwable"})
- Collection<ReferenceType> getThrownTypes() {
- return ctorInner.getThrownTypes();
- }
-
- @Test(result="false")
- Boolean isVarArgs1() {
- return ctor.isVarArgs();
- }
-
- @Test(result="true")
- Boolean isVarArgs2() {
- return ctorInner.isVarArgs();
- }
-
-
- // toString
-
- @Test(result="<N extends java.lang.Number> 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 {
- <N extends Number> C2(N n1, N n2, String... ss) throws Throwable {
- }
- }
-}
-
-@interface AT1 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/EnumDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<ConstructorDeclaration> getConstructors() {
- return eDecl.getConstructors();
- }
-
- // 4989987: Verify synthetic enum constructor parameters are not visible
- @Test(result={"java.lang.String color"})
- Collection<ParameterDeclaration> getConstructorParams() {
- return eDecl.getConstructors().iterator().next().getParameters();
- }
-
- @Test(result={"values()", "valueOf(java.lang.String)"})
- Collection<MethodDeclaration> getMethods() {
- return eDecl.getMethods();
- }
-
- // 5010050: Cannot find parameter names for valueOf(String name) method...
- @Test(result={"java.lang.String name"})
- Collection<ParameterDeclaration> 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<EnumConstantDeclaration> 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;
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/FieldDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> getAnnotationMirrors() {
- return f1.getAnnotationMirrors();
- }
-
- @Test(result=" Sed Quis custodiet ipsos custodes?\n")
- String getDocComment() {
- return f1.getDocComment();
- }
-
- @Test(result={"public"})
- Collection<Modifier> 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<java.lang.String>")
- 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<String> aField = new ArrayList<String>();
-
- static int aStaticField;
-
- public static final boolean aConstantField = true;
-
-
- @interface AT1 {
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/GetAnno.java Thu Mar 01 15:31:33 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/InterfaceDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> 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<Modifier> 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<Modifier> 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<T extends java.lang.Number>")
- TypeDeclaration getDeclaringType2() {
- return nested.getDeclaringType();
- }
-
-
- // TypeDeclaration methods
-
- @Test(result={"i"})
- Collection<FieldDeclaration> getFields() {
- return iDecl.getFields();
- }
-
- @Test(result={"T extends java.lang.Number"})
- Collection<TypeParameterDeclaration> getFormalTypeParameters1() {
- return iDecl.getFormalTypeParameters();
- }
-
- @Test(result={})
- Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
- return nested.getFormalTypeParameters();
- }
-
- // 4993303: verify policy on Object methods being visible
- @Test(result={"m()", "toString()"})
- Collection<? extends MethodDeclaration> getMethods() {
- return nested.getMethods();
- }
-
- @Test(result="I.Nested")
- Collection<TypeDeclaration> 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<InterfaceType> getSuperinterfaces() {
- return iDecl.getSuperinterfaces();
- }
-}
-
-
-// Interfaces used for testing.
-
-/**
- * Sed Quis custodiet ipsos custodes?
- */
-@AT1
-@AT2
-interface I<T extends Number> extends Runnable {
- int i = 6;
- void m1();
- void m2();
- void m2(int j);
-
- interface Nested {
- void m();
- String toString();
- }
-}
-
-@interface AT1 {
-}
-
-@interface AT2 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/MethodDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> getAnnotationMirrors() {
- return meth1.getAnnotationMirrors();
- }
-
- @Test(result=" Sed Quis custodiet ipsos custodes?\n")
- String getDocComment() {
- return meth1.getDocComment();
- }
-
- @Test(result={"private", "static", "strictfp"})
- Collection<Modifier> getModifiers() {
- return meth1.getModifiers();
- }
-
- // Interface methods are implicitly public and abstract.
- @Test(result={"public", "abstract"})
- Collection<Modifier> 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<TypeParameterDeclaration> getFormalTypeParameters1() {
- return meth1.getFormalTypeParameters();
- }
-
- @Test(result={"T", "N extends java.lang.Number"},
- ordered=true)
- Collection<TypeParameterDeclaration> getFormalTypeParameters2() {
- return meth2.getFormalTypeParameters();
- }
-
- @Test(result={})
- Collection<ParameterDeclaration> getParameters1() {
- return meth1.getParameters();
- }
-
- @Test(result={"N n", "java.lang.String[] ss"},
- ordered=true)
- Collection<ParameterDeclaration> 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<ReferenceType> 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="<T, N extends java.lang.Number> 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 <T, N extends Number> 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/PackageDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> 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<Modifier> 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<AnnotationTypeDeclaration> getAnnotationTypes() {
- return pkg1.getAnnotationTypes();
- }
-
- @Test(result={"pkg1.AClass", "pkg1.AnEnum"})
- Collection<ClassDeclaration> getClasses() {
- return pkg1.getClasses();
- }
-
- @Test(result="pkg1.AnEnum")
- Collection<EnumDeclaration> getEnums() {
- return pkg1.getEnums();
- }
-
- @Test(result={"pkg1.AnInterface", "pkg1.AnAnnoType"})
- Collection<InterfaceDeclaration> getInterfaces() {
- return pkg1.getInterfaces();
- }
-
- @Test(result="pkg1")
- String getQualifiedName1() {
- return pkg1.getQualifiedName();
- }
-
- @Test(result="pkg1.pkg2")
- String getQualifiedName2() {
- return pkg2.getQualifiedName();
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/ParameterDecl.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<AnnotationMirror> getAnnotationMirrors() {
- return p1.getAnnotationMirrors();
- }
-
- @Test(result={"final"})
- Collection<Modifier> 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);
- }
-}
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/AClass.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/AnAnnoType.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/AnEnum.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/AnInterface.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/package-info.java Thu Mar 01 15:31:33 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;
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/AnInterface.java Thu Mar 01 15:31:33 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 {
-}
--- a/langtools/test/tools/apt/mirror/declaration/pkg1/pkg2/package.html Thu Mar 01 15:31:33 2012 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<!--
-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.
--->
-
-</head>
-<body bgcolor="white">
-
-Herein lieth the package comment.
-An HTML file it be, and wonderous to behold.
-
-</body>
-</html>
--- a/langtools/test/tools/apt/mirror/type/AnnoTyp.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/type/ArrayTyp.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/type/ClassTyp.java Thu Mar 01 15:31:33 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<T1,T2> extends Tester {
-
- public static void main(String[] args) {
- (new ClassTyp()).run();
- }
-
-
- // Declarations used by tests
-
- static class C1<S> extends AbstractSet<S> implements Set<S> {
- class C2<R> {
- }
-
- static class C3<R> {
- class C4<Q> {
- }
- }
-
- public Iterator<S> iterator() {
- return null;
- }
-
- public int size() {
- return 0;
- }
- }
-
-
- // Generate some class types to test.
- private C1<T1> f0;
- private C1<String> f1;
- private C1 f2;
- private C1.C3<T2> f3;
- private C1<T1>.C2<T2> f4;
- private C1.C2 f5;
- private C1<T1> f6;
- private C1.C3<T2>.C4<T1> 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<T1,T2> 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<T1> is same type as C1<T1>
- @Test(result="true")
- boolean equals4() {
- return t[0].equals(t[6]);
- }
-
- @Test(result={
- "ClassTyp.C1<T1>",
- "ClassTyp.C1<java.lang.String>",
- "ClassTyp.C1",
- "ClassTyp.C1.C3<T2>",
- "ClassTyp.C1<T1>.C2<T2>",
- "ClassTyp.C1.C2",
- "ClassTyp.C1<T1>",
- "ClassTyp.C1.C3<T2>.C4<T1>"
- },
- ordered=true)
- Collection<String> toStringTests() {
- Collection<String> res = new ArrayList<String>();
- for (ClassType c : t) {
- res.add(c.toString());
- }
- return res;
- }
-
-
- // DeclaredType methods
-
- @Test(result={"T1"})
- Collection<TypeMirror> getActualTypeArguments1() {
- return t[0].getActualTypeArguments();
- }
-
- @Test(result={})
- Collection<TypeMirror> getActualTypeArguments2() {
- return t[2].getActualTypeArguments();
- }
-
- @Test(result={"T2"})
- Collection<TypeMirror> 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<T1>")
- DeclaredType getContainingType4() {
- return t[4].getContainingType();
- }
-
- @Test(result={"java.util.Set<T1>"})
- Collection<InterfaceType> getSuperinterfaces() {
- return t[0].getSuperinterfaces();
- }
-
-
- // ClassType methods
-
- @Test(result="ClassTyp.C1<S>")
- ClassDeclaration getDeclaration1() {
- return t[0].getDeclaration();
- }
-
- @Test(result="ClassTyp.C1.C3<R>")
- ClassDeclaration getDeclaration2() {
- return t[3].getDeclaration();
- }
-
- @Test(result="ClassTyp.C1<S>.C2<R>")
- ClassDeclaration getDeclaration3a() {
- return t[4].getDeclaration();
- }
-
- @Test(result="ClassTyp.C1<S>.C2<R>")
- ClassDeclaration getDeclaration3b() {
- return t[5].getDeclaration();
- }
-
- @Test(result="true")
- boolean getDeclarationEq() {
- return t[0].getDeclaration() == t[6].getDeclaration();
- }
-
- @Test(result="java.util.AbstractSet<T1>")
- 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/type/EnumTyp.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/type/InterfaceTyp.java Thu Mar 01 15:31:33 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<T1,T2> extends Tester {
-
- public static void main(String[] args) {
- (new InterfaceTyp()).run();
- }
-
-
- // Declarations used by tests
-
- interface I1<S> extends Set<String> {
- interface I2<R> {
- }
- }
-
-
- // Generate some interface types to test
- private I1<T1> f0;
- private I1<String> f1;
- private I1 f2;
- private I1.I2<String> f3;
- private I1.I2 f4;
- private I1<T1> f5;
- private I3<T1> 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<T1> is same type as I1<T1>
- @Test(result="true")
- boolean equals4() {
- return t[0].equals(t[5]);
- }
-
- @Test(result={
- "InterfaceTyp.I1<T1>",
- "InterfaceTyp.I1<java.lang.String>",
- "InterfaceTyp.I1",
- "InterfaceTyp.I1.I2<java.lang.String>",
- "InterfaceTyp.I1.I2",
- "InterfaceTyp.I1<T1>",
- "I3<T1>"
- },
- ordered=true)
- Collection<String> toStringTests() {
- Collection<String> res = new ArrayList<String>();
- for (InterfaceType i : t) {
- res.add(i.toString());
- }
- return res;
- }
-
-
- // DeclaredType methods
-
- @Test(result={"T1"})
- Collection<TypeMirror> getActualTypeArguments1() {
- return t[0].getActualTypeArguments();
- }
-
- @Test(result={})
- Collection<TypeMirror> getActualTypeArguments2() {
- return t[2].getActualTypeArguments();
- }
-
- @Test(result={"java.lang.String"})
- Collection<TypeMirror> 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<java.lang.String>"})
- Collection<InterfaceType> getSuperinterfaces() {
- return t[0].getSuperinterfaces();
- }
-
-
-
- // InterfaceType method
-
- @Test(result="InterfaceTyp.I1<S>")
- InterfaceDeclaration getDeclaration1() {
- return t[0].getDeclaration();
- }
-
- @Test(result="InterfaceTyp.I1.I2<R>")
- InterfaceDeclaration getDeclaration2a() {
- return t[3].getDeclaration();
- }
-
- @Test(result="InterfaceTyp.I1.I2<R>")
- 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<T> {
-}
--- a/langtools/test/tools/apt/mirror/type/PrimitiveTyp.java Thu Mar 01 15:31:33 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/type/TypeVar.java Thu Mar 01 15:31:33 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<T, S extends Number & Runnable> 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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();
- }
-}
--- a/langtools/test/tools/apt/mirror/type/WildcardTyp.java Thu Mar 01 15:31:33 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<T> {
- }
-
- interface G1<N extends Number & Runnable> {
- }
-
- interface G2<T extends G2<T>> {
- }
-
- // Some wildcard types to test.
- private G<?> f0; // unbound
- private G<? extends Number> f1; // covariant
- private G<? super Number> f2; // contravariant
- private G<? extends Object> f3; // <sigh>
- 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<String> accept() {
- final Collection<String> res = new ArrayList<String>();
-
- 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<String> toStringTests() {
- Collection<String> res = new ArrayList<String>();
- 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<ReferenceType> getLowerBounds() {
- Collection<ReferenceType> res = new ArrayList<ReferenceType>();
- for (WildcardType w : t) {
- Collection<ReferenceType> 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<ReferenceType> getUpperBounds() {
- Collection<ReferenceType> res = new ArrayList<ReferenceType>();
- for (WildcardType w : t) {
- Collection<ReferenceType> 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;
- }
-}
--- a/langtools/test/tools/apt/mirror/util/Overrides.java Thu Mar 01 15:31:33 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<Boolean> 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));
- }
-}
--- a/langtools/test/tools/apt/mirror/util/TypeCreation.java Thu Mar 01 15:31:33 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<T> {
- class I<S> {
- }
- }
-
-
- 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<ReferenceType> uppers = new ArrayList<ReferenceType>();
- Collection<ReferenceType> downers = new ArrayList<ReferenceType>();
- uppers.add(AType);
- return types.getWildcardType(uppers, downers);
- }
-
- @Test(result="TypeCreation.O<java.lang.String>")
- DeclaredType getDeclaredType1() {
- TypeDeclaration stringDecl = env.getTypeDeclaration("java.lang.String");
- DeclaredType stringType = types.getDeclaredType(stringDecl);
- return types.getDeclaredType(O, stringType);
- }
-
- @Test(result="TypeCreation.O<java.lang.String>.I<java.lang.Number>")
- DeclaredType getDeclaredType2() {
- TypeDeclaration numDecl = env.getTypeDeclaration("java.lang.Number");
- DeclaredType numType = types.getDeclaredType(numDecl);
- DeclaredType OType = getDeclaredType1();
- return types.getDeclaredType(OType, I, numType);
- }
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7142086/T7142086.java Fri Mar 02 09:13:13 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<JavaFileObject> 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<JavaFileObject> 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<JavaFileObject> {
+
+ boolean errorFound;
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+ throw new AssertionError("unexpected diagnostic: " + diagnostic.getMessage(Locale.getDefault()));
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7142672/AnnoProcessor.java Fri Mar 02 09:13:13 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<? extends TypeElement> set, RoundEnvironment re) {
+ System.out.println("RUNNING...");
+ if(set.isEmpty()) {
+ return false;
+ }
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7142672/Bug.java Fri Mar 02 09:13:13 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<? super javax.tools.JavaFileObject> dl =
+ new DiagnosticListener<javax.tools.JavaFileObject>() {
+ 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<String> opts = new ArrayList<String>();
+ 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);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7142672/Test2.java Fri Mar 02 09:13:13 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 {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7142672/Test3.java Fri Mar 02 09:13:13 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 {
+}