--- a/jdk/make/com/sun/tools/attach/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/com/sun/tools/attach/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -24,6 +24,8 @@
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../../..
PACKAGE = com.sun.tools.attach
LIBRARY = attach
--- a/jdk/make/common/Defs-linux.gmk Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/common/Defs-linux.gmk Mon Apr 23 16:58:40 2012 -0700
@@ -131,8 +131,9 @@
# Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
# JDK build to import .debuginfo or .diz files from the HotSpot build.
# However, adding FDS support to the JDK build will occur in phases
- # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
- # is used to indicate that a particular library supports FDS.
+ # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+ # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
+ # particular library or program supports FDS.
ifeq ($(OBJCOPY),)
_JUNK_ := $(shell \
@@ -156,9 +157,7 @@
_JUNK_ := $(shell \
echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
- # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
- # changes are promoted
- ZIP_DEBUGINFO_FILES ?= 0
+ ZIP_DEBUGINFO_FILES ?= 1
_JUNK_ := $(shell \
echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
@@ -261,6 +260,17 @@
CFLAGS_REQUIRED += $(DEBUG_FLAG)
endif
+# If Full Debug Symbols is enabled, then we want the same debug and
+# optimization flags as used by FASTDEBUG.
+#
+ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(VARIANT), OPT)
+ CC_OPT = $(DEBUG_FLAG) $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+ endif
+ endif
+endif
+
CFLAGS_OPT = $(CC_OPT)
CFLAGS_DBG = $(DEBUG_FLAG)
CFLAGS_COMMON += $(CFLAGS_REQUIRED)
--- a/jdk/make/common/Defs-solaris.gmk Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/common/Defs-solaris.gmk Mon Apr 23 16:58:40 2012 -0700
@@ -138,8 +138,9 @@
# Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
# JDK build to import .debuginfo or .diz files from the HotSpot build.
# However, adding FDS support to the JDK build will occur in phases
- # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
- # is used to indicate that a particular library supports FDS.
+ # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+ # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
+ # particular library or program supports FDS.
ifeq ($(OBJCOPY),)
_JUNK_ := $(shell \
@@ -164,9 +165,7 @@
_JUNK_ := $(shell \
echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
- # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
- # changes are promoted
- ZIP_DEBUGINFO_FILES ?= 0
+ ZIP_DEBUGINFO_FILES ?= 1
_JUNK_ := $(shell \
echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
@@ -240,6 +239,21 @@
CXXFLAGS_DEBUG_OPTION = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
endif
+# If Full Debug Symbols is enabled, then we want the same debug and
+# optimization flags as used by FASTDEBUG. We also want all the
+# debug info in one place (-xs).
+#
+ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(VARIANT), OPT)
+ CC_OPT = -g -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+ CXX_OPT = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+ endif
+ CFLAGS_DEBUG_OPTION += -xs
+ CXXFLAGS_DEBUG_OPTION += -xs
+ endif
+endif
+
CFLAGS_COMMON = -L$(OBJDIR)
# Do not allow C99 language features like declarations in code etc.
--- a/jdk/make/common/Defs-windows.gmk Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/common/Defs-windows.gmk Mon Apr 23 16:58:40 2012 -0700
@@ -113,9 +113,7 @@
echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
- # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
- # changes are promoted
- ZIP_DEBUGINFO_FILES ?= 0
+ ZIP_DEBUGINFO_FILES ?= 1
else
ZIP_DEBUGINFO_FILES=0
endif
--- a/jdk/make/common/Library.gmk Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/common/Library.gmk Mon Apr 23 16:58:40 2012 -0700
@@ -181,8 +181,17 @@
$(CP) $(OBJDIR)/$(@F) $@
@$(call binary_file_verification,$@)
ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(ZIP_DEBUGINFO_FILES),1)
+ (set -e ; \
+ $(CD) $(OBJDIR) ; \
+ $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).map $(LIBRARY).pdb ; \
+ )
+ $(CP) $(OBJDIR)/$(LIBRARY).diz $(@D)
+ $(RM) $(OBJDIR)/$(LIBRARY).map $(OBJDIR)/$(LIBRARY).pdb
+ else
$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
+ endif
endif
endif # LIBRARY
@@ -248,6 +257,37 @@
ifeq ($(WRITE_LIBVERSION),true)
$(MCS) -d -a "$(FULL_VERSION)" $@
endif # WRITE_LIBVERSION
+ ifneq ($(PLATFORM), macosx)
+ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+ (set -e ; \
+ $(CD) $(@D) ; \
+ $(OBJCOPY) --only-keep-debug $(@F) $(LIBRARY).debuginfo ; \
+ $(OBJCOPY) --add-gnu-debuglink=$(LIBRARY).debuginfo $(@F) ; \
+ )
+ ifeq ($(STRIP_POLICY),all_strip)
+ $(STRIP) $@
+ else
+ ifeq ($(STRIP_POLICY),min_strip)
+ ifeq ($(PLATFORM), solaris)
+ $(STRIP) -x $@
+ else
+ # assume Linux
+ $(STRIP) -g $@
+ endif
+ # implied else here is no stripping at all
+ endif
+ endif
+ ifeq ($(ZIP_DEBUGINFO_FILES),1)
+ (set -e ; \
+ $(CD) $(@D) ; \
+ $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).debuginfo ; \
+ $(RM) $(LIBRARY).debuginfo ; \
+ )
+ endif
+ endif # LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+ endif # ENABLE_FULL_DEBUG_SYMBOLS
+ endif # PLATFORM-!macosx
endif # LIBRARY
endif # PLATFORM
--- a/jdk/make/common/Program.gmk Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/common/Program.gmk Mon Apr 23 16:58:40 2012 -0700
@@ -189,6 +189,15 @@
$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
endif
@$(call binary_file_verification,$@)
+ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(ZIP_DEBUGINFO_FILES),1)
+ (set -e ; \
+ $(CD) $(OBJDIR) ; \
+ $(ZIPEXE) -q $(PROGRAM).diz $(PROGRAM).map $(PROGRAM).pdb ; \
+ $(RM) $(PROGRAM).map $(PROGRAM).pdb ; \
+ )
+ endif
+ endif
else
#
# Note that we have to link -lthread even when USE_PTHREADS is true.
@@ -232,6 +241,42 @@
-codesign -s openjdk_codesign $@
endif
@$(call binary_file_verification,$@)
+ ifneq ($(PLATFORM), macosx)
+ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+ ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+ (set -e ; \
+ $(CD) $(@D) ; \
+ $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
+ $(OBJCOPY) --add-gnu-debuglink=$(@F).debuginfo $(@F) ; \
+ )
+ ifeq ($(STRIP_POLICY),all_strip)
+ $(STRIP) $@
+ else
+ ifeq ($(STRIP_POLICY),min_strip)
+ ifeq ($(PLATFORM), solaris)
+ $(STRIP) -x $@
+ else
+ # assume Linux
+ $(STRIP) -g $@
+ endif
+ # implied else here is no stripping at all
+ endif
+ endif
+ ifeq ($(ZIP_DEBUGINFO_FILES),1)
+ (set -e ; \
+ $(CD) $(@D) ; \
+ $(ZIPEXE) -q $(@F).diz $(@F).debuginfo ; \
+ $(RM) $(@F).debuginfo ; \
+ )
+ # save ZIP'ed debug info with rest of the program's build artifacts
+ $(MV) $@.diz $(OBJDIR)
+ else
+ # save debug info with rest of the program's build artifacts
+ $(MV) $@.debuginfo $(OBJDIR)
+ endif
+ endif # PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
+ endif # ENABLE_FULL_DEBUG_SYMBOLS
+ endif # PLATFORM-!macosx
endif # PLATFORM
clean::
@@ -240,12 +285,16 @@
$(RM) $(OBJDIR)/$(PROGRAM).ico
$(RM) $(OBJDIR)/$(PROGRAM).lcf
$(RM) $(OBJDIR)/$(PROGRAM).map
+ $(RM) $(OBJDIR)/$(PROGRAM).pdb
$(RM) $(OBJDIR)/$(PROGRAM).exp
$(RM) $(OBJDIR)/$(PROGRAM).lib
$(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
$(RM) $(OBJDIR)/$(PROGRAM).ilk
$(RM) *.pdb
+else
+ $(RM) $(OBJDIR)/$(PROGRAM).debuginfo
endif
+ $(RM) $(OBJDIR)/$(PROGRAM).diz
clobber::
--- a/jdk/make/common/Release.gmk Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/common/Release.gmk Mon Apr 23 16:58:40 2012 -0700
@@ -873,7 +873,9 @@
-o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
else
$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
- $(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+# The FILE command reports .debuginfo files as "ELF", but we don't want
+# those files in the JRE_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
+ $(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
endif
@@ -1140,9 +1142,11 @@
else
$(RM) $@
$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
- $(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
+# The FILE command reports .debuginfo files as "ELF", but we don't want
+# those files in the JDK_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
+ $(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
- file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+ file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
| $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
endif
--- a/jdk/make/java/instrument/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/instrument/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -26,6 +26,8 @@
# Makefile for building the Java Programming Language Instrumentation Services
# agent, supporting java.lang.instrument
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
PACKAGE = sun.instrument
LIBRARY = instrument
--- a/jdk/make/java/java/reflect/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/java/reflect/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -36,7 +36,7 @@
#
# Files to compile.
#
-AUTO_FILES_JAVA_DIRS = java/lang/reflect sun/reflect
+AUTO_FILES_JAVA_DIRS = java/lang/reflect sun/reflect java/lang/annotation
#
# Install .lib file.
--- a/jdk/make/java/java_crw_demo/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/java_crw_demo/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
LIBRARY = java_crw_demo
--- a/jdk/make/java/java_hprof_demo/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/java_hprof_demo/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
LIBRARY = hprof
PRODUCT = sun
--- a/jdk/make/java/main/java/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/main/java/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -23,6 +23,8 @@
# questions.
#
+PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PROGRAM = java
PRODUCT = java
--- a/jdk/make/java/management/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/management/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
PACKAGE = java.lang.management
LIBRARY = management
--- a/jdk/make/java/npt/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/npt/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
# It's currently used by jpda and hprof. Put it in base module for now.
--- a/jdk/make/java/verify/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/java/verify/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -27,6 +27,8 @@
# Build libverify.so
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
PRODUCT = java
LIBRARY = verify
--- a/jdk/make/jpda/jdwp/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/jpda/jdwp/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2000, 2005, 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
@@ -27,6 +27,8 @@
# Makefile for building JDWP
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../..
PACKAGE = com.sun.tools.jdwp
PRODUCT = jpda
--- a/jdk/make/jpda/transport/socket/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/jpda/transport/socket/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -27,6 +27,8 @@
# Makefile for building the JDI back-end implementation
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
LIBRARY = dt_socket
PRODUCT = jbug
--- a/jdk/make/launchers/Makefile.launcher Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/launchers/Makefile.launcher Mon Apr 23 16:58:40 2012 -0700
@@ -27,6 +27,8 @@
# Makefile for building simple launchers
#
+PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ..
PACKAGE = launcher
PRODUCT = sun
--- a/jdk/make/mkdemo/jvmti/compiledMethodLoad/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/compiledMethodLoad/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = compiledMethodLoad
--- a/jdk/make/mkdemo/jvmti/gctest/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/gctest/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = gctest
--- a/jdk/make/mkdemo/jvmti/heapTracker/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/heapTracker/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = heapTracker
--- a/jdk/make/mkdemo/jvmti/heapViewer/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/heapViewer/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = heapViewer
--- a/jdk/make/mkdemo/jvmti/hprof/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/hprof/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 2010, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = hprof
--- a/jdk/make/mkdemo/jvmti/minst/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/minst/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = minst
--- a/jdk/make/mkdemo/jvmti/mtrace/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/mtrace/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = mtrace
--- a/jdk/make/mkdemo/jvmti/versionCheck/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/versionCheck/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = versionCheck
--- a/jdk/make/mkdemo/jvmti/waiters/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/mkdemo/jvmti/waiters/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2004, 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
@@ -23,6 +23,8 @@
# questions.
#
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = waiters
--- a/jdk/make/sun/font/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/sun/font/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -62,7 +62,7 @@
java/text/Bidi.java \
sun/font/FileFont.java \
sun/font/FileFontStrike.java \
- sun/font/FontManager.java \
+ sun/font/SunFontManager.java \
sun/font/GlyphList.java \
sun/font/NativeFont.java \
sun/font/StrikeCache.java \
--- a/jdk/make/sun/font/t2k/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/sun/font/t2k/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -52,7 +52,6 @@
FILES_export = \
java/awt/Font.java \
sun/font/FileFont.java \
- sun/font/FontManager.java \
sun/font/GlyphList.java \
sun/font/NativeFont.java \
sun/font/StrikeCache.java \
--- a/jdk/make/sun/tracing/dtrace/Makefile Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/make/sun/tracing/dtrace/Makefile Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 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,6 +26,9 @@
#
# Makefile for building dtrace extension
#
+
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
BUILDDIR = ../../..
PACKAGE = sun.tracing.dtrace
LIBRARY = jsdt
--- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Mon Apr 23 16:58:40 2012 -0700
@@ -213,16 +213,8 @@
SwingUtilities3.setDelegateRepaintManager(delegate, new RepaintManager() {
@Override
public void addDirtyRegion(final JComponent c, final int x, final int y, final int w, final int h) {
- if (SunToolkit.isDispatchThreadForAppContext(getTarget())) {
- synchronized (getDelegateLock()) {
- if (getDelegate().isPaintingForPrint()) {
- return;
- }
- }
- }
- Rectangle res = SwingUtilities.convertRectangle(
- c, new Rectangle(x, y, w, h), getDelegate());
- repaintPeer(res);
+ repaintPeer(SwingUtilities.convertRectangle(
+ c, new Rectangle(x, y, w, h), getDelegate()));
}
});
}
@@ -616,6 +608,17 @@
windowLocation.y + locationInWindow.y);
}
+ /**
+ * Returns the cursor of the peer, which is cursor of the target by default,
+ * but peer can override this behavior.
+ *
+ * @param p Point relative to the peer.
+ * @return Cursor of the peer or null if default cursor should be used.
+ */
+ protected Cursor getCursor(final Point p) {
+ return getTarget().getCursor();
+ }
+
@Override
public void setBackground(final Color c) {
final Color oldBg = getBackground();
@@ -982,16 +985,23 @@
// DropTargetPeer Method
@Override
public void addDropTarget(DropTarget dt) {
- synchronized (dropTargetLock){
- // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
- // if it's the first (or last) one for the component. Otherwise this call is a no-op.
- if (++fNumDropTargets == 1) {
- // Having a non-null drop target would be an error but let's check just in case:
- if (fDropTarget != null)
- System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
+ LWWindowPeer winPeer = getWindowPeerOrSelf();
+ if (winPeer != null && winPeer != this) {
+ // We need to register the DropTarget in the
+ // peer of the window ancestor of the component
+ winPeer.addDropTarget(dt);
+ } else {
+ synchronized (dropTargetLock) {
+ // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
+ // if it's the first (or last) one for the component. Otherwise this call is a no-op.
+ if (++fNumDropTargets == 1) {
+ // Having a non-null drop target would be an error but let's check just in case:
+ if (fDropTarget != null)
+ System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
- // Create a new drop target:
- fDropTarget = CDropTarget.createDropTarget(dt, target, this);
+ // Create a new drop target:
+ fDropTarget = CDropTarget.createDropTarget(dt, target, this);
+ }
}
}
}
@@ -999,17 +1009,24 @@
// DropTargetPeer Method
@Override
public void removeDropTarget(DropTarget dt) {
- synchronized (dropTargetLock){
- // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
- // if it's the first (or last) one for the component. Otherwise this call is a no-op.
- if (--fNumDropTargets == 0) {
- // Having a null drop target would be an error but let's check just in case:
- if (fDropTarget != null) {
- // Dispose of the drop target:
- fDropTarget.dispose();
- fDropTarget = null;
- } else
- System.err.println("CComponent.removeDropTarget(): current drop target is null.");
+ LWWindowPeer winPeer = getWindowPeerOrSelf();
+ if (winPeer != null && winPeer != this) {
+ // We need to unregister the DropTarget in the
+ // peer of the window ancestor of the component
+ winPeer.removeDropTarget(dt);
+ } else {
+ synchronized (dropTargetLock){
+ // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
+ // if it's the first (or last) one for the component. Otherwise this call is a no-op.
+ if (--fNumDropTargets == 0) {
+ // Having a null drop target would be an error but let's check just in case:
+ if (fDropTarget != null) {
+ // Dispose of the drop target:
+ fDropTarget.dispose();
+ fDropTarget = null;
+ } else
+ System.err.println("CComponent.removeDropTarget(): current drop target is null.");
+ }
}
}
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWCursorManager.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWCursorManager.java Mon Apr 23 16:58:40 2012 -0700
@@ -36,32 +36,34 @@
public abstract class LWCursorManager {
- // A flag to indicate if the update is scheduled, so we don't
- // process it twice
- private AtomicBoolean updatePending = new AtomicBoolean(false);
+ /**
+ * A flag to indicate if the update is scheduled, so we don't process it
+ * twice.
+ */
+ private final AtomicBoolean updatePending = new AtomicBoolean(false);
protected LWCursorManager() {
}
- /*
+ /**
* Sets the cursor to correspond the component currently under mouse.
*
* This method should not be executed on the toolkit thread as it
* calls to user code (e.g. Container.findComponentAt).
*/
- public void updateCursor() {
+ public final void updateCursor() {
updatePending.set(false);
updateCursorImpl();
}
- /*
+ /**
* Schedules updating the cursor on the corresponding event dispatch
* thread for the given window.
*
* This method is called on the toolkit thread as a result of a
* native update cursor request (e.g. WM_SETCURSOR on Windows).
*/
- public void updateCursorLater(LWWindowPeer window) {
+ public final void updateCursorLater(final LWWindowPeer window) {
if (updatePending.compareAndSet(false, true)) {
Runnable r = new Runnable() {
@Override
@@ -74,45 +76,58 @@
}
private void updateCursorImpl() {
- LWWindowPeer windowUnderCursor = LWWindowPeer.getWindowUnderCursor();
- Point cursorPos = getCursorPosition();
- LWComponentPeer<?, ?> componentUnderCursor = null;
- // TODO: it's possible to get the component under cursor directly as
- // it's stored in LWWindowPee anyway (lastMouseEventPeer)
- if (windowUnderCursor != null) {
- componentUnderCursor = windowUnderCursor.findPeerAt(cursorPos.x, cursorPos.y);
+ final Point cursorPos = getCursorPosition();
+ final Component c = findComponent(cursorPos);
+ final Cursor cursor;
+ final Object peer = LWToolkit.targetToPeer(c);
+ if (peer instanceof LWComponentPeer) {
+ final LWComponentPeer<?, ?> lwpeer = (LWComponentPeer<?, ?>) peer;
+ final Point p = lwpeer.getLocationOnScreen();
+ cursor = lwpeer.getCursor(new Point(cursorPos.x - p.x,
+ cursorPos.y - p.y));
+ } else {
+ cursor = (c != null) ? c.getCursor() : null;
}
- Cursor cursor = null;
- if (componentUnderCursor != null) {
- Component c = componentUnderCursor.getTarget();
+ // TODO: default cursor for modal blocked windows
+ setCursor(cursor);
+ }
+
+ /**
+ * Returns the first visible, enabled and showing component under cursor.
+ *
+ * @param cursorPos Current cursor position.
+ * @return Component
+ */
+ private static final Component findComponent(final Point cursorPos) {
+ final LWComponentPeer<?, ?> peer = LWWindowPeer.getPeerUnderCursor();
+ Component c = null;
+ if (peer != null) {
+ c = peer.getTarget();
if (c instanceof Container) {
- Point p = componentUnderCursor.getLocationOnScreen();
- c = ((Container)c).findComponentAt(cursorPos.x - p.x, cursorPos.y - p.y);
+ final Point p = peer.getLocationOnScreen();
+ c = ((Container) c).findComponentAt(cursorPos.x - p.x,
+ cursorPos.y - p.y);
}
- // Traverse up to the first visible, enabled and showing component
while (c != null) {
if (c.isVisible() && c.isEnabled() && (c.getPeer() != null)) {
break;
}
c = c.getParent();
}
- if (c != null) {
- cursor = c.getCursor();
- }
}
- // TODO: default cursor for modal blocked windows
- setCursor(windowUnderCursor, cursor);
+ return c;
}
- /*
+ /**
* Returns the current cursor position.
*/
// TODO: make it public to reuse for MouseInfo
protected abstract Point getCursorPosition();
- /*
- * Sets a cursor. The cursor can be null if the mouse is not over a Java window.
+ /**
+ * Sets a cursor. The cursor can be null if the mouse is not over a Java
+ * window.
+ * @param cursor the new {@code Cursor}.
*/
- protected abstract void setCursor(LWWindowPeer windowUnderCursor, Cursor cursor);
-
+ protected abstract void setCursor(Cursor cursor);
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWRepaintArea.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWRepaintArea.java Mon Apr 23 16:58:40 2012 -0700
@@ -39,12 +39,8 @@
@Override
protected void updateComponent(final Component comp, final Graphics g) {
if (comp != null) {
- final LWComponentPeer peer = (LWComponentPeer) comp.getPeer();
- if (peer != null) {
- peer.paintPeer(g);
- }
super.updateComponent(comp, g);
- flushBuffers(peer);
+ flushBuffers((LWComponentPeer) comp.getPeer());
}
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java Mon Apr 23 16:58:40 2012 -0700
@@ -27,6 +27,7 @@
package sun.lwawt;
import java.awt.Component;
+import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.TextArea;
@@ -72,6 +73,15 @@
}
@Override
+ protected Cursor getCursor(final Point p) {
+ final boolean isContains;
+ synchronized (getDelegateLock()) {
+ isContains = getDelegate().getViewport().getBounds().contains(p);
+ }
+ return isContains ? super.getCursor(p) : null;
+ }
+
+ @Override
protected Component getDelegateFocusOwner() {
return getTextComponent();
}
--- a/jdk/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java Mon Apr 23 16:58:40 2012 -0700
@@ -31,6 +31,7 @@
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
import java.awt.peer.TextFieldPeer;
import javax.swing.JPasswordField;
@@ -97,6 +98,21 @@
getText(), e.getWhen(), e.getModifiers()));
}
+ /**
+ * Restoring native behavior. We should sets the selection range to zero,
+ * when component lost its focus.
+ *
+ * @param e the focus event
+ */
+ @Override
+ protected void handleJavaFocusEvent(final FocusEvent e) {
+ if (e.getID() == FocusEvent.FOCUS_LOST) {
+ // In order to de-select the selection
+ setCaretPosition(0);
+ }
+ super.handleJavaFocusEvent(e);
+ }
+
private final class JTextAreaDelegate extends JPasswordField {
// Empty non private constructor was added because access to this
--- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Mon Apr 23 16:58:40 2012 -0700
@@ -784,9 +784,8 @@
}
mouseClickButtons &= ~eventButtonMask;
}
-
- notifyUpdateCursor();
}
+ notifyUpdateCursor();
}
public void dispatchMouseWheelEvent(long when, int x, int y, int modifiers,
@@ -1057,6 +1056,10 @@
return lastMouseEventPeer != null ? lastMouseEventPeer.getWindowPeerOrSelf() : null;
}
+ public static LWComponentPeer<?, ?> getPeerUnderCursor() {
+ return lastMouseEventPeer;
+ }
+
public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
if (focusLog.isLoggable(PlatformLogger.FINE)) {
focusLog.fine("requesting native focus to " + this);
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java Mon Apr 23 16:58:40 2012 -0700
@@ -25,24 +25,26 @@
package sun.lwawt.macosx;
-import java.awt.*;
+import sun.lwawt.LWCursorManager;
+
+import java.awt.Cursor;
+import java.awt.Point;
import java.awt.geom.Point2D;
-import sun.lwawt.*;
+final class CCursorManager extends LWCursorManager {
-public class CCursorManager extends LWCursorManager {
private static native Point2D nativeGetCursorPosition();
private static native void nativeSetBuiltInCursor(final int type, final String name);
private static native void nativeSetCustomCursor(final long imgPtr, final double x, final double y);
private static final int NAMED_CURSOR = -1;
- private final static CCursorManager theInstance = new CCursorManager();
+ private static final CCursorManager theInstance = new CCursorManager();
public static CCursorManager getInstance() {
return theInstance;
}
- Cursor currentCursor;
+ private volatile Cursor currentCursor;
private CCursorManager() { }
@@ -62,8 +64,11 @@
}
@Override
- protected void setCursor(final LWWindowPeer windowUnderCursor, final Cursor cursor) {
- if (cursor == currentCursor) return;
+ protected void setCursor(final Cursor cursor) {
+ if (cursor == currentCursor) {
+ return;
+ }
+ currentCursor = cursor;
if (cursor == null) {
nativeSetBuiltInCursor(Cursor.DEFAULT_CURSOR, null);
@@ -71,10 +76,12 @@
}
if (cursor instanceof CCustomCursor) {
- final CCustomCursor customCursor = ((CCustomCursor)cursor);
+ final CCustomCursor customCursor = (CCustomCursor) cursor;
final long imagePtr = customCursor.getImageData();
- final Point hotSpot = customCursor.getHotSpot();
- if(imagePtr != 0L) nativeSetCustomCursor(imagePtr, hotSpot.x, hotSpot.y);
+ if (imagePtr != 0L) {
+ final Point hotSpot = customCursor.getHotSpot();
+ nativeSetCustomCursor(imagePtr, hotSpot.x, hotSpot.y);
+ }
return;
}
@@ -94,13 +101,6 @@
throw new RuntimeException("Unimplemented");
}
- static long getNativeWindow(final LWWindowPeer window) {
- if (window == null) return 0;
- final CPlatformWindow platformWindow = (CPlatformWindow)window.getPlatformWindow();
- if (platformWindow == null) return 0;
- return platformWindow.getNSWindowPtr();
- }
-
// package private methods to handle cursor change during drag-and-drop
private boolean isDragging = false;
private Point dragPos = null;
@@ -109,9 +109,7 @@
if (isDragging) {
throw new RuntimeException("Invalid Drag state in CCursorManager!");
}
-
isDragging = true;
-
dragPos = new Point(x, y);
}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Mon Apr 23 16:58:40 2012 -0700
@@ -89,12 +89,19 @@
}
public void handleKeyEvent(int eventType, int modifierFlags, String characters,
+ String charsIgnoringMods, boolean isRepeat, short keyCode,
+ boolean needsKeyTyped) {
+ responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode, needsKeyTyped);
+ }
+
+ // REMIND: delete this method once 'deploy' changes for 7156194 is pushed
+ public void handleKeyEvent(int eventType, int modifierFlags, String characters,
String charsIgnoringMods, boolean isRepeat, short keyCode) {
- responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode);
+ handleKeyEvent(eventType, modifierFlags, characters, charsIgnoringMods, isRepeat, keyCode, true);
}
public void handleInputEvent(String text) {
- new RuntimeException("Not implemented");
+ responder.handleInputEvent(text);
}
public void handleFocusEvent(boolean focused) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CImage.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CImage.java Mon Apr 23 16:58:40 2012 -0700
@@ -29,10 +29,14 @@
import java.awt.geom.Dimension2D;
import java.awt.image.*;
+import java.util.Arrays;
+import java.util.List;
+
import sun.awt.image.SunWritableRaster;
public class CImage extends CFRetainedResource {
private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
+ private static native long nativeCreateNSImageFromArrays(int[][] buffers, int w[], int h[]);
private static native long nativeCreateNSImageFromFileContents(String file);
private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
private static native long nativeCreateNSImageFromImageName(String name);
@@ -93,8 +97,7 @@
return createImageUsingNativeSize(nativeCreateNSImageFromImageName(name));
}
- // This is used to create a CImage from a Image
- public CImage createFromImage(final Image image) {
+ private static int[] imageToArray(Image image) {
if (image == null) return null;
MediaTracker mt = new MediaTracker(new Label());
@@ -117,8 +120,50 @@
g2.setComposite(AlphaComposite.Src);
g2.drawImage(image, 0, 0, null);
g2.dispose();
- int[] buffer = ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
- return new CImage(nativeCreateNSImageFromArray(buffer, w, h));
+ return ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
+ }
+
+ // This is used to create a CImage from a Image
+ public CImage createFromImage(final Image image) {
+ int[] buffer = imageToArray(image);
+ if (buffer == null) {
+ return null;
+ }
+ return new CImage(nativeCreateNSImageFromArray(buffer, image.getWidth(null), image.getHeight(null)));
+ }
+
+ public CImage createFromImages(List<Image> images) {
+ if (images == null || images.isEmpty()) {
+ return null;
+ }
+
+ int num = images.size();
+
+ int[][] buffers = new int[num][];
+ int[] w = new int[num];
+ int[] h = new int[num];
+
+ num = 0;
+
+ for (Image img : images) {
+ buffers[num] = imageToArray(img);
+ if (buffers[num] == null) {
+ // Unable to process the image
+ continue;
+ }
+ w[num] = img.getWidth(null);
+ h[num] = img.getHeight(null);
+ num++;
+ }
+
+ if (num == 0) {
+ return null;
+ }
+
+ return new CImage(nativeCreateNSImageFromArrays(
+ Arrays.copyOf(buffers, num),
+ Arrays.copyOf(w, num),
+ Arrays.copyOf(h, num)));
}
static int getSelectorAsInt(final String fromString) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java Mon Apr 23 16:58:40 2012 -0700
@@ -117,7 +117,7 @@
* Handles key events.
*/
void handleKeyEvent(int eventType, int modifierFlags, String chars,
- short keyCode) {
+ short keyCode, boolean needsKeyTyped) {
boolean isFlagsChangedEvent =
isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
(eventType == CocoaConstants.NSFlagsChanged);
@@ -158,11 +158,24 @@
NSEvent.nsToJavaEventType(eventType);
}
+ char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
+ // Some keys may generate a KEY_TYPED, but we can't determine
+ // what that character is. That's likely a bug, but for now we
+ // just check for CHAR_UNDEFINED.
+ if (javaChar == KeyEvent.CHAR_UNDEFINED) {
+ postsTyped = false;
+ }
+
+
int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
long when = System.currentTimeMillis();
peer.dispatchKeyEvent(jeventType, when, jmodifiers,
- jkeyCode, testChar, jkeyLocation);
+ jkeyCode, javaChar, jkeyLocation);
+
+ // Current browser may be sending input events, so don't
+ // post the KEY_TYPED here.
+ postsTyped &= needsKeyTyped;
// That's the reaction on the PRESSED (not RELEASED) event as it comes to
// appear in MacOSX.
@@ -172,8 +185,23 @@
boolean isMetaDown = (jmodifiers & KeyEvent.META_DOWN_MASK) != 0;
if (jeventType == KeyEvent.KEY_PRESSED && postsTyped && !isMetaDown) {
peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
- KeyEvent.VK_UNDEFINED, testChar,
+ KeyEvent.VK_UNDEFINED, javaChar,
KeyEvent.KEY_LOCATION_UNKNOWN);
}
}
+
+ void handleInputEvent(String text) {
+ if (text != null) {
+ int index = 0, length = text.length();
+ char c;
+ while (index < length) {
+ c = text.charAt(index);
+ peer.dispatchKeyEvent(KeyEvent.KEY_TYPED,
+ System.currentTimeMillis(),
+ 0, KeyEvent.VK_UNDEFINED, c,
+ KeyEvent.KEY_LOCATION_UNKNOWN);
+ index++;
+ }
+ }
+ }
}
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Mon Apr 23 16:58:40 2012 -0700
@@ -199,7 +199,7 @@
private void deliverKeyEvent(NSEvent event) {
responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
- event.getCharactersIgnoringModifiers(), event.getKeyCode());
+ event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
}
private void deliverWindowDidExposeEvent() {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Mon Apr 23 16:58:40 2012 -0700
@@ -661,11 +661,19 @@
@Override
public void setResizable(boolean resizable) {
setStyleBits(RESIZABLE, resizable);
+
+ // Re-apply the size constraints and the size to ensure the space
+ // occupied by the grow box is counted properly
+ setMinimumSize(1, 1); // the method ignores its arguments
+
+ Rectangle bounds = peer.getBounds();
+ setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
@Override
public void setMinimumSize(int width, int height) {
//TODO width, height should be used
+ //NOTE: setResizable() calls setMinimumSize(1,1) relaying on the logic below
final long nsWindowPtr = getNSWindowPtr();
final Dimension min = target.getMinimumSize();
final Dimension max = target.getMaximumSize();
@@ -802,11 +810,7 @@
if (icons == null || icons.size() == 0) {
return null;
}
-
- // TODO: need a walk-through to find the best image.
- // The best mean with higher resolution. Otherwise an icon looks bad.
- final Image image = icons.get(0);
- return CImage.getCreator().createFromImage(image);
+ return CImage.getCreator().createFromImages(icons);
}
/*
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Mon Apr 23 16:58:40 2012 -0700
@@ -647,6 +647,15 @@
return InputEvent.CTRL_MASK | InputEvent.ALT_MASK;
}
+ /**
+ * Tests whether specified key modifiers mask can be used to enter a printable
+ * character.
+ */
+ @Override
+ public boolean isPrintableCharacterModifiersMask(int mods) {
+ return ((mods & (InputEvent.META_MASK | InputEvent.CTRL_MASK)) == 0);
+ }
+
// Extends PeerEvent because we want to pass long an ObjC mediator object and because we want these events to be posted early
// Typically, rather than relying on the notifier to call notifyAll(), we use the mediator to stop the runloop
public static class CPeerEvent extends PeerEvent {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java Mon Apr 23 16:58:40 2012 -0700
@@ -245,6 +245,12 @@
*/
public static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);
+ /*
+ * There is a small number of NS characters that need to be converted
+ * into other characters before we pass them to AWT.
+ */
+ public static native char nsToJavaChar(char nsChar, int modifierFlags);
+
public static boolean isPopupTrigger(int jmodifiers) {
final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
--- a/jdk/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java Mon Apr 23 16:58:40 2012 -0700
@@ -4,7 +4,9 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -40,7 +42,7 @@
* Returns the default SelectorProvider.
*/
public static SelectorProvider create() {
- return new sun.nio.ch.PollSelectorProvider();
+ return new sun.nio.ch.KQueueSelectorProvider();
}
}
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueArrayWrapper.java Mon Apr 23 16:58:40 2012 -0700
@@ -4,7 +4,9 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -64,8 +66,8 @@
static short FD_OFFSET;
static short FILTER_OFFSET;
- // kevent array size (just under 1K bytes)
- static final int NUM_KEVENTS = 50;
+ // kevent array size
+ static final int NUM_KEVENTS = 128;
// Are we in a 64-bit VM?
static boolean is64bit = false;
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -4,7 +4,9 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@@ -49,8 +51,8 @@
// Count of registered descriptors (including interrupt)
private int totalChannels;
- // Map from file descriptors to selection keys
- private HashMap<Integer,SelectionKeyImpl> fdToKey;
+ // Map from a file descriptor to an entry containing the selection key
+ private HashMap<Integer,MapEntry> fdMap;
// True if this Selector has been closed
private boolean closed = false;
@@ -59,6 +61,20 @@
private Object interruptLock = new Object();
private boolean interruptTriggered = false;
+ // used by updateSelectedKeys to handle cases where the same file
+ // descriptor is polled by more than one filter
+ private long updateCount;
+
+ // Used to map file descriptors to a selection key and "update count"
+ // (see updateSelectedKeys for usage).
+ private static class MapEntry {
+ SelectionKeyImpl ski;
+ long updateCount;
+ MapEntry(SelectionKeyImpl ski) {
+ this.ski = ski;
+ }
+ }
+
/**
* Package private constructor called by factory method in
* the abstract superclass Selector.
@@ -70,7 +86,7 @@
fd1 = (int)fds;
kqueueWrapper = new KQueueArrayWrapper();
kqueueWrapper.initInterrupt(fd0, fd1);
- fdToKey = new HashMap<>();
+ fdMap = new HashMap<>();
totalChannels = 1;
}
@@ -82,8 +98,6 @@
if (closed)
throw new ClosedSelectorException();
processDeregisterQueue();
- if (timeout == 0 && totalChannels == 1)
- return 0;
try {
begin();
entries = kqueueWrapper.poll(timeout);
@@ -94,10 +108,9 @@
return updateSelectedKeys(entries);
}
-
/**
- * Update the keys whose fd's have been selected by the devpoll
- * driver. Add the ready keys to the ready queue.
+ * Update the keys whose fd's have been selected by kqueue.
+ * Add the ready keys to the selected key set.
* If the interrupt fd has been selected, drain it and clear the interrupt.
*/
private int updateSelectedKeys(int entries)
@@ -106,24 +119,42 @@
int numKeysUpdated = 0;
boolean interrupted = false;
+ // A file descriptor may be registered with kqueue with more than one
+ // filter and so there may be more than one event for a fd. The update
+ // count in the MapEntry tracks when the fd was last updated and this
+ // ensures that the ready ops are updated rather than replaced by a
+ // second or subsequent event.
+ updateCount++;
+
for (int i = 0; i < entries; i++) {
int nextFD = kqueueWrapper.getDescriptor(i);
if (nextFD == fd0) {
interrupted = true;
} else {
- SelectionKeyImpl ski = fdToKey.get(new Integer(nextFD));
- // ski is null in the case of an interrupt
- if (ski != null) {
+ MapEntry me = fdMap.get(Integer.valueOf(nextFD));
+
+ // entry is null in the case of an interrupt
+ if (me != null) {
int rOps = kqueueWrapper.getReventOps(i);
+ SelectionKeyImpl ski = me.ski;
if (selectedKeys.contains(ski)) {
- if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
- numKeysUpdated++;
+ // first time this file descriptor has been encountered on this
+ // update?
+ if (me.updateCount != updateCount) {
+ if (ski.channel.translateAndSetReadyOps(rOps, ski)) {
+ numKeysUpdated++;
+ me.updateCount = updateCount;
+ }
+ } else {
+ // ready ops have already been set on this update
+ ski.channel.translateAndUpdateReadyOps(rOps, ski);
}
} else {
ski.channel.translateAndSetReadyOps(rOps, ski);
- if ((ski.readyOps() & ski.interestOps()) != 0) {
+ if ((ski.nioReadyOps() & ski.nioInterestOps()) != 0) {
selectedKeys.add(ski);
numKeysUpdated++;
+ me.updateCount = updateCount;
}
}
}
@@ -137,7 +168,6 @@
interruptTriggered = false;
}
}
-
return numKeysUpdated;
}
@@ -145,6 +175,12 @@
protected void implClose() throws IOException {
if (!closed) {
closed = true;
+
+ // prevent further wakeup
+ synchronized (interruptLock) {
+ interruptTriggered = true;
+ }
+
FileDispatcherImpl.closeIntFD(fd0);
FileDispatcherImpl.closeIntFD(fd1);
if (kqueueWrapper != null) {
@@ -172,8 +208,10 @@
protected void implRegister(SelectionKeyImpl ski) {
+ if (closed)
+ throw new ClosedSelectorException();
int fd = IOUtil.fdVal(ski.channel.getFD());
- fdToKey.put(new Integer(fd), ski);
+ fdMap.put(Integer.valueOf(fd), new MapEntry(ski));
totalChannels++;
keys.add(ski);
}
@@ -181,7 +219,7 @@
protected void implDereg(SelectionKeyImpl ski) throws IOException {
int fd = ski.channel.getFDVal();
- fdToKey.remove(new Integer(fd));
+ fdMap.remove(Integer.valueOf(fd));
kqueueWrapper.release(fd);
totalChannels--;
keys.remove(ski);
@@ -194,6 +232,8 @@
public void putEventOps(SelectionKeyImpl ski, int ops) {
+ if (closed)
+ throw new ClosedSelectorException();
int fd = IOUtil.fdVal(ski.channel.getFD());
kqueueWrapper.setInterest(fd, ops);
}
--- a/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/classes/sun/nio/ch/KQueueSelectorProvider.java Mon Apr 23 16:58:40 2012 -0700
@@ -4,7 +4,9 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
--- a/jdk/src/macosx/native/sun/awt/AWTEvent.m Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTEvent.m Mon Apr 23 16:58:40 2012 -0700
@@ -124,7 +124,7 @@
{0x32, YES, KL_STANDARD, java_awt_event_KeyEvent_VK_BACK_QUOTE},
{0x33, YES, KL_STANDARD, java_awt_event_KeyEvent_VK_BACK_SPACE},
{0x34, YES, KL_NUMPAD, java_awt_event_KeyEvent_VK_ENTER},
- {0x35, NO, KL_STANDARD, java_awt_event_KeyEvent_VK_ESCAPE},
+ {0x35, YES, KL_STANDARD, java_awt_event_KeyEvent_VK_ESCAPE},
{0x36, NO, KL_UNKNOWN, java_awt_event_KeyEvent_VK_UNDEFINED},
{0x37, NO, KL_UNKNOWN, java_awt_event_KeyEvent_VK_META}, // ****
{0x38, NO, KL_UNKNOWN, java_awt_event_KeyEvent_VK_SHIFT}, // ****
@@ -308,6 +308,9 @@
* Almost all unicode characters just go from NS to Java with no translation.
* For the few exceptions, we handle it here with this small table.
*/
+#define ALL_NS_KEY_MODIFIERS_MASK \
+ (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
+
static struct _char {
NSUInteger modifier;
unichar nsChar;
@@ -315,17 +318,17 @@
}
const charTable[] = {
// map enter on keypad to same as return key
- {0, NSEnterCharacter, NSNewlineCharacter},
+ {0, NSEnterCharacter, NSNewlineCharacter},
// [3134616] return newline instead of carriage return
- {0, NSCarriageReturnCharacter, NSNewlineCharacter},
+ {0, NSCarriageReturnCharacter, NSNewlineCharacter},
// "delete" means backspace in Java
- {0, NSDeleteCharacter, NSBackspaceCharacter},
- {0, NSDeleteFunctionKey, NSDeleteCharacter},
+ {ALL_NS_KEY_MODIFIERS_MASK, NSDeleteCharacter, NSBackspaceCharacter},
+ {ALL_NS_KEY_MODIFIERS_MASK, NSDeleteFunctionKey, NSDeleteCharacter},
// back-tab is only differentiated from tab by Shift flag
- {NSShiftKeyMask, NSBackTabCharacter, NSTabCharacter},
+ {NSShiftKeyMask, NSBackTabCharacter, NSTabCharacter},
{0, 0, 0}
};
@@ -334,12 +337,8 @@
NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
{
const struct _char *cur;
- NSUInteger keyModifierFlags =
- NSShiftKeyMask | NSControlKeyMask |
- NSAlternateKeyMask | NSCommandKeyMask;
-
// Mask off just the keyboard modifiers from the event modifier mask.
- NSUInteger testableFlags = (modifiers & keyModifierFlags);
+ NSUInteger testableFlags = (modifiers & ALL_NS_KEY_MODIFIERS_MASK);
// walk through table & find the match
for (cur = charTable; cur->nsChar != 0 ; cur++) {
@@ -507,189 +506,6 @@
return javaModifiers;
}
-/*
- * Returns the correct java character for a key event. Most unicode
- * characters don't require any fussing, but a few seem to need adjusting,
- * see nsCharToJavaChar.
- */
-static unichar
-GetJavaCharacter(NSEvent *event, unsigned int index)
-{
- unichar returnValue = java_awt_event_KeyEvent_CHAR_UNDEFINED;
- NSString *chars = nil;
- unichar testChar = 0, testDeadChar = 0;
- jint javaModifiers = NsKeyModifiersToJavaModifiers([event modifierFlags]);
-
- switch ([event type]) {
- case NSFlagsChanged:
- // no character for modifier keys
- returnValue = java_awt_event_KeyEvent_CHAR_UNDEFINED;
- break;
-
- case NSKeyDown:
- case NSKeyUp:
- chars = [event characters];
- if ([chars length] > 0) {
- testChar = [chars characterAtIndex:index];
- }
-
- if (javaModifiers == 0) {
- // TODO: uses SPI...
- //if (TSMGetDeadKeyState() != 0) {
- // testDeadChar = [self deadKeyCharacter];
- //}
- }
-
- if (testChar != 0) {
- returnValue = NsCharToJavaChar(testChar, [event modifierFlags]);
- } else if (testDeadChar != 0) {
- returnValue = NsCharToJavaChar(testDeadChar, [event modifierFlags]);
- } else {
- returnValue = java_awt_event_KeyEvent_CHAR_UNDEFINED;
- }
- break;
-
- default:
- //[NSException raise:@"AWT error" format:@"Attempt to get character code from non-key event!"];
- break;
- }
-
- return returnValue;
-}
-
-/*
-static jchar
-GetDeadKeyCharacter(NSEvent *event)
-{
- // If the current event is not a dead key, return 0.
- // TODO: this uses SPI; it's an optimization but not strictly necessary
- //if (TSMGetDeadKeyState() == 0) {
- // return 0;
- //}
-
- // AppKit does not track dead-key states directly, but TSM does. Even then,
- // it's not necessarily all that accurate, because the dead key can change
- // given some combination of modifier keys on certain layouts.
- // As a result, finding the unicode value for the front end of the dead
- // key is a bit of a heuristic.
-
- // This algorithm was suggested by Aki Inoue.
- // When you get a dead key, you need to simiulate what would happen in
- // the current dead-key and modifier state if the user hit the spacebar.
- // That will tell you the front end of the dead-key combination.
-
- unichar returnValue = 0;
- const UInt16 VIRTUAL_KEY_SPACE = 49;
- UInt32 deadKeyState = 0;
- UInt32 appkitFlags = [event modifierFlags];
- UniCharCount actualStringLength;
- UniChar unicodeInputString[16];
- TISInputSourceRef keyLayout;
- const void *chrData;
-
- keyLayout = TISCopyCurrentKeyboardLayoutInputSource();
- CFDataRef cfUchrData =
- TISGetInputSourceProperty(keyLayout, kTISPropertyUnicodeKeyLayoutData);
-
- if (cfUchrData == NULL) {
- return returnValue;
- }
-
- // The actual 'uchr' table is inside the CFDataRef.
- chrData = CFDataGetBytePtr(cfUchrData);
-
- UInt8 keyboardType = LMGetKbdType();
- UInt32 keyEventModifiers = 0;
- if (appkitFlags & NSShiftKeyMask) keyEventModifiers |= shiftKey;
- if (appkitFlags & NSCommandKeyMask) keyEventModifiers |= cmdKey;
- if (appkitFlags & NSAlphaShiftKeyMask) keyEventModifiers |= alphaLock;
- if (appkitFlags & NSControlKeyMask) keyEventModifiers |= controlKey;
- if (appkitFlags & NSAlternateKeyMask) keyEventModifiers |= optionKey;
-
- if (noErr == UCKeyTranslate(chrData,
- VIRTUAL_KEY_SPACE,
- ([event type] == NSKeyDown ? kUCKeyActionDown : kUCKeyActionUp),
- keyEventModifiers,
- keyboardType,
- kUCKeyTranslateNoDeadKeysMask,
- &deadKeyState,
- 16,
- &actualStringLength,
- unicodeInputString))
- {
- if (actualStringLength > 0) {
- returnValue = unicodeInputString[0];
- }
- }
-
- return returnValue;
-}
-*/
-
-
-// REMIND: The fix for MACOSX_PORT-539 introduces Java-level implementation
-// of the function below (see CPlatformResponder). Consider removing this code.
-
-void
-DeliverJavaKeyEvent(JNIEnv *env, NSEvent *event, jobject peer)
-{
- jint javaKeyType = java_awt_event_KeyEvent_KEY_PRESSED;
- jint javaKeyCode = java_awt_event_KeyEvent_VK_UNDEFINED;
- jint javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN;
- NSString *chars = nil;
- BOOL postsTyped;
- unichar testChar = java_awt_event_KeyEvent_CHAR_UNDEFINED;
- unichar testDeadChar = 0;
- jint javaModifiers = 0;
-
- switch ([event type]) {
- case NSFlagsChanged:
- NsKeyModifiersToJavaKeyInfo([event modifierFlags],
- [event keyCode],
- &javaKeyCode,
- &javaKeyLocation,
- &javaKeyType);
- break;
-
- case NSKeyDown:
- case NSKeyUp:
- chars = [event charactersIgnoringModifiers];
- if ([chars length] > 0) {
- testChar = [chars characterAtIndex:0];
- }
-
- javaModifiers = NsKeyModifiersToJavaModifiers([event modifierFlags]);
- if (javaModifiers == 0) {
- // TODO: dead key chars
-// testDeadChar = GetDeadKeyCharacter(event);
- }
-
- NsCharToJavaVirtualKeyCode(testChar, testDeadChar,
- [event modifierFlags], [event keyCode],
- &javaKeyCode, &javaKeyLocation, &postsTyped);
- if( !postsTyped ) {
- testChar = java_awt_event_KeyEvent_CHAR_UNDEFINED;
- }
-
- javaKeyType = ([event type] == NSKeyDown) ?
- java_awt_event_KeyEvent_KEY_PRESSED :
- java_awt_event_KeyEvent_KEY_RELEASED;
- break;
-
- default:
- //[NSException raise:@"AWT error" format:@"Attempt to get virtual key code from non-key event!"];
- break;
- }
-
- if (env != NULL) {
- static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
- static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_CPlatformView, "deliverKeyEvent", "(IICII)V");
- JNFCallVoidMethod(env, peer, jm_deliverKeyEvent,
- javaKeyType, javaModifiers,
- testChar, javaKeyCode, javaKeyLocation);
- }
-}
-
jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags)
{
// Mousing needs the key modifiers
@@ -726,217 +542,6 @@
return modifiers;
}
-/*
- * Converts an NSEvent button number to a MouseEvent constant.
- */
-static jint
-NSButtonToJavaButton(NSInteger nsButtonNumber)
-{
- jint jbutton = java_awt_event_MouseEvent_NOBUTTON;
-
- if (nsButtonNumber == 0) { // left
- jbutton = java_awt_event_MouseEvent_BUTTON1;
- } else if (nsButtonNumber == 1) { // right
- jbutton = java_awt_event_MouseEvent_BUTTON3;
- } else if (nsButtonNumber == 2) { // middle
- jbutton = java_awt_event_MouseEvent_BUTTON2;
- }
-
- return jbutton;
-}
-
-
-static BOOL isDragging = NO;
-
-void
-DeliverMouseClickedEvent(JNIEnv *env, NSEvent *event, jobject peer)
-{
- NSPoint pt = [event locationInWindow];
- NSPoint pOnScreen = [NSEvent mouseLocation];
- jint etype = java_awt_event_MouseEvent_MOUSE_CLICKED;
- jint modifiers = GetJavaMouseModifiers([event buttonNumber], [event modifierFlags]);
- jint clickCount = [event clickCount];
- jint button = NSButtonToJavaButton([event buttonNumber]);
-
- if (env != NULL) {
- static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
- static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_CPlatformView,
- "deliverMouseEvent", "(IIIIFFFF)V");
- JNFCallVoidMethod(env, peer, jm_deliverMouseEvent,
- etype, modifiers,
- clickCount, button,
- pt.x, pt.y,
- pOnScreen.x, pOnScreen.y);
- }
-}
-
-/*
- * After every key down event, this is called to make the matching
- * KEY_TYPED (if this key posts those). We use the same NSEvent for it,
- * but create a KEY_TYPED java event this time.
- * If this key doesn't post typed, we don't post the event.
- *
- * TODO: some duplicated effort here; could just fold it
- * into DeliverJavaKeyEvent...
- */
-static void
-DeliverKeyTypedEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer)
-{
- if (peer == NULL) {
- return;
- }
-
- jint javaKeyCode, javaKeyLocation;
- BOOL postsTyped = NO;
- unichar testChar, testDeadChar = 0;
- jint javaModifiers = NsKeyModifiersToJavaModifiers([nsEvent modifierFlags]);
-
- if (javaModifiers == 0) {
- testDeadChar = [nsEvent deadKeyCharacter];
- }
-
- NSString *theChars = [nsEvent characters];
- unsigned i, stringLength = [theChars length];
-
- for (i = 0; i < stringLength; i++) {
- testChar = [theChars characterAtIndex:i];
- NsCharToJavaVirtualKeyCode(testChar, testDeadChar,
- [nsEvent modifierFlags], [nsEvent keyCode],
- &javaKeyCode, &javaKeyLocation, &postsTyped);
-
- if (postsTyped) {
- // Some keys may generate a KEY_TYPED, but we can't determine
- // what that character is. That's likely a bug, but for now we
- // just check for CHAR_UNDEFINED.
- unichar theChar = GetJavaCharacter(nsEvent, i);
- if (theChar != java_awt_event_KeyEvent_CHAR_UNDEFINED) {
- if (env != NULL) {
- static JNF_CLASS_CACHE(jc_CPlatformView,
- "sun/lwawt/macosx/CPlatformView");
- static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_CPlatformView,
- "deliverKeyEvent", "(IICII)V");
- JNFCallVoidMethod(env, peer, jm_deliverKeyEvent,
- java_awt_event_KeyEvent_KEY_TYPED,
- javaModifiers,
- theChar,
- java_awt_event_KeyEvent_VK_UNDEFINED,
- java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN);
- }
- }
- }
- }
-}
-
-/*
- * There are a couple of extra events that Java expects to get that don't
- * actually correspond to a direct NSEvent, KEY_TYPED and MOUSE_CLICKED are
- * both extra events that are sort of redundant with ordinary
- * key downs and mouse ups. In this extra message, we take the original
- * input event and if necessary, cons up a special follow-on event which
- * we dispatch over to Java.
- *
- * For Java, keyDown's generate a KeyPressed (for each hardware key as it
- * goes down) and then a "logical KeyTyped" event for the key event. (So
- * a shift-a generates two presses, one keytyped of "A", and then two
- * releases). The standard event utility function converts a key down to
- * a key pressed. When appropriate, we need to cons up another event
- * (KEY_TYPED) to follow a keyDown.
- *
- * Java expects you to send a clicked event if you got a down & up, with no
- * intervening drag. So in addition to the MOUSE_RELEASED event that a
- * mouseUp is translated to, we also have to cons up a MOUSE_CLICKED event
- * for that case. Mike Paquette, god of Window Server event handling,
- * confirmed this fact about how to determine if a mouse up event had an
- * intervening drag:
- * An initial mouse-down gets a click count of 1. Subsequent left or right
- * mouse-downs within the space/time tolerance limits increment the click
- * count. A mouse-up will have the clickCount of the last mouseDown if
- * mouse is not outside the tolerance limits, but 0 otherwise. Thus, a
- * down-up sequence without any intervening drag will have a click count
- * of 0 in the mouse-up event. NOTE: The problem with this is that
- * clickCount goes to zero after some point in time. So a long, click &
- * hold without moving and then release the mouse doesn't create a
- * MOUSE_CLICK event as it should. Java AWT now tracks the drag state itself.
- *
- * As another add-on, we also check for the status of mouse-motion events
- * after a mouse-down, so we know whether to generate mouse-dragged events
- * during this down sequence.
- */
-void
-SendAdditionalJavaEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer)
-{
- AWT_ASSERT_APPKIT_THREAD;
-
- NSEventType type = [nsEvent type];
- switch (type) {
- case NSKeyDown:
- break;
-
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
- // TODO: we may need to pull in changedDragToMove here...
- //if (!isDragging && ([NSViewAWT changedDragToMove]==NO)) {
- if (!isDragging) {
- // got down/up pair with no dragged in between; ignores drag events
- // that have been morphed to move events
- DeliverMouseClickedEvent(env, nsEvent, peer);
- }
- break;
-
-// TODO: to be implemented...
-#if 0
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- //
- // During a drag, the AppKit does not send mouseEnter and mouseExit
- // events. It turns out that doing a hitTest causes the window's
- // view hierarchy to be locked from drawing and that, of course,
- // slows everything way down. Synthesize mouseEnter and mouseExit
- // then forward.
- //
- NSView *hitView = [[source model] hitTest:[nsEvent locationInWindow]];
-
- if ((hitView != nil) &&
- ([hitView conformsToProtocol:@protocol(AWTPeerControl)]))
- {
- if (sLastMouseDraggedView == nil) {
- sLastMouseDraggedView = hitView;
- }
- else if (hitView != sLastMouseDraggedView) {
- // We know sLastMouseDraggedView is a AWTPeerControl.
- jobject lastPeer =
- [(id <AWTPeerControl>)sLastMouseDraggedView peer];
-
- // Send mouseExit to sLastMouseDraggedView
- jobject exitEvent =
- makeMouseEvent(env, nsEvent, lastPeer,
- sLastMouseDraggedView,
- java_awt_event_MouseEvent_MOUSE_EXITED);
- pushEventForward(exitEvent, env);
- (*env)->DeleteLocalRef(env, exitEvent);
-
- // Send mouseEnter to hitView
- jobject enterEvent =
- makeMouseEvent(env, nsEvent, peer, hitView,
- java_awt_event_MouseEvent_MOUSE_ENTERED);
- pushEventForward(enterEvent, env);
-
- (*env)->DeleteLocalRef(env, enterEvent);
-
- // Set sLastMouseDraggedView = hitView
- sLastMouseDraggedView = hitView;
- }
- }
- break;
-#endif
-
- default:
- break;
- }
-}
-
jlong UTC(NSEvent *event) {
struct timeval tv;
if (gettimeofday(&tv, NULL) == 0) {
@@ -1069,3 +674,23 @@
JNF_COCOA_EXIT(env);
}
+
+/*
+ * Class: sun_lwawt_macosx_event_NSEvent
+ * Method: nsToJavaChar
+ * Signature: (CI)C
+ */
+JNIEXPORT jint JNICALL
+Java_sun_lwawt_macosx_event_NSEvent_nsToJavaChar
+(JNIEnv *env, jclass cls, char nsChar, jint modifierFlags)
+{
+ jchar javaChar = 0;
+
+JNF_COCOA_ENTER(env);
+
+ javaChar = NsCharToJavaChar(nsChar, modifierFlags);
+
+JNF_COCOA_EXIT(env);
+
+ return javaChar;
+}
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.h Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.h Mon Apr 23 16:58:40 2012 -0700
@@ -39,7 +39,6 @@
@private
JNFWeakJObjectWrapper *javaPlatformWindow;
CMenuBar *javaMenuBar;
- NSWindow *growBoxWindow;
NSSize javaMinSize;
NSSize javaMaxSize;
jint styleBits;
@@ -47,7 +46,6 @@
@property (nonatomic, retain) JNFWeakJObjectWrapper *javaPlatformWindow;
@property (nonatomic, retain) CMenuBar *javaMenuBar;
-@property (nonatomic, retain) NSWindow *growBoxWindow;
@property (nonatomic) NSSize javaMinSize;
@property (nonatomic) NSSize javaMaxSize;
@property (nonatomic) jint styleBits;
--- a/jdk/src/macosx/native/sun/awt/AWTWindow.m Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m Mon Apr 23 16:58:40 2012 -0700
@@ -40,7 +40,6 @@
#import "ThreadUtilities.h"
#import "OSVersion.h"
-
#define MASK(KEY) \
(sun_lwawt_macosx_CPlatformWindow_ ## KEY)
@@ -50,31 +49,12 @@
#define SET(BITS, KEY, VALUE) \
BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY)
-
static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
-@interface JavaResizeGrowBoxOverlayWindow : NSWindow { }
-
-@end
-
-@implementation JavaResizeGrowBoxOverlayWindow
-
-- (BOOL) accessibilityIsIgnored
-{
- return YES;
-}
-
-- (NSArray *)accessibilityChildrenAttribute
-{
- return nil;
-}
-@end
-
@implementation AWTWindow
@synthesize javaPlatformWindow;
@synthesize javaMenuBar;
-@synthesize growBoxWindow;
@synthesize javaMinSize;
@synthesize javaMaxSize;
@synthesize styleBits;
@@ -154,24 +134,6 @@
}
-- (BOOL) shouldShowGrowBox {
- return isSnowLeopardOrLower() && IS(self.styleBits, RESIZABLE);
-}
-
-- (NSImage *) createGrowBoxImage {
- NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(12, 12)];
- JRSUIControlRef growBoxWidget = JRSUIControlCreate(FALSE);
- JRSUIControlSetWidget(growBoxWidget, kJRSUI_Widget_growBoxTextured);
- JRSUIControlSetWindowType(growBoxWidget, kJRSUI_WindowType_utility);
- JRSUIRendererRef renderer = JRSUIRendererCreate();
- [image lockFocus]; // sets current graphics context to that of the image
- JRSUIControlDraw(renderer, growBoxWidget, [[NSGraphicsContext currentContext] graphicsPort], CGRectMake(0, 1, 11, 11));
- [image unlockFocus];
- JRSUIRendererRelease(renderer);
- JRSUIControlRelease(growBoxWidget);
- return image;
-}
-
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
styleBits:(jint)bits
frameRect:(NSRect)rect
@@ -205,28 +167,6 @@
[self setReleasedWhenClosed:NO];
[self setPreservesContentDuringLiveResize:YES];
- if ([self shouldShowGrowBox]) {
- NSImage *growBoxImage = [self createGrowBoxImage];
- growBoxWindow = [[JavaResizeGrowBoxOverlayWindow alloc] initWithContentRect:NSMakeRect(0, 0, [growBoxImage size].width, [growBoxImage size].height) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
- [self.growBoxWindow setIgnoresMouseEvents:YES];
- [self.growBoxWindow setOpaque:NO];
- [self.growBoxWindow setBackgroundColor:[NSColor clearColor]];
- [self.growBoxWindow setHasShadow:NO];
- [self.growBoxWindow setReleasedWhenClosed:NO];
-
- NSImageView *imageView = [[NSImageView alloc] initWithFrame:[self.growBoxWindow frame]];
- [imageView setEditable:NO];
- [imageView setAnimates:NO];
- [imageView setAllowsCutCopyPaste:NO];
- [self.growBoxWindow setContentView:imageView];
- [imageView setImage:growBoxImage];
- [growBoxImage release];
- [imageView release];
-
- [self addChildWindow:self.growBoxWindow ordered:NSWindowAbove];
- [self adjustGrowBoxWindow];
- } else growBoxWindow = nil;
-
return self;
}
@@ -235,7 +175,6 @@
JNIEnv *env = [ThreadUtilities getJNIEnv];
[self.javaPlatformWindow setJObject:nil withEnv:env];
- self.growBoxWindow = nil;
[super dealloc];
}
@@ -321,14 +260,6 @@
// NSWindowDelegate methods
-- (void) adjustGrowBoxWindow {
- if (self.growBoxWindow != nil) {
- NSRect parentRect = [self frame];
- parentRect.origin.x += (parentRect.size.width - [self.growBoxWindow frame].size.width);
- [self.growBoxWindow setFrameOrigin:parentRect.origin];
- }
-}
-
- (void) _deliverMoveResizeEvent {
AWT_ASSERT_APPKIT_THREAD;
@@ -342,8 +273,6 @@
// TODO: create generic AWT assert
}
- [self adjustGrowBoxWindow];
-
NSRect frame = ConvertNSScreenRect(env, [self frame]);
static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V");
@@ -548,6 +477,31 @@
}
[super sendEvent:event];
}
+
+- (void)constrainSize:(NSSize*)size {
+ float minWidth = 0.f, minHeight = 0.f;
+
+ if (IS(self.styleBits, DECORATED)) {
+ NSRect frame = [self frame];
+ NSRect contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[self styleMask]];
+
+ float top = frame.size.height - contentRect.size.height;
+ float left = contentRect.origin.x - frame.origin.x;
+ float bottom = contentRect.origin.y - frame.origin.y;
+ float right = frame.size.width - (contentRect.size.width + left);
+
+ // Speculative estimation: 80 - enough for window decorations controls
+ minWidth += left + right + 80;
+ minHeight += top + bottom;
+ }
+
+ minWidth = MAX(1.f, minWidth);
+ minHeight = MAX(1.f, minHeight);
+
+ size->width = MAX(size->width, minWidth);
+ size->height = MAX(size->height, minHeight);
+}
+
@end // AWTWindow
@@ -703,6 +657,8 @@
AWT_ASSERT_APPKIT_THREAD;
NSRect rect = ConvertNSScreenRect(NULL, jrect);
+ [window constrainSize:&rect.size];
+
[window setFrame:rect display:YES];
// only start tracking events if pointer is above the toplevel
@@ -734,13 +690,16 @@
if (maxW < 1) maxW = 1;
if (maxH < 1) maxH = 1;
- NSSize min = { minW, minH };
- NSSize max = { maxW, maxH };
-
AWTWindow *window = OBJC(windowPtr);
[JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
AWT_ASSERT_APPKIT_THREAD;
+ NSSize min = { minW, minH };
+ NSSize max = { maxW, maxH };
+
+ [window constrainSize:&min];
+ [window constrainSize:&max];
+
window.javaMinSize = min;
window.javaMaxSize = max;
[window updateMinMaxSize:IS(window.styleBits, RESIZABLE)];
@@ -830,7 +789,6 @@
AWT_ASSERT_APPKIT_THREAD;
[window setAlphaValue:alpha];
- [window.growBoxWindow setAlphaValue:alpha];
}];
JNF_COCOA_EXIT(env);
--- a/jdk/src/macosx/native/sun/awt/CDropTarget.m Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/CDropTarget.m Mon Apr 23 16:58:40 2012 -0700
@@ -648,6 +648,10 @@
if (sDraggingError == FALSE) {
sDraggingLocation = [sender draggingLocation];
NSPoint javaLocation = [fView convertPoint:sDraggingLocation fromView:nil];
+ // The y coordinate that comes in the NSDraggingInfo seems to be reversed - probably
+ // has to do something with the type of view it comes to.
+ // This is the earliest place where we can correct it.
+ javaLocation.y = fView.window.frame.size.height - javaLocation.y;
jint actions = [DnDUtilities mapNSDragOperationMaskToJava:[sender draggingSourceOperationMask]];
jint dropAction = sJavaDropOperation;
--- a/jdk/src/macosx/native/sun/awt/CImage.m Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/CImage.m Mon Apr 23 16:58:40 2012 -0700
@@ -70,19 +70,8 @@
[oldContext release];
}
-/*
- * Class: sun_lwawt_macosx_CImage
- * Method: nativeCreateNSImageFromArray
- * Signature: ([III)J
- */
-JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
-(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
{
- jlong result = 0L;
-
-JNF_COCOA_ENTER(env);
-AWT_ASSERT_ANY_THREAD;
-
NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:width
pixelsHigh:height
@@ -105,15 +94,83 @@
(*env)->ReleasePrimitiveArrayCritical(env, buffer, src, JNI_ABORT);
- NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
- [nsImage addRepresentation:imageRep];
- [imageRep release];
+ return imageRep;
+}
+
+/*
+ * Class: sun_lwawt_macosx_CImage
+ * Method: nativeCreateNSImageFromArray
+ * Signature: ([III)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArray
+(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+{
+ jlong result = 0L;
- if (nsImage != nil) {
- CFRetain(nsImage); // GC
+JNF_COCOA_ENTER(env);
+AWT_ASSERT_ANY_THREAD;
+
+ NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
+ if (imageRep) {
+ NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
+ [nsImage addRepresentation:imageRep];
+ [imageRep release];
+
+ if (nsImage != nil) {
+ CFRetain(nsImage); // GC
+ }
+
+ result = ptr_to_jlong(nsImage);
}
- result = ptr_to_jlong(nsImage);
+JNF_COCOA_EXIT(env);
+
+ return result;
+}
+
+/*
+ * Class: sun_lwawt_macosx_CImage
+ * Method: nativeCreateNSImageFromArrays
+ * Signature: ([[I[I[I)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromArrays
+(JNIEnv *env, jclass klass, jobjectArray buffers, jintArray widths, jintArray heights)
+{
+ jlong result = 0L;
+
+JNF_COCOA_ENTER(env);
+AWT_ASSERT_ANY_THREAD;
+
+ jsize num = (*env)->GetArrayLength(env, buffers);
+ NSMutableArray * reps = [NSMutableArray arrayWithCapacity: num];
+
+ jint * ws = (*env)->GetIntArrayElements(env, widths, NULL);
+ jint * hs = (*env)->GetIntArrayElements(env, heights, NULL);
+
+ jsize i;
+ for (i = 0; i < num; i++) {
+ jintArray buffer = (*env)->GetObjectArrayElement(env, buffers, i);
+
+ NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, ws[i], hs[i]);
+ if (imageRep) {
+ [reps addObject: imageRep];
+ }
+ }
+
+ (*env)->ReleaseIntArrayElements(env, heights, hs, JNI_ABORT);
+ (*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
+
+ if ([reps count]) {
+ NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
+ [nsImage addRepresentations: reps];
+ [reps release];
+
+ if (nsImage != nil) {
+ CFRetain(nsImage); // GC
+ }
+
+ result = ptr_to_jlong(nsImage);
+ }
JNF_COCOA_EXIT(env);
--- a/jdk/src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/macosx/native/sun/nio/ch/KQueueArrayWrapper.c Mon Apr 23 16:58:40 2012 -0700
@@ -4,7 +4,9 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
--- a/jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/com/sun/tools/example/debug/tty/VMConnection.java Mon Apr 23 16:58:40 2012 -0700
@@ -114,6 +114,23 @@
String value = token.substring(index + 1,
token.length() - 1); // Remove comma delimiter
+ /*
+ * for values enclosed in quotes (single and/or double quotes)
+ * strip off enclosing quote chars
+ * needed for quote enclosed delimited substrings
+ */
+ if (name.equals("options")) {
+ StringBuilder sb = new StringBuilder();
+ for (String s : splitStringAtNonEnclosedWhiteSpace(value)) {
+ while (isEnclosed(s, "\"") || isEnclosed(s, "'")) {
+ s = s.substring(1, s.length() - 1);
+ }
+ sb.append(s);
+ sb.append(" ");
+ }
+ value = sb.toString();
+ }
+
Connector.Argument argument = arguments.get(name);
if (argument == null) {
throw new IllegalArgumentException
@@ -136,6 +153,152 @@
return arguments;
}
+ private static boolean isEnclosed(String value, String enclosingChar) {
+ if (value.indexOf(enclosingChar) == 0) {
+ int lastIndex = value.lastIndexOf(enclosingChar);
+ if (lastIndex > 0 && lastIndex == value.length() - 1) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static List<String> splitStringAtNonEnclosedWhiteSpace(String value) throws IllegalArgumentException {
+ List<String> al = new ArrayList<String>();
+ char[] arr;
+ int startPosition = 0;
+ int endPosition = 0;
+ final char SPACE = ' ';
+ final char DOUBLEQ = '"';
+ final char SINGLEQ = '\'';
+
+ /*
+ * An "open" or "active" enclosing state is where
+ * the first valid start quote qualifier is found,
+ * and there is a search in progress for the
+ * relevant end matching quote
+ *
+ * enclosingTargetChar set to SPACE
+ * is used to signal a non open enclosing state
+ */
+ char enclosingTargetChar = SPACE;
+
+ if (value == null) {
+ throw new IllegalArgumentException
+ (MessageOutput.format("value string is null"));
+ }
+
+ // split parameter string into individual chars
+ arr = value.toCharArray();
+
+ for (int i = 0; i < arr.length; i++) {
+ switch (arr[i]) {
+ case SPACE: {
+ // do nothing for spaces
+ // unless last in array
+ if (isLastChar(arr, i)) {
+ endPosition = i;
+ // break for substring creation
+ break;
+ }
+ continue;
+ }
+ case DOUBLEQ:
+ case SINGLEQ: {
+ if (enclosingTargetChar == arr[i]) {
+ // potential match to close open enclosing
+ if (isNextCharWhitespace(arr, i)) {
+ // if peek next is whitespace
+ // then enclosing is a valid substring
+ endPosition = i;
+ // reset enclosing target char
+ enclosingTargetChar = SPACE;
+ // break for substring creation
+ break;
+ }
+ }
+ if (enclosingTargetChar == SPACE) {
+ // no open enclosing state
+ // handle as normal char
+ if (isPreviousCharWhitespace(arr, i)) {
+ startPosition = i;
+ // peek forward for end candidates
+ if (value.indexOf(arr[i], i + 1) >= 0) {
+ // set open enclosing state by
+ // setting up the target char
+ enclosingTargetChar = arr[i];
+ } else {
+ // no more target chars left to match
+ // end enclosing, handle as normal char
+ if (isNextCharWhitespace(arr, i)) {
+ endPosition = i;
+ // break for substring creation
+ break;
+ }
+ }
+ }
+ }
+ continue;
+ }
+ default: {
+ // normal non-space, non-" and non-' chars
+ if (enclosingTargetChar == SPACE) {
+ // no open enclosing state
+ if (isPreviousCharWhitespace(arr, i)) {
+ // start of space delim substring
+ startPosition = i;
+ }
+ if (isNextCharWhitespace(arr, i)) {
+ // end of space delim substring
+ endPosition = i;
+ // break for substring creation
+ break;
+ }
+ }
+ continue;
+ }
+ }
+
+ // break's end up here
+ if (startPosition > endPosition) {
+ throw new IllegalArgumentException
+ (MessageOutput.format("Illegal option values"));
+ }
+
+ // extract substring and add to List<String>
+ al.add(value.substring(startPosition, ++endPosition));
+
+ // set new start position
+ i = startPosition = endPosition;
+
+ } // for loop
+
+ return al;
+ }
+
+ static private boolean isPreviousCharWhitespace(char[] arr, int curr_pos) {
+ return isCharWhitespace(arr, curr_pos - 1);
+ }
+
+ static private boolean isNextCharWhitespace(char[] arr, int curr_pos) {
+ return isCharWhitespace(arr, curr_pos + 1);
+ }
+
+ static private boolean isCharWhitespace(char[] arr, int pos) {
+ if (pos < 0 || pos >= arr.length) {
+ // outside arraybounds is considered an implicit space
+ return true;
+ }
+ if (arr[pos] == ' ') {
+ return true;
+ }
+ return false;
+ }
+
+ static private boolean isLastChar(char[] arr, int pos) {
+ return (pos + 1 == arr.length);
+ }
+
VMConnection(String connectSpec, int traceFlags) {
String nameString;
String argString;
--- a/jdk/src/share/classes/java/net/HttpCookie.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/net/HttpCookie.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -616,9 +616,6 @@
* would be accepted.</li>
* <li>A Set-Cookie2 with Domain=.com or Domain=.com., will always be
* rejected, because there is no embedded dot.</li>
- * <li>A Set-Cookie2 with Domain=ajax.com will be accepted, and the
- * value for Domain will be taken to be .ajax.com, because a dot
- * gets prepended to the value.</li>
* <li>A Set-Cookie2 from request-host example for Domain=.local will
* be accepted, because the effective host name for the request-
* host is example.local, and example.local domain-matches .local.</li>
--- a/jdk/src/share/classes/java/nio/file/Files.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/nio/file/Files.java Mon Apr 23 16:58:40 2012 -0700
@@ -269,7 +269,7 @@
* WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND));
*
* // create file with initial permissions, opening it for both reading and writing
- * {@code FileAttribute<<SetPosixFilePermission>> perms = ...}
+ * {@code FileAttribute<Set<PosixFilePermission>> perms = ...}
* SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
* </pre>
*
--- a/jdk/src/share/classes/java/security/CodeSource.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/security/CodeSource.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -114,7 +114,7 @@
*
* @return a hash code value for this object.
*/
-
+ @Override
public int hashCode() {
if (location != null)
return location.hashCode();
@@ -133,6 +133,7 @@
*
* @return true if the objects are considered equal, false otherwise.
*/
+ @Override
public boolean equals(Object obj) {
if (obj == this)
return true;
@@ -231,10 +232,10 @@
/**
* Returns true if this CodeSource object "implies" the specified CodeSource.
- * <P>
- * More specifically, this method makes the following checks, in order.
+ * <p>
+ * More specifically, this method makes the following checks.
* If any fail, it returns false. If they all succeed, it returns true.<p>
- * <ol>
+ * <ul>
* <li> <i>codesource</i> must not be null.
* <li> If this object's certificates are not null, then all
* of this object's certificates must be present in <i>codesource</i>'s
@@ -242,14 +243,14 @@
* <li> If this object's location (getLocation()) is not null, then the
* following checks are made against this object's location and
* <i>codesource</i>'s:<p>
- * <ol>
+ * <ul>
* <li> <i>codesource</i>'s location must not be null.
*
* <li> If this object's location
* equals <i>codesource</i>'s location, then return true.
*
* <li> This object's protocol (getLocation().getProtocol()) must be
- * equal to <i>codesource</i>'s protocol.
+ * equal to <i>codesource</i>'s protocol, ignoring case.
*
* <li> If this object's host (getLocation().getHost()) is not null,
* then the SocketPermission
@@ -258,7 +259,8 @@
*
* <li> If this object's port (getLocation().getPort()) is not
* equal to -1 (that is, if a port is specified), it must equal
- * <i>codesource</i>'s port.
+ * <i>codesource</i>'s port or default port
+ * (codesource.getLocation().getDefaultPort()).
*
* <li> If this object's file (getLocation().getFile()) doesn't equal
* <i>codesource</i>'s file, then the following checks are made:
@@ -275,8 +277,8 @@
* <li> If this object's reference (getLocation().getRef()) is
* not null, it must equal <i>codesource</i>'s reference.
*
- * </ol>
- * </ol>
+ * </ul>
+ * </ul>
* <p>
* For example, the codesource objects with the following locations
* and null certificates all imply
@@ -369,85 +371,88 @@
*
* @param that CodeSource to compare against
*/
- private boolean matchLocation(CodeSource that)
- {
- if (location == null) {
- return true;
- }
+ private boolean matchLocation(CodeSource that) {
+ if (location == null)
+ return true;
- if ((that == null) || (that.location == null))
- return false;
+ if ((that == null) || (that.location == null))
+ return false;
+
+ if (location.equals(that.location))
+ return true;
- if (location.equals(that.location))
- return true;
+ if (!location.getProtocol().equalsIgnoreCase(that.location.getProtocol()))
+ return false;
- if (!location.getProtocol().equals(that.location.getProtocol()))
+ int thisPort = location.getPort();
+ if (thisPort != -1) {
+ int thatPort = that.location.getPort();
+ int port = thatPort != -1 ? thatPort
+ : that.location.getDefaultPort();
+ if (thisPort != port)
return false;
-
- String thisHost = location.getHost();
- String thatHost = that.location.getHost();
+ }
- if (thisHost != null) {
- if (("".equals(thisHost) || "localhost".equals(thisHost)) &&
- ("".equals(thatHost) || "localhost".equals(thatHost))) {
- // ok
- } else if (!thisHost.equals(thatHost)) {
- if (thatHost == null) {
- return false;
- }
- if (this.sp == null) {
- this.sp = new SocketPermission(thisHost, "resolve");
- }
- if (that.sp == null) {
- that.sp = new SocketPermission(thatHost, "resolve");
- }
- if (!this.sp.implies(that.sp)) {
- return false;
- }
- }
+ if (location.getFile().endsWith("/-")) {
+ // Matches the directory and (recursively) all files
+ // and subdirectories contained in that directory.
+ // For example, "/a/b/-" implies anything that starts with
+ // "/a/b/"
+ String thisPath = location.getFile().substring(0,
+ location.getFile().length()-1);
+ if (!that.location.getFile().startsWith(thisPath))
+ return false;
+ } else if (location.getFile().endsWith("/*")) {
+ // Matches the directory and all the files contained in that
+ // directory.
+ // For example, "/a/b/*" implies anything that starts with
+ // "/a/b/" but has no further slashes
+ int last = that.location.getFile().lastIndexOf('/');
+ if (last == -1)
+ return false;
+ String thisPath = location.getFile().substring(0,
+ location.getFile().length()-1);
+ String thatPath = that.location.getFile().substring(0, last+1);
+ if (!thatPath.equals(thisPath))
+ return false;
+ } else {
+ // Exact matches only.
+ // For example, "/a/b" and "/a/b/" both imply "/a/b/"
+ if ((!that.location.getFile().equals(location.getFile()))
+ && (!that.location.getFile().equals(location.getFile()+"/"))) {
+ return false;
}
-
- if (location.getPort() != -1) {
- if (location.getPort() != that.location.getPort())
- return false;
- }
+ }
- if (location.getFile().endsWith("/-")) {
- // Matches the directory and (recursively) all files
- // and subdirectories contained in that directory.
- // For example, "/a/b/-" implies anything that starts with
- // "/a/b/"
- String thisPath = location.getFile().substring(0,
- location.getFile().length()-1);
- if (!that.location.getFile().startsWith(thisPath))
+ if (location.getRef() != null
+ && !location.getRef().equals(that.location.getRef())) {
+ return false;
+ }
+
+ String thisHost = location.getHost();
+ String thatHost = that.location.getHost();
+ if (thisHost != null) {
+ if (("".equals(thisHost) || "localhost".equals(thisHost)) &&
+ ("".equals(thatHost) || "localhost".equals(thatHost))) {
+ // ok
+ } else if (!thisHost.equals(thatHost)) {
+ if (thatHost == null) {
return false;
- } else if (location.getFile().endsWith("/*")) {
- // Matches the directory and all the files contained in that
- // directory.
- // For example, "/a/b/*" implies anything that starts with
- // "/a/b/" but has no further slashes
- int last = that.location.getFile().lastIndexOf('/');
- if (last == -1)
- return false;
- String thisPath = location.getFile().substring(0,
- location.getFile().length()-1);
- String thatPath = that.location.getFile().substring(0, last+1);
- if (!thatPath.equals(thisPath))
- return false;
- } else {
- // Exact matches only.
- // For example, "/a/b" and "/a/b/" both imply "/a/b/"
- if ((!that.location.getFile().equals(location.getFile()))
- && (!that.location.getFile().equals(location.getFile()+"/"))) {
+ }
+ if (this.sp == null) {
+ this.sp = new SocketPermission(thisHost, "resolve");
+ }
+ if (that.sp == null) {
+ that.sp = new SocketPermission(thatHost, "resolve");
+ }
+ if (!this.sp.implies(that.sp)) {
return false;
}
}
-
- if (location.getRef() == null)
- return true;
- else
- return location.getRef().equals(that.location.getRef());
}
+ // everything matches
+ return true;
+ }
/**
* Returns a string describing this CodeSource, telling its
@@ -455,6 +460,7 @@
*
* @return information about this CodeSource.
*/
+ @Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("(");
--- a/jdk/src/share/classes/java/util/AbstractCollection.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractCollection.java Mon Apr 23 16:58:40 2012 -0700
@@ -170,6 +170,7 @@
* @throws ArrayStoreException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
// Estimate size of array; be prepared to see more or fewer elements
int size = size();
@@ -180,13 +181,21 @@
for (int i = 0; i < r.length; i++) {
if (! it.hasNext()) { // fewer elements than expected
- if (a != r)
+ if (a == r) {
+ r[i] = null; // null-terminate
+ } else if (a.length < i) {
return Arrays.copyOf(r, i);
- r[i] = null; // null-terminate
- return r;
+ } else {
+ System.arraycopy(r, 0, a, 0, i);
+ if (a.length > i) {
+ a[i] = null;
+ }
+ }
+ return a;
}
r[i] = (T)it.next();
}
+ // more elements than expected
return it.hasNext() ? finishToArray(r, it) : r;
}
@@ -208,6 +217,7 @@
* @return array containing the elements in the given array, plus any
* further elements returned by the iterator, trimmed to size
*/
+ @SuppressWarnings("unchecked")
private static <T> T[] finishToArray(T[] r, Iterator<?> it) {
int i = r.length;
while (it.hasNext()) {
--- a/jdk/src/share/classes/java/util/AbstractList.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractList.java Mon Apr 23 16:58:40 2012 -0700
@@ -516,7 +516,7 @@
return false;
ListIterator<E> e1 = listIterator();
- ListIterator e2 = ((List) o).listIterator();
+ ListIterator<?> e2 = ((List<?>) o).listIterator();
while (e1.hasNext() && e2.hasNext()) {
E o1 = e1.next();
Object o2 = e2.next();
--- a/jdk/src/share/classes/java/util/AbstractMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -443,7 +443,7 @@
if (!(o instanceof Map))
return false;
- Map<K,V> m = (Map<K,V>) o;
+ Map<?,?> m = (Map<?,?>) o;
if (m.size() != size())
return false;
@@ -534,7 +534,7 @@
* @return a shallow copy of this map
*/
protected Object clone() throws CloneNotSupportedException {
- AbstractMap<K,V> result = (AbstractMap<K,V>)super.clone();
+ AbstractMap<?,?> result = (AbstractMap<?,?>)super.clone();
result.keySet = null;
result.values = null;
return result;
@@ -652,7 +652,7 @@
public boolean equals(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
return eq(key, e.getKey()) && eq(value, e.getValue());
}
@@ -783,7 +783,7 @@
public boolean equals(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
return eq(key, e.getKey()) && eq(value, e.getValue());
}
--- a/jdk/src/share/classes/java/util/AbstractSet.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/AbstractSet.java Mon Apr 23 16:58:40 2012 -0700
@@ -88,7 +88,7 @@
if (!(o instanceof Set))
return false;
- Collection c = (Collection) o;
+ Collection<?> c = (Collection<?>) o;
if (c.size() != size())
return false;
try {
--- a/jdk/src/share/classes/java/util/ArrayDeque.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/ArrayDeque.java Mon Apr 23 16:58:40 2012 -0700
@@ -813,7 +813,8 @@
*/
public ArrayDeque<E> clone() {
try {
- ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
+ @SuppressWarnings("unchecked")
+ ArrayDeque<E> result = (ArrayDeque<E>) super.clone();
result.elements = Arrays.copyOf(elements, elements.length);
return result;
@@ -849,6 +850,7 @@
/**
* Deserialize this deque.
*/
+ @SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();
--- a/jdk/src/share/classes/java/util/ArrayList.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/ArrayList.java Mon Apr 23 16:58:40 2012 -0700
@@ -300,8 +300,7 @@
*/
public Object clone() {
try {
- @SuppressWarnings("unchecked")
- ArrayList<E> v = (ArrayList<E>) super.clone();
+ ArrayList<?> v = (ArrayList<?>) super.clone();
v.elementData = Arrays.copyOf(elementData, size);
v.modCount = 0;
return v;
--- a/jdk/src/share/classes/java/util/Arrays.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Arrays.java Mon Apr 23 16:58:40 2012 -0700
@@ -560,6 +560,7 @@
* off is the offset to generate corresponding low, high in src
* To be removed in a future release.
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private static void mergeSort(Object[] src,
Object[] dest,
int low,
@@ -746,6 +747,7 @@
* off is the offset into src corresponding to low in dest
* To be removed in a future release.
*/
+ @SuppressWarnings({ "rawtypes", "unchecked" })
private static void mergeSort(Object[] src,
Object[] dest,
int low, int high, int off,
@@ -1477,8 +1479,10 @@
while (low <= high) {
int mid = (low + high) >>> 1;
- Comparable midVal = (Comparable)a[mid];
- int cmp = midVal.compareTo(key);
+ @SuppressWarnings("rawtypes")
+ Comparable midVal = (Comparable)a[mid];
+ @SuppressWarnings("unchecked")
+ int cmp = midVal.compareTo(key);
if (cmp < 0)
low = mid + 1;
@@ -2215,6 +2219,7 @@
* @throws NullPointerException if <tt>original</tt> is null
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <T> T[] copyOf(T[] original, int newLength) {
return (T[]) copyOf(original, newLength, original.getClass());
}
@@ -2242,6 +2247,7 @@
* @since 1.6
*/
public static <T,U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) {
+ @SuppressWarnings("unchecked")
T[] copy = ((Object)newType == (Object)Object[].class)
? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
@@ -2470,8 +2476,9 @@
* @throws NullPointerException if <tt>original</tt> is null
* @since 1.6
*/
+ @SuppressWarnings("unchecked")
public static <T> T[] copyOfRange(T[] original, int from, int to) {
- return copyOfRange(original, from, to, (Class<T[]>) original.getClass());
+ return copyOfRange(original, from, to, (Class<? extends T[]>) original.getClass());
}
/**
@@ -2509,6 +2516,7 @@
int newLength = to - from;
if (newLength < 0)
throw new IllegalArgumentException(from + " > " + to);
+ @SuppressWarnings("unchecked")
T[] copy = ((Object)newType == (Object)Object[].class)
? (T[]) new Object[newLength]
: (T[]) Array.newInstance(newType.getComponentType(), newLength);
@@ -2851,6 +2859,7 @@
return a.clone();
}
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
int size = size();
if (a.length < size)
@@ -3634,7 +3643,7 @@
if (element == null) {
buf.append("null");
} else {
- Class eClass = element.getClass();
+ Class<?> eClass = element.getClass();
if (eClass.isArray()) {
if (eClass == byte[].class)
--- a/jdk/src/share/classes/java/util/Calendar.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Calendar.java Mon Apr 23 16:58:40 2012 -0700
@@ -840,7 +840,7 @@
* of a Locale.
*/
private static final ConcurrentMap<Locale, int[]> cachedLocaleData
- = new ConcurrentHashMap<Locale, int[]>(3);
+ = new ConcurrentHashMap<>(3);
// Special values of stamp[]
/**
@@ -1499,7 +1499,7 @@
DateFormatSymbols symbols = DateFormatSymbols.getInstance(locale);
String[] strings = getFieldStrings(field, style, symbols);
if (strings != null) {
- Map<String,Integer> names = new HashMap<String,Integer>();
+ Map<String,Integer> names = new HashMap<>();
for (int i = 0; i < strings.length; i++) {
if (strings[i].length() == 0) {
continue;
--- a/jdk/src/share/classes/java/util/Collections.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Collections.java Mon Apr 23 16:58:40 2012 -0700
@@ -150,6 +150,7 @@
* detects that the natural ordering of the list elements is
* found to violate the {@link Comparable} contract
*/
+ @SuppressWarnings("unchecked")
public static <T extends Comparable<? super T>> void sort(List<T> list) {
Object[] a = list.toArray();
Arrays.sort(a);
@@ -212,13 +213,14 @@
* @throws IllegalArgumentException (optional) if the comparator is
* found to violate the {@link Comparator} contract
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> void sort(List<T> list, Comparator<? super T> c) {
Object[] a = list.toArray();
Arrays.sort(a, (Comparator)c);
- ListIterator i = list.listIterator();
+ ListIterator<T> i = list.listIterator();
for (int j=0; j<a.length; j++) {
i.next();
- i.set(a[j]);
+ i.set((T)a[j]);
}
}
@@ -357,9 +359,10 @@
* or the search key is not mutually comparable with the
* elements of the list using this comparator.
*/
+ @SuppressWarnings("unchecked")
public static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c) {
if (c==null)
- return binarySearch((List) list, key);
+ return binarySearch((List<? extends Comparable<? super T>>) list, key);
if (list instanceof RandomAccess || list.size()<BINARYSEARCH_THRESHOLD)
return Collections.indexedBinarySearch(list, key, c);
@@ -406,9 +409,6 @@
return -(low + 1); // key not found
}
- private interface SelfComparable extends Comparable<SelfComparable> {}
-
-
/**
* Reverses the order of the elements in the specified list.<p>
*
@@ -418,12 +418,16 @@
* @throws UnsupportedOperationException if the specified list or
* its list-iterator does not support the <tt>set</tt> operation.
*/
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public static void reverse(List<?> list) {
int size = list.size();
if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) {
for (int i=0, mid=size>>1, j=size-1; i<mid; i++, j--)
swap(list, i, j);
} else {
+ // instead of using a raw type here, it's possible to capture
+ // the wildcard but it will require a call to a supplementary
+ // private method
ListIterator fwd = list.listIterator();
ListIterator rev = list.listIterator(size);
for (int i=0, mid=list.size()>>1; i<mid; i++) {
@@ -493,6 +497,7 @@
* @throws UnsupportedOperationException if the specified list or its
* list-iterator does not support the <tt>set</tt> operation.
*/
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public static void shuffle(List<?> list, Random rnd) {
int size = list.size();
if (size < SHUFFLE_THRESHOLD || list instanceof RandomAccess) {
@@ -506,6 +511,9 @@
swap(arr, i-1, rnd.nextInt(i));
// Dump array back into list
+ // instead of using a raw type here, it's possible to capture
+ // the wildcard but it will require a call to a supplementary
+ // private method
ListIterator it = list.listIterator();
for (int i=0; i<arr.length; i++) {
it.next();
@@ -527,7 +535,11 @@
* || j < 0 || j >= list.size()).
* @since 1.4
*/
+ @SuppressWarnings({ "rawtypes", "unchecked" })
public static void swap(List<?> list, int i, int j) {
+ // instead of using a raw type here, it's possible to capture
+ // the wildcard but it will require a call to a supplementary
+ // private method
final List l = list;
l.set(i, l.set(j, l.get(i)));
}
@@ -657,9 +669,10 @@
* @throws NoSuchElementException if the collection is empty.
* @see Comparable
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
if (comp==null)
- return (T)min((Collection<SelfComparable>) (Collection) coll);
+ return (T)min((Collection) coll);
Iterator<? extends T> i = coll.iterator();
T candidate = i.next();
@@ -727,9 +740,10 @@
* @throws NoSuchElementException if the collection is empty.
* @see Comparable
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {
if (comp==null)
- return (T)max((Collection<SelfComparable>) (Collection) coll);
+ return (T)max((Collection) coll);
Iterator<? extends T> i = coll.iterator();
T candidate = i.next();
@@ -1389,7 +1403,9 @@
extends UnmodifiableSet<Map.Entry<K,V>> {
private static final long serialVersionUID = 7854390611657943733L;
+ @SuppressWarnings({ "unchecked", "rawtypes" })
UnmodifiableEntrySet(Set<? extends Map.Entry<? extends K, ? extends V>> s) {
+ // Need to cast to raw in order to work around a limitation in the type system
super((Set)s);
}
public Iterator<Map.Entry<K,V>> iterator() {
@@ -1408,13 +1424,15 @@
};
}
+ @SuppressWarnings("unchecked")
public Object[] toArray() {
Object[] a = c.toArray();
for (int i=0; i<a.length; i++)
- a[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)a[i]);
+ a[i] = new UnmodifiableEntry<>((Map.Entry<? extends K, ? extends V>)a[i]);
return a;
}
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
// We don't pass a to c.toArray, to avoid window of
// vulnerability wherein an unscrupulous multithreaded client
@@ -1422,7 +1440,7 @@
Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0));
for (int i=0; i<arr.length; i++)
- arr[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)arr[i]);
+ arr[i] = new UnmodifiableEntry<>((Map.Entry<? extends K, ? extends V>)arr[i]);
if (arr.length > a.length)
return (T[])arr;
@@ -1464,7 +1482,7 @@
if (!(o instanceof Set))
return false;
- Set s = (Set) o;
+ Set<?> s = (Set<?>) o;
if (s.size() != c.size())
return false;
return containsAll(s); // Invokes safe containsAll() above
@@ -1493,7 +1511,7 @@
return true;
if (!(o instanceof Map.Entry))
return false;
- Map.Entry t = (Map.Entry)o;
+ Map.Entry<?,?> t = (Map.Entry<?,?>)o;
return eq(e.getKey(), t.getKey()) &&
eq(e.getValue(), t.getValue());
}
--- a/jdk/src/share/classes/java/util/ComparableTimSort.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/ComparableTimSort.java Mon Apr 23 16:58:40 2012 -0700
@@ -114,7 +114,6 @@
// Allocate temp storage (which may be increased later if necessary)
int len = a.length;
- @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
Object[] newArray = new Object[len < 2 * INITIAL_TMP_STORAGE_LENGTH ?
len >>> 1 : INITIAL_TMP_STORAGE_LENGTH];
tmp = newArray;
@@ -209,14 +208,13 @@
* @param start the index of the first element in the range that is
* not already known to be sorted ({@code lo <= start <= hi})
*/
- @SuppressWarnings("fallthrough")
+ @SuppressWarnings({ "fallthrough", "rawtypes", "unchecked" })
private static void binarySort(Object[] a, int lo, int hi, int start) {
assert lo <= start && start <= hi;
if (start == lo)
start++;
for ( ; start < hi; start++) {
- @SuppressWarnings("unchecked")
- Comparable<Object> pivot = (Comparable) a[start];
+ Comparable pivot = (Comparable) a[start];
// Set left (and right) to the index where a[start] (pivot) belongs
int left = lo;
@@ -279,7 +277,7 @@
* @return the length of the run beginning at the specified position in
* the specified array
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private static int countRunAndMakeAscending(Object[] a, int lo, int hi) {
assert lo < hi;
int runHi = lo + 1;
@@ -614,7 +612,7 @@
* (must be aBase + aLen)
* @param len2 length of second run to be merged (must be > 0)
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private void mergeLo(int base1, int len1, int base2, int len2) {
assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
@@ -731,7 +729,7 @@
* (must be aBase + aLen)
* @param len2 length of second run to be merged (must be > 0)
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
private void mergeHi(int base1, int len1, int base2, int len2) {
assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
@@ -865,7 +863,6 @@
else
newSize = Math.min(newSize, a.length >>> 1);
- @SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
Object[] newArray = new Object[newSize];
tmp = newArray;
}
--- a/jdk/src/share/classes/java/util/Currency.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Currency.java Mon Apr 23 16:58:40 2012 -0700
@@ -404,7 +404,7 @@
public static Set<Currency> getAvailableCurrencies() {
synchronized(Currency.class) {
if (available == null) {
- available = new HashSet<Currency>(256);
+ available = new HashSet<>(256);
// Add simple currencies first
for (char c1 = 'A'; c1 <= 'Z'; c1 ++) {
--- a/jdk/src/share/classes/java/util/EnumMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/EnumMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -120,11 +120,12 @@
return (value == null ? NULL : value);
}
+ @SuppressWarnings("unchecked")
private V unmaskNull(Object value) {
- return (V) (value == NULL ? null : value);
+ return (V)(value == NULL ? null : value);
}
- private static final Enum[] ZERO_LENGTH_ENUM_ARRAY = new Enum[0];
+ private static final Enum<?>[] ZERO_LENGTH_ENUM_ARRAY = new Enum<?>[0];
/**
* Creates an empty enum map with the specified key type.
@@ -218,12 +219,12 @@
* key
*/
public boolean containsKey(Object key) {
- return isValidKey(key) && vals[((Enum)key).ordinal()] != null;
+ return isValidKey(key) && vals[((Enum<?>)key).ordinal()] != null;
}
private boolean containsMapping(Object key, Object value) {
return isValidKey(key) &&
- maskNull(value).equals(vals[((Enum)key).ordinal()]);
+ maskNull(value).equals(vals[((Enum<?>)key).ordinal()]);
}
/**
@@ -243,7 +244,7 @@
*/
public V get(Object key) {
return (isValidKey(key) ?
- unmaskNull(vals[((Enum)key).ordinal()]) : null);
+ unmaskNull(vals[((Enum<?>)key).ordinal()]) : null);
}
// Modification Operations
@@ -285,7 +286,7 @@
public V remove(Object key) {
if (!isValidKey(key))
return null;
- int index = ((Enum)key).ordinal();
+ int index = ((Enum<?>)key).ordinal();
Object oldValue = vals[index];
vals[index] = null;
if (oldValue != null)
@@ -296,7 +297,7 @@
private boolean removeMapping(Object key, Object value) {
if (!isValidKey(key))
return false;
- int index = ((Enum)key).ordinal();
+ int index = ((Enum<?>)key).ordinal();
if (maskNull(value).equals(vals[index])) {
vals[index] = null;
size--;
@@ -314,7 +315,7 @@
return false;
// Cheaper than instanceof Enum followed by getDeclaringClass
- Class keyClass = key.getClass();
+ Class<?> keyClass = key.getClass();
return keyClass == keyType || keyClass.getSuperclass() == keyType;
}
@@ -331,8 +332,7 @@
*/
public void putAll(Map<? extends K, ? extends V> m) {
if (m instanceof EnumMap) {
- EnumMap<? extends K, ? extends V> em =
- (EnumMap<? extends K, ? extends V>)m;
+ EnumMap<?, ?> em = (EnumMap<?, ?>)m;
if (em.keyType != keyType) {
if (em.isEmpty())
return;
@@ -476,13 +476,13 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
return containsMapping(entry.getKey(), entry.getValue());
}
public boolean remove(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
return removeMapping(entry.getKey(), entry.getValue());
}
public int size() {
@@ -610,7 +610,7 @@
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
V ourValue = unmaskNull(vals[index]);
Object hisValue = e.getValue();
return (e.getKey() == keyUniverse[index] &&
@@ -655,11 +655,11 @@
if (this == o)
return true;
if (o instanceof EnumMap)
- return equals((EnumMap)o);
+ return equals((EnumMap<?,?>)o);
if (!(o instanceof Map))
return false;
- Map<K,V> m = (Map<K,V>)o;
+ Map<?,?> m = (Map<?,?>)o;
if (size != m.size())
return false;
@@ -680,7 +680,7 @@
return true;
}
- private boolean equals(EnumMap em) {
+ private boolean equals(EnumMap<?,?> em) {
if (em.keyType != keyType)
return size == 0 && em.size == 0;
@@ -721,6 +721,7 @@
*
* @return a shallow copy of this enum map
*/
+ @SuppressWarnings("unchecked")
public EnumMap<K, V> clone() {
EnumMap<K, V> result = null;
try {
@@ -736,7 +737,7 @@
* Throws an exception if e is not of the correct type for this enum set.
*/
private void typeCheck(K key) {
- Class keyClass = key.getClass();
+ Class<?> keyClass = key.getClass();
if (keyClass != keyType && keyClass.getSuperclass() != keyType)
throw new ClassCastException(keyClass + " != " + keyType);
}
@@ -785,6 +786,7 @@
* Reconstitute the <tt>EnumMap</tt> instance from a stream (i.e.,
* deserialize it).
*/
+ @SuppressWarnings("unchecked")
private void readObject(java.io.ObjectInputStream s)
throws java.io.IOException, ClassNotFoundException
{
--- a/jdk/src/share/classes/java/util/EnumSet.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/EnumSet.java Mon Apr 23 16:58:40 2012 -0700
@@ -88,11 +88,11 @@
/**
* All of the values comprising T. (Cached for performance.)
*/
- final Enum[] universe;
+ final Enum<?>[] universe;
- private static Enum[] ZERO_LENGTH_ENUM_ARRAY = new Enum[0];
+ private static Enum<?>[] ZERO_LENGTH_ENUM_ARRAY = new Enum<?>[0];
- EnumSet(Class<E>elementType, Enum[] universe) {
+ EnumSet(Class<E>elementType, Enum<?>[] universe) {
this.elementType = elementType;
this.universe = universe;
}
@@ -105,7 +105,7 @@
* @throws NullPointerException if <tt>elementType</tt> is null
*/
public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) {
- Enum[] universe = getUniverse(elementType);
+ Enum<?>[] universe = getUniverse(elementType);
if (universe == null)
throw new ClassCastException(elementType + " not an enum");
@@ -358,6 +358,7 @@
*
* @return a copy of this set
*/
+ @SuppressWarnings("unchecked")
public EnumSet<E> clone() {
try {
return (EnumSet<E>) super.clone();
@@ -375,7 +376,7 @@
* Throws an exception if e is not of the correct type for this enum set.
*/
final void typeCheck(E e) {
- Class eClass = e.getClass();
+ Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
throw new ClassCastException(eClass + " != " + elementType);
}
@@ -413,16 +414,19 @@
*
* @serial
*/
- private final Enum[] elements;
+ private final Enum<?>[] elements;
SerializationProxy(EnumSet<E> set) {
elementType = set.elementType;
elements = set.toArray(ZERO_LENGTH_ENUM_ARRAY);
}
+ // instead of cast to E, we should perhaps use elementType.cast()
+ // to avoid injection of forged stream, but it will slow the implementation
+ @SuppressWarnings("unchecked")
private Object readResolve() {
EnumSet<E> result = EnumSet.noneOf(elementType);
- for (Enum e : elements)
+ for (Enum<?> e : elements)
result.add((E)e);
return result;
}
--- a/jdk/src/share/classes/java/util/HashMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/HashMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -146,7 +146,7 @@
/**
* The table, resized as necessary. Length MUST Always be a power of two.
*/
- transient Entry[] table;
+ transient Entry<?,?>[] table;
/**
* The number of key-value mappings contained in this map.
@@ -311,16 +311,17 @@
*
* @see #put(Object, Object)
*/
+ @SuppressWarnings("unchecked")
public V get(Object key) {
if (key == null)
- return getForNullKey();
+ return (V)getForNullKey();
int hash = hash(key.hashCode());
- for (Entry<K,V> e = table[indexFor(hash, table.length)];
+ for (Entry<?,?> e = table[indexFor(hash, table.length)];
e != null;
e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k)))
- return e.value;
+ return (V)e.value;
}
return null;
}
@@ -332,8 +333,8 @@
* operations (get and put), but incorporated with conditionals in
* others.
*/
- private V getForNullKey() {
- for (Entry<K,V> e = table[0]; e != null; e = e.next) {
+ private Object getForNullKey() {
+ for (Entry<?,?> e = table[0]; e != null; e = e.next) {
if (e.key == null)
return e.value;
}
@@ -357,15 +358,16 @@
* HashMap. Returns null if the HashMap contains no mapping
* for the key.
*/
+ @SuppressWarnings("unchecked")
final Entry<K,V> getEntry(Object key) {
int hash = (key == null) ? 0 : hash(key.hashCode());
- for (Entry<K,V> e = table[indexFor(hash, table.length)];
+ for (Entry<?,?> e = table[indexFor(hash, table.length)];
e != null;
e = e.next) {
Object k;
if (e.hash == hash &&
((k = e.key) == key || (key != null && key.equals(k))))
- return e;
+ return (Entry<K,V>)e;
}
return null;
}
@@ -388,7 +390,9 @@
return putForNullKey(value);
int hash = hash(key.hashCode());
int i = indexFor(hash, table.length);
- for (Entry<K,V> e = table[i]; e != null; e = e.next) {
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)table[i];
+ for(; e != null; e = e.next) {
Object k;
if (e.hash == hash && ((k = e.key) == key || key.equals(k))) {
V oldValue = e.value;
@@ -407,7 +411,9 @@
* Offloaded version of put for null keys
*/
private V putForNullKey(V value) {
- for (Entry<K,V> e = table[0]; e != null; e = e.next) {
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)table[0];
+ for(; e != null; e = e.next) {
if (e.key == null) {
V oldValue = e.value;
e.value = value;
@@ -435,7 +441,8 @@
* clone or deserialize. It will only happen for construction if the
* input Map is a sorted map whose ordering is inconsistent w/ equals.
*/
- for (Entry<K,V> e = table[i]; e != null; e = e.next) {
+ for (@SuppressWarnings("unchecked")
+ Entry<?,V> e = (Entry<?,V>)table[i]; e != null; e = e.next) {
Object k;
if (e.hash == hash &&
((k = e.key) == key || (key != null && key.equals(k)))) {
@@ -467,14 +474,14 @@
* is irrelevant).
*/
void resize(int newCapacity) {
- Entry[] oldTable = table;
+ Entry<?,?>[] oldTable = table;
int oldCapacity = oldTable.length;
if (oldCapacity == MAXIMUM_CAPACITY) {
threshold = Integer.MAX_VALUE;
return;
}
- Entry[] newTable = new Entry[newCapacity];
+ Entry<?,?>[] newTable = new Entry<?,?>[newCapacity];
transfer(newTable);
table = newTable;
threshold = (int)(newCapacity * loadFactor);
@@ -483,17 +490,18 @@
/**
* Transfers all entries from current table to newTable.
*/
- void transfer(Entry[] newTable) {
- Entry[] src = table;
+ @SuppressWarnings("unchecked")
+ void transfer(Entry<?,?>[] newTable) {
+ Entry<?,?>[] src = table;
int newCapacity = newTable.length;
for (int j = 0; j < src.length; j++) {
- Entry<K,V> e = src[j];
+ Entry<K,V> e = (Entry<K,V>)src[j];
if (e != null) {
src[j] = null;
do {
Entry<K,V> next = e.next;
int i = indexFor(e.hash, newCapacity);
- e.next = newTable[i];
+ e.next = (Entry<K,V>)newTable[i];
newTable[i] = e;
e = next;
} while (e != null);
@@ -560,7 +568,8 @@
final Entry<K,V> removeEntryForKey(Object key) {
int hash = (key == null) ? 0 : hash(key.hashCode());
int i = indexFor(hash, table.length);
- Entry<K,V> prev = table[i];
+ @SuppressWarnings("unchecked")
+ Entry<K,V> prev = (Entry<K,V>)table[i];
Entry<K,V> e = prev;
while (e != null) {
@@ -591,11 +600,12 @@
if (!(o instanceof Map.Entry))
return null;
- Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
Object key = entry.getKey();
int hash = (key == null) ? 0 : hash(key.hashCode());
int i = indexFor(hash, table.length);
- Entry<K,V> prev = table[i];
+ @SuppressWarnings("unchecked")
+ Entry<K,V> prev = (Entry<K,V>)table[i];
Entry<K,V> e = prev;
while (e != null) {
@@ -623,7 +633,7 @@
*/
public void clear() {
modCount++;
- Entry[] tab = table;
+ Entry<?,?>[] tab = table;
for (int i = 0; i < tab.length; i++)
tab[i] = null;
size = 0;
@@ -641,9 +651,9 @@
if (value == null)
return containsNullValue();
- Entry[] tab = table;
+ Entry<?,?>[] tab = table;
for (int i = 0; i < tab.length ; i++)
- for (Entry e = tab[i] ; e != null ; e = e.next)
+ for (Entry<?,?> e = tab[i] ; e != null ; e = e.next)
if (value.equals(e.value))
return true;
return false;
@@ -653,9 +663,9 @@
* Special-case code for containsValue with null argument
*/
private boolean containsNullValue() {
- Entry[] tab = table;
+ Entry<?,?>[] tab = table;
for (int i = 0; i < tab.length ; i++)
- for (Entry e = tab[i] ; e != null ; e = e.next)
+ for (Entry<?,?> e = tab[i] ; e != null ; e = e.next)
if (e.value == null)
return true;
return false;
@@ -667,6 +677,7 @@
*
* @return a shallow copy of this map
*/
+ @SuppressWarnings("unchecked")
public Object clone() {
HashMap<K,V> result = null;
try {
@@ -674,7 +685,7 @@
} catch (CloneNotSupportedException e) {
// assert false;
}
- result.table = new Entry[table.length];
+ result.table = new Entry<?,?>[table.length];
result.entrySet = null;
result.modCount = 0;
result.size = 0;
@@ -717,7 +728,7 @@
public final boolean equals(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
Object k1 = getKey();
Object k2 = e.getKey();
if (k1 == k2 || (k1 != null && k1.equals(k2))) {
@@ -762,7 +773,8 @@
* Subclass overrides this to alter the behavior of put method.
*/
void addEntry(int hash, K key, V value, int bucketIndex) {
- Entry<K,V> e = table[bucketIndex];
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)table[bucketIndex];
table[bucketIndex] = new Entry<>(hash, key, value, e);
if (size++ >= threshold)
resize(2 * table.length);
@@ -777,21 +789,22 @@
* clone, and readObject.
*/
void createEntry(int hash, K key, V value, int bucketIndex) {
- Entry<K,V> e = table[bucketIndex];
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)table[bucketIndex];
table[bucketIndex] = new Entry<>(hash, key, value, e);
size++;
}
private abstract class HashIterator<E> implements Iterator<E> {
- Entry<K,V> next; // next entry to return
+ Entry<?,?> next; // next entry to return
int expectedModCount; // For fast-fail
int index; // current slot
- Entry<K,V> current; // current entry
+ Entry<?,?> current; // current entry
HashIterator() {
expectedModCount = modCount;
if (size > 0) { // advance to first entry
- Entry[] t = table;
+ Entry<?,?>[] t = table;
while (index < t.length && (next = t[index++]) == null)
;
}
@@ -801,20 +814,21 @@
return next != null;
}
+ @SuppressWarnings("unchecked")
final Entry<K,V> nextEntry() {
if (modCount != expectedModCount)
throw new ConcurrentModificationException();
- Entry<K,V> e = next;
+ Entry<?,?> e = next;
if (e == null)
throw new NoSuchElementException();
if ((next = e.next) == null) {
- Entry[] t = table;
+ Entry<?,?>[] t = table;
while (index < t.length && (next = t[index++]) == null)
;
}
current = e;
- return e;
+ return (Entry<K,V>)e;
}
public void remove() {
@@ -965,7 +979,7 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry<K,V> e = (Map.Entry<K,V>) o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>) o;
Entry<K,V> candidate = getEntry(e.getKey());
return candidate != null && candidate.equals(e);
}
@@ -1039,8 +1053,10 @@
// Read the keys and values, and put the mappings in the HashMap
for (int i=0; i<size; i++) {
- K key = (K) s.readObject();
- V value = (V) s.readObject();
+ @SuppressWarnings("unchecked")
+ K key = (K) s.readObject();
+ @SuppressWarnings("unchecked")
+ V value = (V) s.readObject();
putForCreate(key, value);
}
}
--- a/jdk/src/share/classes/java/util/HashSet.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/HashSet.java Mon Apr 23 16:58:40 2012 -0700
@@ -247,6 +247,7 @@
*
* @return a shallow copy of this set
*/
+ @SuppressWarnings("unchecked")
public Object clone() {
try {
HashSet<E> newSet = (HashSet<E>) super.clone();
@@ -296,7 +297,7 @@
// Read in HashMap capacity and load factor and create backing HashMap
int capacity = s.readInt();
float loadFactor = s.readFloat();
- map = (((HashSet)this) instanceof LinkedHashSet ?
+ map = (((HashSet<?>)this) instanceof LinkedHashSet ?
new LinkedHashMap<E,Object>(capacity, loadFactor) :
new HashMap<E,Object>(capacity, loadFactor));
@@ -305,7 +306,8 @@
// Read in all elements in the proper order.
for (int i=0; i<size; i++) {
- E e = (E) s.readObject();
+ @SuppressWarnings("unchecked")
+ E e = (E) s.readObject();
map.put(e, PRESENT);
}
}
--- a/jdk/src/share/classes/java/util/Hashtable.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Hashtable.java Mon Apr 23 16:58:40 2012 -0700
@@ -129,7 +129,7 @@
/**
* The hash table data.
*/
- private transient Entry[] table;
+ private transient Entry<?,?>[] table;
/**
* The total number of entries in the hash table.
@@ -182,7 +182,7 @@
if (initialCapacity==0)
initialCapacity = 1;
this.loadFactor = loadFactor;
- table = new Entry[initialCapacity];
+ table = new Entry<?,?>[initialCapacity];
threshold = (int)(initialCapacity * loadFactor);
}
@@ -288,9 +288,9 @@
throw new NullPointerException();
}
- Entry tab[] = table;
+ Entry<?,?> tab[] = table;
for (int i = tab.length ; i-- > 0 ;) {
- for (Entry<K,V> e = tab[i] ; e != null ; e = e.next) {
+ for (Entry<?,?> e = tab[i] ; e != null ; e = e.next) {
if (e.value.equals(value)) {
return true;
}
@@ -326,10 +326,10 @@
* @see #contains(Object)
*/
public synchronized boolean containsKey(Object key) {
- Entry tab[] = table;
+ Entry<?,?> tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
+ for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
return true;
}
@@ -352,13 +352,14 @@
* @throws NullPointerException if the specified key is null
* @see #put(Object, Object)
*/
+ @SuppressWarnings("unchecked")
public synchronized V get(Object key) {
- Entry tab[] = table;
+ Entry<?,?> tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
+ for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
- return e.value;
+ return (V)e.value;
}
}
return null;
@@ -379,9 +380,10 @@
* number of keys in the hashtable exceeds this hashtable's capacity
* and load factor.
*/
+ @SuppressWarnings("unchecked")
protected void rehash() {
int oldCapacity = table.length;
- Entry[] oldMap = table;
+ Entry<?,?>[] oldMap = table;
// overflow-conscious code
int newCapacity = (oldCapacity << 1) + 1;
@@ -391,19 +393,19 @@
return;
newCapacity = MAX_ARRAY_SIZE;
}
- Entry[] newMap = new Entry[newCapacity];
+ Entry<?,?>[] newMap = new Entry<?,?>[newCapacity];
modCount++;
threshold = (int)(newCapacity * loadFactor);
table = newMap;
for (int i = oldCapacity ; i-- > 0 ;) {
- for (Entry<K,V> old = oldMap[i] ; old != null ; ) {
+ for (Entry<K,V> old = (Entry<K,V>)oldMap[i] ; old != null ; ) {
Entry<K,V> e = old;
old = old.next;
int index = (e.hash & 0x7FFFFFFF) % newCapacity;
- e.next = newMap[index];
+ e.next = (Entry<K,V>)newMap[index];
newMap[index] = e;
}
}
@@ -433,13 +435,15 @@
}
// Makes sure the key is not already in the hashtable.
- Entry tab[] = table;
+ Entry<?,?> tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
- if ((e.hash == hash) && e.key.equals(key)) {
- V old = e.value;
- e.value = value;
+ @SuppressWarnings("unchecked")
+ Entry<K,V> entry = (Entry<K,V>)tab[index];
+ for(; entry != null ; entry = entry.next) {
+ if ((entry.hash == hash) && entry.key.equals(key)) {
+ V old = entry.value;
+ entry.value = value;
return old;
}
}
@@ -454,7 +458,8 @@
}
// Creates the new entry.
- Entry<K,V> e = tab[index];
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)tab[index];
tab[index] = new Entry<>(hash, key, value, e);
count++;
return null;
@@ -470,10 +475,12 @@
* @throws NullPointerException if the key is <code>null</code>
*/
public synchronized V remove(Object key) {
- Entry tab[] = table;
+ Entry<?,?> tab[] = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index], prev = null ; e != null ; prev = e, e = e.next) {
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)tab[index];
+ for(Entry<K,V> prev = null ; e != null ; prev = e, e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
modCount++;
if (prev != null) {
@@ -508,7 +515,7 @@
* Clears this hashtable so that it contains no keys.
*/
public synchronized void clear() {
- Entry tab[] = table;
+ Entry<?,?> tab[] = table;
modCount++;
for (int index = tab.length; --index >= 0; )
tab[index] = null;
@@ -524,11 +531,11 @@
*/
public synchronized Object clone() {
try {
- Hashtable<K,V> t = (Hashtable<K,V>) super.clone();
- t.table = new Entry[table.length];
+ Hashtable<?,?> t = (Hashtable<?,?>)super.clone();
+ t.table = new Entry<?,?>[table.length];
for (int i = table.length ; i-- > 0 ; ) {
t.table[i] = (table[i] != null)
- ? (Entry<K,V>) table[i].clone() : null;
+ ? (Entry<?,?>) table[i].clone() : null;
}
t.keySet = null;
t.entrySet = null;
@@ -675,13 +682,13 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
Object key = entry.getKey();
- Entry[] tab = table;
+ Entry<?,?>[] tab = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry e = tab[index]; e != null; e = e.next)
+ for (Entry<?,?> e = tab[index]; e != null; e = e.next)
if (e.hash==hash && e.equals(entry))
return true;
return false;
@@ -690,14 +697,15 @@
public boolean remove(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
- K key = entry.getKey();
- Entry[] tab = table;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+ Object key = entry.getKey();
+ Entry<?,?>[] tab = table;
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index], prev = null; e != null;
- prev = e, e = e.next) {
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)tab[index];
+ for(Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
if (e.hash==hash && e.equals(entry)) {
modCount++;
if (prev != null)
@@ -776,7 +784,7 @@
if (!(o instanceof Map))
return false;
- Map<K,V> t = (Map<K,V>) o;
+ Map<?,?> t = (Map<?,?>) o;
if (t.size() != size())
return false;
@@ -826,9 +834,9 @@
return h; // Returns zero
loadFactor = -loadFactor; // Mark hashCode computation in progress
- Entry[] tab = table;
+ Entry<?,?>[] tab = table;
for (int i = 0; i < tab.length; i++)
- for (Entry e = tab[i]; e != null; e = e.next)
+ for (Entry<?,?> e = tab[i]; e != null; e = e.next)
h += e.key.hashCode() ^ e.value.hashCode();
loadFactor = -loadFactor; // Mark hashCode computation complete
@@ -859,7 +867,7 @@
// Stack copies of the entries in the table
for (int index = 0; index < table.length; index++) {
- Entry entry = table[index];
+ Entry<?,?> entry = table[index];
while (entry != null) {
entryStack =
@@ -899,14 +907,15 @@
length--;
if (origlength > 0 && length > origlength)
length = origlength;
-
- Entry[] table = new Entry[length];
+ Entry<?,?>[] table = new Entry<?,?>[length];
count = 0;
// Read the number of elements and then all the key/value objects
for (; elements > 0; elements--) {
- K key = (K)s.readObject();
- V value = (V)s.readObject();
+ @SuppressWarnings("unchecked")
+ K key = (K)s.readObject();
+ @SuppressWarnings("unchecked")
+ V value = (V)s.readObject();
// synch could be eliminated for performance
reconstitutionPut(table, key, value);
}
@@ -924,7 +933,7 @@
* because we are creating a new instance. Also, no return value
* is needed.
*/
- private void reconstitutionPut(Entry[] tab, K key, V value)
+ private void reconstitutionPut(Entry<?,?>[] tab, K key, V value)
throws StreamCorruptedException
{
if (value == null) {
@@ -934,13 +943,14 @@
// This should not happen in deserialized version.
int hash = key.hashCode();
int index = (hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index] ; e != null ; e = e.next) {
+ for (Entry<?,?> e = tab[index] ; e != null ; e = e.next) {
if ((e.hash == hash) && e.key.equals(key)) {
throw new java.io.StreamCorruptedException();
}
}
// Creates the new entry.
- Entry<K,V> e = tab[index];
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)tab[index];
tab[index] = new Entry<>(hash, key, value, e);
count++;
}
@@ -961,6 +971,7 @@
this.next = next;
}
+ @SuppressWarnings("unchecked")
protected Object clone() {
return new Entry<>(hash, key, value,
(next==null ? null : (Entry<K,V>) next.clone()));
@@ -988,7 +999,7 @@
public boolean equals(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
return (key==null ? e.getKey()==null : key.equals(e.getKey())) &&
(value==null ? e.getValue()==null : value.equals(e.getValue()));
@@ -1016,10 +1027,10 @@
* by passing an Enumeration.
*/
private class Enumerator<T> implements Enumeration<T>, Iterator<T> {
- Entry[] table = Hashtable.this.table;
+ Entry<?,?>[] table = Hashtable.this.table;
int index = table.length;
- Entry<K,V> entry = null;
- Entry<K,V> lastReturned = null;
+ Entry<?,?> entry = null;
+ Entry<?,?> lastReturned = null;
int type;
/**
@@ -1041,9 +1052,9 @@
}
public boolean hasMoreElements() {
- Entry<K,V> e = entry;
+ Entry<?,?> e = entry;
int i = index;
- Entry[] t = table;
+ Entry<?,?>[] t = table;
/* Use locals for faster loop iteration */
while (e == null && i > 0) {
e = t[--i];
@@ -1053,10 +1064,11 @@
return e != null;
}
+ @SuppressWarnings("unchecked")
public T nextElement() {
- Entry<K,V> et = entry;
+ Entry<?,?> et = entry;
int i = index;
- Entry[] t = table;
+ Entry<?,?>[] t = table;
/* Use locals for faster loop iteration */
while (et == null && i > 0) {
et = t[--i];
@@ -1064,7 +1076,7 @@
entry = et;
index = i;
if (et != null) {
- Entry<K,V> e = lastReturned = entry;
+ Entry<?,?> e = lastReturned = entry;
entry = e.next;
return type == KEYS ? (T)e.key : (type == VALUES ? (T)e.value : (T)e);
}
@@ -1091,11 +1103,12 @@
throw new ConcurrentModificationException();
synchronized(Hashtable.this) {
- Entry[] tab = Hashtable.this.table;
+ Entry<?,?>[] tab = Hashtable.this.table;
int index = (lastReturned.hash & 0x7FFFFFFF) % tab.length;
- for (Entry<K,V> e = tab[index], prev = null; e != null;
- prev = e, e = e.next) {
+ @SuppressWarnings("unchecked")
+ Entry<K,V> e = (Entry<K,V>)tab[index];
+ for(Entry<K,V> prev = null; e != null; prev = e, e = e.next) {
if (e == lastReturned) {
modCount++;
expectedModCount++;
--- a/jdk/src/share/classes/java/util/IdentityHashMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/IdentityHashMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -327,6 +327,7 @@
*
* @see #put(Object, Object)
*/
+ @SuppressWarnings("unchecked")
public V get(Object key) {
Object k = maskNull(key);
Object[] tab = table;
@@ -431,7 +432,8 @@
Object item;
while ( (item = tab[i]) != null) {
if (item == k) {
- V oldValue = (V) tab[i + 1];
+ @SuppressWarnings("unchecked")
+ V oldValue = (V) tab[i + 1];
tab[i + 1] = value;
return oldValue;
}
@@ -524,7 +526,8 @@
if (item == k) {
modCount++;
size--;
- V oldValue = (V) tab[i + 1];
+ @SuppressWarnings("unchecked")
+ V oldValue = (V) tab[i + 1];
tab[i + 1] = null;
tab[i] = null;
closeDeletion(i);
@@ -638,7 +641,7 @@
if (o == this) {
return true;
} else if (o instanceof IdentityHashMap) {
- IdentityHashMap m = (IdentityHashMap) o;
+ IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) o;
if (m.size() != size)
return false;
@@ -650,7 +653,7 @@
}
return true;
} else if (o instanceof Map) {
- Map m = (Map)o;
+ Map<?,?> m = (Map<?,?>)o;
return entrySet().equals(m.entrySet());
} else {
return false; // o is not a Map
@@ -698,7 +701,7 @@
*/
public Object clone() {
try {
- IdentityHashMap<K,V> m = (IdentityHashMap<K,V>) super.clone();
+ IdentityHashMap<?,?> m = (IdentityHashMap<?,?>) super.clone();
m.entrySet = null;
m.table = table.clone();
return m;
@@ -768,7 +771,7 @@
int len = tab.length;
int d = deletedSlot;
- K key = (K) tab[d];
+ Object key = tab[d];
tab[d] = null; // vacate the slot
tab[d + 1] = null;
@@ -818,12 +821,14 @@
}
private class KeyIterator extends IdentityHashMapIterator<K> {
+ @SuppressWarnings("unchecked")
public K next() {
return (K) unmaskNull(traversalTable[nextIndex()]);
}
}
private class ValueIterator extends IdentityHashMapIterator<V> {
+ @SuppressWarnings("unchecked")
public V next() {
return (V) traversalTable[nextIndex() + 1];
}
@@ -854,16 +859,19 @@
this.index = index;
}
+ @SuppressWarnings("unchecked")
public K getKey() {
checkIndexForEntryUse();
return (K) unmaskNull(traversalTable[index]);
}
+ @SuppressWarnings("unchecked")
public V getValue() {
checkIndexForEntryUse();
return (V) traversalTable[index+1];
}
+ @SuppressWarnings("unchecked")
public V setValue(V value) {
checkIndexForEntryUse();
V oldValue = (V) traversalTable[index+1];
@@ -880,7 +888,7 @@
if (!(o instanceof Map.Entry))
return false;
- Map.Entry e = (Map.Entry)o;
+ Map.Entry<?,?> e = (Map.Entry<?,?>)o;
return (e.getKey() == unmaskNull(traversalTable[index]) &&
e.getValue() == traversalTable[index+1]);
}
@@ -1109,13 +1117,13 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
return containsMapping(entry.getKey(), entry.getValue());
}
public boolean remove(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry entry = (Map.Entry)o;
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)o;
return removeMapping(entry.getKey(), entry.getValue());
}
public int size() {
@@ -1213,8 +1221,10 @@
// Read the keys and values, and put the mappings in the table
for (int i=0; i<size; i++) {
- K key = (K) s.readObject();
- V value = (V) s.readObject();
+ @SuppressWarnings("unchecked")
+ K key = (K) s.readObject();
+ @SuppressWarnings("unchecked")
+ V value = (V) s.readObject();
putForCreate(key, value);
}
}
@@ -1226,7 +1236,7 @@
private void putForCreate(K key, V value)
throws IOException
{
- K k = (K)maskNull(key);
+ Object k = maskNull(key);
Object[] tab = table;
int len = tab.length;
int i = hash(k, len);
--- a/jdk/src/share/classes/java/util/IllegalFormatConversionException.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/IllegalFormatConversionException.java Mon Apr 23 16:58:40 2012 -0700
@@ -40,7 +40,7 @@
private static final long serialVersionUID = 17000126L;
private char c;
- private Class arg;
+ private Class<?> arg;
/**
* Constructs an instance of this class with the mismatched conversion and
--- a/jdk/src/share/classes/java/util/JumboEnumSet.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/JumboEnumSet.java Mon Apr 23 16:58:40 2012 -0700
@@ -46,7 +46,7 @@
// Redundant - maintained for performance
private int size = 0;
- JumboEnumSet(Class<E>elementType, Enum[] universe) {
+ JumboEnumSet(Class<E>elementType, Enum<?>[] universe) {
super(elementType, universe);
elements = new long[(universe.length + 63) >>> 6];
}
@@ -127,6 +127,7 @@
return unseen != 0;
}
+ @Override
public E next() {
if (!hasNext())
throw new NoSuchElementException();
@@ -176,11 +177,11 @@
public boolean contains(Object e) {
if (e == null)
return false;
- Class eClass = e.getClass();
+ Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
return false;
- int eOrdinal = ((Enum)e).ordinal();
+ int eOrdinal = ((Enum<?>)e).ordinal();
return (elements[eOrdinal >>> 6] & (1L << eOrdinal)) != 0;
}
@@ -217,10 +218,10 @@
public boolean remove(Object e) {
if (e == null)
return false;
- Class eClass = e.getClass();
+ Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
return false;
- int eOrdinal = ((Enum)e).ordinal();
+ int eOrdinal = ((Enum<?>)e).ordinal();
int eWordNum = eOrdinal >>> 6;
long oldElements = elements[eWordNum];
@@ -246,7 +247,7 @@
if (!(c instanceof JumboEnumSet))
return super.containsAll(c);
- JumboEnumSet es = (JumboEnumSet)c;
+ JumboEnumSet<?> es = (JumboEnumSet<?>)c;
if (es.elementType != elementType)
return es.isEmpty();
@@ -268,7 +269,7 @@
if (!(c instanceof JumboEnumSet))
return super.addAll(c);
- JumboEnumSet es = (JumboEnumSet)c;
+ JumboEnumSet<?> es = (JumboEnumSet<?>)c;
if (es.elementType != elementType) {
if (es.isEmpty())
return false;
@@ -294,7 +295,7 @@
if (!(c instanceof JumboEnumSet))
return super.removeAll(c);
- JumboEnumSet es = (JumboEnumSet)c;
+ JumboEnumSet<?> es = (JumboEnumSet<?>)c;
if (es.elementType != elementType)
return false;
@@ -348,7 +349,7 @@
if (!(o instanceof JumboEnumSet))
return super.equals(o);
- JumboEnumSet es = (JumboEnumSet)o;
+ JumboEnumSet<?> es = (JumboEnumSet<?>)o;
if (es.elementType != elementType)
return size == 0 && es.size == 0;
--- a/jdk/src/share/classes/java/util/LinkedHashMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/LinkedHashMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -246,11 +246,12 @@
* by superclass resize. It is overridden for performance, as it is
* faster to iterate using our linked list.
*/
+ @SuppressWarnings("unchecked")
void transfer(HashMap.Entry[] newTable) {
int newCapacity = newTable.length;
for (Entry<K,V> e = header.after; e != header; e = e.after) {
int index = indexFor(e.hash, newCapacity);
- e.next = newTable[index];
+ e.next = (HashMap.Entry<K,V>)newTable[index];
newTable[index] = e;
}
}
@@ -267,11 +268,11 @@
public boolean containsValue(Object value) {
// Overridden to take advantage of faster iterator
if (value==null) {
- for (Entry e = header.after; e != header; e = e.after)
+ for (Entry<?,?> e = header.after; e != header; e = e.after)
if (e.value==null)
return true;
} else {
- for (Entry e = header.after; e != header; e = e.after)
+ for (Entry<?,?> e = header.after; e != header; e = e.after)
if (value.equals(e.value))
return true;
}
@@ -437,7 +438,8 @@
* table or remove the eldest entry.
*/
void createEntry(int hash, K key, V value, int bucketIndex) {
- HashMap.Entry<K,V> old = table[bucketIndex];
+ @SuppressWarnings("unchecked")
+ HashMap.Entry<K,V> old = (HashMap.Entry<K,V>)table[bucketIndex];
Entry<K,V> e = new Entry<>(hash, key, value, old);
table[bucketIndex] = e;
e.addBefore(header);
--- a/jdk/src/share/classes/java/util/Observable.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Observable.java Mon Apr 23 16:58:40 2012 -0700
@@ -61,12 +61,12 @@
*/
public class Observable {
private boolean changed = false;
- private Vector obs;
+ private Vector<Observer> obs;
/** Construct an Observable with zero Observers. */
public Observable() {
- obs = new Vector();
+ obs = new Vector<>();
}
/**
--- a/jdk/src/share/classes/java/util/PriorityQueue.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/PriorityQueue.java Mon Apr 23 16:58:40 2012 -0700
@@ -449,6 +449,7 @@
* this queue
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
if (a.length < size)
// Make a new array of a's runtime type, but my contents:
@@ -514,6 +515,7 @@
(forgetMeNot != null && !forgetMeNot.isEmpty());
}
+ @SuppressWarnings("unchecked")
public E next() {
if (expectedModCount != modCount)
throw new ConcurrentModificationException();
@@ -571,8 +573,10 @@
return null;
int s = --size;
modCount++;
- E result = (E) queue[0];
- E x = (E) queue[s];
+ @SuppressWarnings("unchecked")
+ E result = (E) queue[0];
+ @SuppressWarnings("unchecked")
+ E x = (E) queue[s];
queue[s] = null;
if (s != 0)
siftDown(0, x);
@@ -598,7 +602,8 @@
if (s == i) // removed last element
queue[i] = null;
else {
- E moved = (E) queue[s];
+ @SuppressWarnings("unchecked")
+ E moved = (E) queue[s];
queue[s] = null;
siftDown(i, moved);
if (queue[i] == moved) {
@@ -629,6 +634,7 @@
siftUpComparable(k, x);
}
+ @SuppressWarnings("unchecked")
private void siftUpComparable(int k, E x) {
Comparable<? super E> key = (Comparable<? super E>) x;
while (k > 0) {
@@ -645,8 +651,9 @@
private void siftUpUsingComparator(int k, E x) {
while (k > 0) {
int parent = (k - 1) >>> 1;
- Object e = queue[parent];
- if (comparator.compare(x, (E) e) >= 0)
+ @SuppressWarnings("unchecked")
+ E e = (E) queue[parent];
+ if (comparator.compare(x, e) >= 0)
break;
queue[k] = e;
k = parent;
@@ -669,6 +676,7 @@
siftDownComparable(k, x);
}
+ @SuppressWarnings("unchecked")
private void siftDownComparable(int k, E x) {
Comparable<? super E> key = (Comparable<? super E>)x;
int half = size >>> 1; // loop while a non-leaf
@@ -687,6 +695,7 @@
queue[k] = key;
}
+ @SuppressWarnings("unchecked")
private void siftDownUsingComparator(int k, E x) {
int half = size >>> 1;
while (k < half) {
@@ -708,6 +717,7 @@
* Establishes the heap invariant (described above) in the entire tree,
* assuming nothing about the order of the elements prior to the call.
*/
+ @SuppressWarnings("unchecked")
private void heapify() {
for (int i = (size >>> 1) - 1; i >= 0; i--)
siftDown(i, (E) queue[i]);
--- a/jdk/src/share/classes/java/util/Properties.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/Properties.java Mon Apr 23 16:58:40 2012 -0700
@@ -824,7 +824,7 @@
bw.write("#" + new Date().toString());
bw.newLine();
synchronized (this) {
- for (Enumeration e = keys(); e.hasMoreElements();) {
+ for (Enumeration<?> e = keys(); e.hasMoreElements();) {
String key = (String)e.nextElement();
String val = (String)get(key);
key = saveConvert(key, true, escUnicode);
@@ -987,7 +987,7 @@
* @see #stringPropertyNames
*/
public Enumeration<?> propertyNames() {
- Hashtable h = new Hashtable();
+ Hashtable<String,Object> h = new Hashtable<>();
enumerate(h);
return h.keys();
}
@@ -1026,10 +1026,10 @@
*/
public void list(PrintStream out) {
out.println("-- listing properties --");
- Hashtable h = new Hashtable();
+ Hashtable<String,Object> h = new Hashtable<>();
enumerate(h);
- for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
- String key = (String)e.nextElement();
+ for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
+ String key = e.nextElement();
String val = (String)h.get(key);
if (val.length() > 40) {
val = val.substring(0, 37) + "...";
@@ -1054,10 +1054,10 @@
*/
public void list(PrintWriter out) {
out.println("-- listing properties --");
- Hashtable h = new Hashtable();
+ Hashtable<String,Object> h = new Hashtable<>();
enumerate(h);
- for (Enumeration e = h.keys() ; e.hasMoreElements() ;) {
- String key = (String)e.nextElement();
+ for (Enumeration<String> e = h.keys() ; e.hasMoreElements() ;) {
+ String key = e.nextElement();
String val = (String)h.get(key);
if (val.length() > 40) {
val = val.substring(0, 37) + "...";
@@ -1072,11 +1072,11 @@
* @throws ClassCastException if any of the property keys
* is not of String type.
*/
- private synchronized void enumerate(Hashtable h) {
+ private synchronized void enumerate(Hashtable<String,Object> h) {
if (defaults != null) {
defaults.enumerate(h);
}
- for (Enumeration e = keys() ; e.hasMoreElements() ;) {
+ for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
String key = (String)e.nextElement();
h.put(key, get(key));
}
@@ -1091,7 +1091,7 @@
if (defaults != null) {
defaults.enumerateStringProperties(h);
}
- for (Enumeration e = keys() ; e.hasMoreElements() ;) {
+ for (Enumeration<?> e = keys() ; e.hasMoreElements() ;) {
Object k = e.nextElement();
Object v = get(k);
if (k instanceof String && v instanceof String) {
--- a/jdk/src/share/classes/java/util/PropertyPermission.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/PropertyPermission.java Mon Apr 23 16:58:40 2012 -0700
@@ -442,7 +442,7 @@
* Key is property name; value is PropertyPermission.
* Not serialized; see serialization section at end of class.
*/
- private transient Map<String, Permission> perms;
+ private transient Map<String, PropertyPermission> perms;
/**
* Boolean saying if "*" is in the collection.
@@ -488,7 +488,7 @@
String propName = pp.getName();
synchronized (this) {
- PropertyPermission existing = (PropertyPermission) perms.get(propName);
+ PropertyPermission existing = perms.get(propName);
if (existing != null) {
int oldMask = existing.getMask();
@@ -499,7 +499,7 @@
perms.put(propName, new PropertyPermission(propName, actions));
}
} else {
- perms.put(propName, permission);
+ perms.put(propName, pp);
}
}
@@ -533,7 +533,7 @@
// short circuit if the "*" Permission was added
if (all_allowed) {
synchronized (this) {
- x = (PropertyPermission) perms.get("*");
+ x = perms.get("*");
}
if (x != null) {
effective |= x.getMask();
@@ -550,7 +550,7 @@
//System.out.println("check "+name);
synchronized (this) {
- x = (PropertyPermission) perms.get(name);
+ x = perms.get(name);
}
if (x != null) {
@@ -570,7 +570,7 @@
name = name.substring(0, last+1) + "*";
//System.out.println("check "+name);
synchronized (this) {
- x = (PropertyPermission) perms.get(name);
+ x = perms.get(name);
}
if (x != null) {
@@ -592,11 +592,15 @@
*
* @return an enumeration of all the PropertyPermission objects.
*/
-
+ @SuppressWarnings("unchecked")
public Enumeration<Permission> elements() {
// Convert Iterator of Map values into an Enumeration
synchronized (this) {
- return Collections.enumeration(perms.values());
+ /**
+ * Casting to rawtype since Enumeration<PropertyPermission>
+ * cannot be directly cast to Enumeration<Permission>
+ */
+ return (Enumeration)Collections.enumeration(perms.values());
}
}
@@ -633,7 +637,8 @@
// Don't call out.defaultWriteObject()
// Copy perms into a Hashtable
- Hashtable<String, Permission> permissions = new Hashtable<>(perms.size()*2);
+ Hashtable<String, Permission> permissions =
+ new Hashtable<>(perms.size()*2);
synchronized (this) {
permissions.putAll(perms);
}
@@ -661,8 +666,8 @@
// Get permissions
@SuppressWarnings("unchecked")
- Hashtable<String, Permission> permissions =
- (Hashtable<String, Permission>)gfields.get("permissions", null);
+ Hashtable<String, PropertyPermission> permissions =
+ (Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
perms = new HashMap<>(permissions.size()*2);
perms.putAll(permissions);
}
--- a/jdk/src/share/classes/java/util/RegularEnumSet.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/RegularEnumSet.java Mon Apr 23 16:58:40 2012 -0700
@@ -41,7 +41,7 @@
*/
private long elements = 0L;
- RegularEnumSet(Class<E>elementType, Enum[] universe) {
+ RegularEnumSet(Class<E>elementType, Enum<?>[] universe) {
super(elementType, universe);
}
@@ -96,6 +96,7 @@
return unseen != 0;
}
+ @SuppressWarnings("unchecked")
public E next() {
if (unseen == 0)
throw new NoSuchElementException();
@@ -139,11 +140,11 @@
public boolean contains(Object e) {
if (e == null)
return false;
- Class eClass = e.getClass();
+ Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
return false;
- return (elements & (1L << ((Enum)e).ordinal())) != 0;
+ return (elements & (1L << ((Enum<?>)e).ordinal())) != 0;
}
// Modification Operations
@@ -160,7 +161,7 @@
typeCheck(e);
long oldElements = elements;
- elements |= (1L << ((Enum)e).ordinal());
+ elements |= (1L << ((Enum<?>)e).ordinal());
return elements != oldElements;
}
@@ -173,12 +174,12 @@
public boolean remove(Object e) {
if (e == null)
return false;
- Class eClass = e.getClass();
+ Class<?> eClass = e.getClass();
if (eClass != elementType && eClass.getSuperclass() != elementType)
return false;
long oldElements = elements;
- elements &= ~(1L << ((Enum)e).ordinal());
+ elements &= ~(1L << ((Enum<?>)e).ordinal());
return elements != oldElements;
}
@@ -197,7 +198,7 @@
if (!(c instanceof RegularEnumSet))
return super.containsAll(c);
- RegularEnumSet es = (RegularEnumSet)c;
+ RegularEnumSet<?> es = (RegularEnumSet<?>)c;
if (es.elementType != elementType)
return es.isEmpty();
@@ -216,7 +217,7 @@
if (!(c instanceof RegularEnumSet))
return super.addAll(c);
- RegularEnumSet es = (RegularEnumSet)c;
+ RegularEnumSet<?> es = (RegularEnumSet<?>)c;
if (es.elementType != elementType) {
if (es.isEmpty())
return false;
@@ -242,7 +243,7 @@
if (!(c instanceof RegularEnumSet))
return super.removeAll(c);
- RegularEnumSet es = (RegularEnumSet)c;
+ RegularEnumSet<?> es = (RegularEnumSet<?>)c;
if (es.elementType != elementType)
return false;
@@ -295,7 +296,7 @@
if (!(o instanceof RegularEnumSet))
return super.equals(o);
- RegularEnumSet es = (RegularEnumSet)o;
+ RegularEnumSet<?> es = (RegularEnumSet<?>)o;
if (es.elementType != elementType)
return elements == 0 && es.elements == 0;
return es.elements == elements;
--- a/jdk/src/share/classes/java/util/ResourceBundle.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/ResourceBundle.java Mon Apr 23 16:58:40 2012 -0700
@@ -294,7 +294,8 @@
/**
* Queue for reference objects referring to class loaders or bundles.
*/
- private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
+ private static final ReferenceQueue<Object> referenceQueue =
+ new ReferenceQueue<>();
/**
* The parent bundle of this bundle.
@@ -417,7 +418,7 @@
* caller's caller.
*/
private static ClassLoader getLoader() {
- Class[] stack = getClassContext();
+ Class<?>[] stack = getClassContext();
/* Magic number 2 identifies our caller's caller */
Class<?> c = stack[2];
ClassLoader cl = (c == null) ? null : c.getClassLoader();
@@ -434,7 +435,7 @@
return cl;
}
- private static native Class[] getClassContext();
+ private static native Class<?>[] getClassContext();
/**
* A wrapper of ClassLoader.getSystemClassLoader().
--- a/jdk/src/share/classes/java/util/ServiceLoader.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/ServiceLoader.java Mon Apr 23 16:58:40 2012 -0700
@@ -218,20 +218,20 @@
reload();
}
- private static void fail(Class service, String msg, Throwable cause)
+ private static void fail(Class<?> service, String msg, Throwable cause)
throws ServiceConfigurationError
{
throw new ServiceConfigurationError(service.getName() + ": " + msg,
cause);
}
- private static void fail(Class service, String msg)
+ private static void fail(Class<?> service, String msg)
throws ServiceConfigurationError
{
throw new ServiceConfigurationError(service.getName() + ": " + msg);
}
- private static void fail(Class service, URL u, int line, String msg)
+ private static void fail(Class<?> service, URL u, int line, String msg)
throws ServiceConfigurationError
{
fail(service, u + ":" + line + ": " + msg);
@@ -240,7 +240,7 @@
// Parse a single line from the given configuration file, adding the name
// on the line to the names list.
//
- private int parseLine(Class service, URL u, BufferedReader r, int lc,
+ private int parseLine(Class<?> service, URL u, BufferedReader r, int lc,
List<String> names)
throws IOException, ServiceConfigurationError
{
@@ -286,7 +286,7 @@
// If an I/O error occurs while reading from the given URL, or
// if a configuration-file format error is detected
//
- private Iterator<String> parse(Class service, URL u)
+ private Iterator<String> parse(Class<?> service, URL u)
throws ServiceConfigurationError
{
InputStream in = null;
--- a/jdk/src/share/classes/java/util/TimeZone.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/TimeZone.java Mon Apr 23 16:58:40 2012 -0700
@@ -428,7 +428,7 @@
// The structure is:
// Map(key=id, value=SoftReference(Map(key=locale, value=displaynames)))
private static final Map<String, SoftReference<Map<Locale, String[]>>> CACHE =
- new ConcurrentHashMap<String, SoftReference<Map<Locale, String[]>>>();
+ new ConcurrentHashMap<>();
}
private static final String[] getDisplayNames(String id, Locale locale) {
@@ -452,9 +452,9 @@
String[] names = TimeZoneNameUtility.retrieveDisplayNames(id, locale);
if (names != null) {
- Map<Locale, String[]> perLocale = new ConcurrentHashMap<Locale, String[]>();
+ Map<Locale, String[]> perLocale = new ConcurrentHashMap<>();
perLocale.put(locale, names);
- ref = new SoftReference<Map<Locale, String[]>>(perLocale);
+ ref = new SoftReference<>(perLocale);
displayNames.put(id, ref);
}
return names;
--- a/jdk/src/share/classes/java/util/TreeMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/TreeMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -307,7 +307,7 @@
public void putAll(Map<? extends K, ? extends V> map) {
int mapSize = map.size();
if (size==0 && mapSize!=0 && map instanceof SortedMap) {
- Comparator c = ((SortedMap)map).comparator();
+ Comparator<?> c = ((SortedMap<?,?>)map).comparator();
if (c == comparator || (c != null && c.equals(comparator))) {
++modCount;
try {
@@ -340,7 +340,8 @@
return getEntryUsingComparator(key);
if (key == null)
throw new NullPointerException();
- Comparable<? super K> k = (Comparable<? super K>) key;
+ @SuppressWarnings("unchecked")
+ Comparable<? super K> k = (Comparable<? super K>) key;
Entry<K,V> p = root;
while (p != null) {
int cmp = k.compareTo(p.key);
@@ -361,7 +362,8 @@
* worthwhile here.)
*/
final Entry<K,V> getEntryUsingComparator(Object key) {
- K k = (K) key;
+ @SuppressWarnings("unchecked")
+ K k = (K) key;
Comparator<? super K> cpr = comparator;
if (cpr != null) {
Entry<K,V> p = root;
@@ -554,7 +556,8 @@
else {
if (key == null)
throw new NullPointerException();
- Comparable<? super K> k = (Comparable<? super K>) key;
+ @SuppressWarnings("unchecked")
+ Comparable<? super K> k = (Comparable<? super K>) key;
do {
parent = t;
cmp = k.compareTo(t.key);
@@ -618,9 +621,9 @@
* @return a shallow copy of this map
*/
public Object clone() {
- TreeMap<K,V> clone = null;
+ TreeMap<?,?> clone;
try {
- clone = (TreeMap<K,V>) super.clone();
+ clone = (TreeMap<?,?>) super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalError(e);
}
@@ -803,7 +806,7 @@
*/
public NavigableSet<K> navigableKeySet() {
KeySet<K> nks = navigableKeySet;
- return (nks != null) ? nks : (navigableKeySet = new KeySet(this));
+ return (nks != null) ? nks : (navigableKeySet = new KeySet<>(this));
}
/**
@@ -859,9 +862,9 @@
public NavigableMap<K, V> descendingMap() {
NavigableMap<K, V> km = descendingMap;
return (km != null) ? km :
- (descendingMap = new DescendingSubMap(this,
- true, null, true,
- true, null, true));
+ (descendingMap = new DescendingSubMap<>(this,
+ true, null, true,
+ true, null, true));
}
/**
@@ -874,9 +877,9 @@
*/
public NavigableMap<K,V> subMap(K fromKey, boolean fromInclusive,
K toKey, boolean toInclusive) {
- return new AscendingSubMap(this,
- false, fromKey, fromInclusive,
- false, toKey, toInclusive);
+ return new AscendingSubMap<>(this,
+ false, fromKey, fromInclusive,
+ false, toKey, toInclusive);
}
/**
@@ -888,9 +891,9 @@
* @since 1.6
*/
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
- return new AscendingSubMap(this,
- true, null, true,
- false, toKey, inclusive);
+ return new AscendingSubMap<>(this,
+ true, null, true,
+ false, toKey, inclusive);
}
/**
@@ -902,9 +905,9 @@
* @since 1.6
*/
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
- return new AscendingSubMap(this,
- false, fromKey, inclusive,
- true, null, true);
+ return new AscendingSubMap<>(this,
+ false, fromKey, inclusive,
+ true, null, true);
}
/**
@@ -978,8 +981,8 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
- V value = entry.getValue();
+ Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+ Object value = entry.getValue();
Entry<K,V> p = getEntry(entry.getKey());
return p != null && valEquals(p.getValue(), value);
}
@@ -987,8 +990,8 @@
public boolean remove(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
- V value = entry.getValue();
+ Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+ Object value = entry.getValue();
Entry<K,V> p = getEntry(entry.getKey());
if (p != null && valEquals(p.getValue(), value)) {
deleteEntry(p);
@@ -1023,21 +1026,21 @@
}
static final class KeySet<E> extends AbstractSet<E> implements NavigableSet<E> {
- private final NavigableMap<E, Object> m;
- KeySet(NavigableMap<E,Object> map) { m = map; }
+ private final NavigableMap<E, ?> m;
+ KeySet(NavigableMap<E,?> map) { m = map; }
public Iterator<E> iterator() {
if (m instanceof TreeMap)
- return ((TreeMap<E,Object>)m).keyIterator();
+ return ((TreeMap<E,?>)m).keyIterator();
else
- return (Iterator<E>)(((TreeMap.NavigableSubMap)m).keyIterator());
+ return ((TreeMap.NavigableSubMap<E,?>)m).keyIterator();
}
public Iterator<E> descendingIterator() {
if (m instanceof TreeMap)
- return ((TreeMap<E,Object>)m).descendingKeyIterator();
+ return ((TreeMap<E,?>)m).descendingKeyIterator();
else
- return (Iterator<E>)(((TreeMap.NavigableSubMap)m).descendingKeyIterator());
+ return ((TreeMap.NavigableSubMap<E,?>)m).descendingKeyIterator();
}
public int size() { return m.size(); }
@@ -1052,11 +1055,11 @@
public E last() { return m.lastKey(); }
public Comparator<? super E> comparator() { return m.comparator(); }
public E pollFirst() {
- Map.Entry<E,Object> e = m.pollFirstEntry();
+ Map.Entry<E,?> e = m.pollFirstEntry();
return (e == null) ? null : e.getKey();
}
public E pollLast() {
- Map.Entry<E,Object> e = m.pollLastEntry();
+ Map.Entry<E,?> e = m.pollLastEntry();
return (e == null) ? null : e.getKey();
}
public boolean remove(Object o) {
@@ -1085,7 +1088,7 @@
return tailSet(fromElement, true);
}
public NavigableSet<E> descendingSet() {
- return new KeySet(m.descendingMap());
+ return new KeySet<>(m.descendingMap());
}
}
@@ -1184,6 +1187,7 @@
/**
* Compares two keys using the correct comparison method for this TreeMap.
*/
+ @SuppressWarnings("unchecked")
final int compare(Object k1, Object k2) {
return comparator==null ? ((Comparable<? super K>)k1).compareTo((K)k2)
: comparator.compare((K)k1, (K)k2);
@@ -1488,7 +1492,7 @@
public final NavigableSet<K> navigableKeySet() {
KeySet<K> nksv = navigableKeySetView;
return (nksv != null) ? nksv :
- (navigableKeySetView = new TreeMap.KeySet(this));
+ (navigableKeySetView = new TreeMap.KeySet<>(this));
}
public final Set<K> keySet() {
@@ -1522,7 +1526,7 @@
if (size == -1 || sizeModCount != m.modCount) {
sizeModCount = m.modCount;
size = 0;
- Iterator i = iterator();
+ Iterator<?> i = iterator();
while (i.hasNext()) {
size++;
i.next();
@@ -1539,11 +1543,11 @@
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
- K key = entry.getKey();
+ Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+ Object key = entry.getKey();
if (!inRange(key))
return false;
- TreeMap.Entry node = m.getEntry(key);
+ TreeMap.Entry<?,?> node = m.getEntry(key);
return node != null &&
valEquals(node.getValue(), entry.getValue());
}
@@ -1551,8 +1555,8 @@
public boolean remove(Object o) {
if (!(o instanceof Map.Entry))
return false;
- Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
- K key = entry.getKey();
+ Map.Entry<?,?> entry = (Map.Entry<?,?>) o;
+ Object key = entry.getKey();
if (!inRange(key))
return false;
TreeMap.Entry<K,V> node = m.getEntry(key);
@@ -1709,34 +1713,34 @@
throw new IllegalArgumentException("fromKey out of range");
if (!inRange(toKey, toInclusive))
throw new IllegalArgumentException("toKey out of range");
- return new AscendingSubMap(m,
- false, fromKey, fromInclusive,
- false, toKey, toInclusive);
+ return new AscendingSubMap<>(m,
+ false, fromKey, fromInclusive,
+ false, toKey, toInclusive);
}
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
if (!inRange(toKey, inclusive))
throw new IllegalArgumentException("toKey out of range");
- return new AscendingSubMap(m,
- fromStart, lo, loInclusive,
- false, toKey, inclusive);
+ return new AscendingSubMap<>(m,
+ fromStart, lo, loInclusive,
+ false, toKey, inclusive);
}
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
if (!inRange(fromKey, inclusive))
throw new IllegalArgumentException("fromKey out of range");
- return new AscendingSubMap(m,
- false, fromKey, inclusive,
- toEnd, hi, hiInclusive);
+ return new AscendingSubMap<>(m,
+ false, fromKey, inclusive,
+ toEnd, hi, hiInclusive);
}
public NavigableMap<K,V> descendingMap() {
NavigableMap<K,V> mv = descendingMapView;
return (mv != null) ? mv :
(descendingMapView =
- new DescendingSubMap(m,
- fromStart, lo, loInclusive,
- toEnd, hi, hiInclusive));
+ new DescendingSubMap<>(m,
+ fromStart, lo, loInclusive,
+ toEnd, hi, hiInclusive));
}
Iterator<K> keyIterator() {
@@ -1790,34 +1794,34 @@
throw new IllegalArgumentException("fromKey out of range");
if (!inRange(toKey, toInclusive))
throw new IllegalArgumentException("toKey out of range");
- return new DescendingSubMap(m,
- false, toKey, toInclusive,
- false, fromKey, fromInclusive);
+ return new DescendingSubMap<>(m,
+ false, toKey, toInclusive,
+ false, fromKey, fromInclusive);
}
public NavigableMap<K,V> headMap(K toKey, boolean inclusive) {
if (!inRange(toKey, inclusive))
throw new IllegalArgumentException("toKey out of range");
- return new DescendingSubMap(m,
- false, toKey, inclusive,
- toEnd, hi, hiInclusive);
+ return new DescendingSubMap<>(m,
+ false, toKey, inclusive,
+ toEnd, hi, hiInclusive);
}
public NavigableMap<K,V> tailMap(K fromKey, boolean inclusive) {
if (!inRange(fromKey, inclusive))
throw new IllegalArgumentException("fromKey out of range");
- return new DescendingSubMap(m,
- fromStart, lo, loInclusive,
- false, fromKey, inclusive);
+ return new DescendingSubMap<>(m,
+ fromStart, lo, loInclusive,
+ false, fromKey, inclusive);
}
public NavigableMap<K,V> descendingMap() {
NavigableMap<K,V> mv = descendingMapView;
return (mv != null) ? mv :
(descendingMapView =
- new AscendingSubMap(m,
- fromStart, lo, loInclusive,
- toEnd, hi, hiInclusive));
+ new AscendingSubMap<>(m,
+ fromStart, lo, loInclusive,
+ toEnd, hi, hiInclusive));
}
Iterator<K> keyIterator() {
@@ -1862,9 +1866,9 @@
private boolean fromStart = false, toEnd = false;
private K fromKey, toKey;
private Object readResolve() {
- return new AscendingSubMap(TreeMap.this,
- fromStart, fromKey, true,
- toEnd, toKey, false);
+ return new AscendingSubMap<>(TreeMap.this,
+ fromStart, fromKey, true,
+ toEnd, toKey, false);
}
public Set<Map.Entry<K,V>> entrySet() { throw new InternalError(); }
public K lastKey() { throw new InternalError(); }
@@ -2331,12 +2335,12 @@
* @param defaultVal if non-null, this default value is used for
* each value in the map. If null, each value is read from
* iterator or stream, as described above.
- * @throws IOException propagated from stream reads. This cannot
+ * @throws java.io.IOException propagated from stream reads. This cannot
* occur if str is null.
* @throws ClassNotFoundException propagated from readObject.
* This cannot occur if str is null.
*/
- private void buildFromSorted(int size, Iterator it,
+ private void buildFromSorted(int size, Iterator<?> it,
java.io.ObjectInputStream str,
V defaultVal)
throws java.io.IOException, ClassNotFoundException {
@@ -2359,9 +2363,10 @@
* @param redLevel the level at which nodes should be red.
* Must be equal to computeRedLevel for tree of this size.
*/
+ @SuppressWarnings("unchecked")
private final Entry<K,V> buildFromSorted(int level, int lo, int hi,
int redLevel,
- Iterator it,
+ Iterator<?> it,
java.io.ObjectInputStream str,
V defaultVal)
throws java.io.IOException, ClassNotFoundException {
@@ -2391,9 +2396,9 @@
V value;
if (it != null) {
if (defaultVal==null) {
- Map.Entry<K,V> entry = (Map.Entry<K,V>)it.next();
- key = entry.getKey();
- value = entry.getValue();
+ Map.Entry<?,?> entry = (Map.Entry<?,?>)it.next();
+ key = (K)entry.getKey();
+ value = (V)entry.getValue();
} else {
key = (K)it.next();
value = defaultVal;
--- a/jdk/src/share/classes/java/util/TreeSet.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/TreeSet.java Mon Apr 23 16:58:40 2012 -0700
@@ -302,7 +302,7 @@
m instanceof TreeMap) {
SortedSet<? extends E> set = (SortedSet<? extends E>) c;
TreeMap<E,Object> map = (TreeMap<E, Object>) m;
- Comparator<? super E> cc = (Comparator<? super E>) set.comparator();
+ Comparator<?> cc = set.comparator();
Comparator<? super E> mc = map.comparator();
if (cc==mc || (cc != null && cc.equals(mc))) {
map.addAllForTreeSet(set, PRESENT);
@@ -469,8 +469,9 @@
*
* @return a shallow copy of this set
*/
+ @SuppressWarnings("unchecked")
public Object clone() {
- TreeSet<E> clone = null;
+ TreeSet<E> clone;
try {
clone = (TreeSet<E>) super.clone();
} catch (CloneNotSupportedException e) {
@@ -519,14 +520,11 @@
s.defaultReadObject();
// Read in Comparator
- Comparator<? super E> c = (Comparator<? super E>) s.readObject();
+ @SuppressWarnings("unchecked")
+ Comparator<? super E> c = (Comparator<? super E>) s.readObject();
// Create backing TreeMap
- TreeMap<E,Object> tm;
- if (c==null)
- tm = new TreeMap<>();
- else
- tm = new TreeMap<>(c);
+ TreeMap<E,Object> tm = new TreeMap<>(c);
m = tm;
// Read in size
--- a/jdk/src/share/classes/java/util/WeakHashMap.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/WeakHashMap.java Mon Apr 23 16:58:40 2012 -0700
@@ -186,7 +186,7 @@
@SuppressWarnings("unchecked")
private Entry<K,V>[] newTable(int n) {
- return (Entry<K,V>[]) new Entry[n];
+ return (Entry<K,V>[]) new Entry<?,?>[n];
}
/**
--- a/jdk/src/share/classes/java/util/regex/Matcher.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/java/util/regex/Matcher.java Mon Apr 23 16:58:40 2012 -0700
@@ -759,16 +759,19 @@
char nextChar = replacement.charAt(cursor);
if (nextChar == '\\') {
cursor++;
+ if (cursor == replacement.length())
+ throw new IllegalArgumentException(
+ "character to be escaped is missing");
nextChar = replacement.charAt(cursor);
result.append(nextChar);
cursor++;
} else if (nextChar == '$') {
// Skip past $
cursor++;
- // A StringIndexOutOfBoundsException is thrown if
- // this "$" is the last character in replacement
- // string in current implementation, a IAE might be
- // more appropriate.
+ // Throw IAE if this "$" is the last character in replacement
+ if (cursor == replacement.length())
+ throw new IllegalArgumentException(
+ "Illegal group reference: group index is missing");
nextChar = replacement.charAt(cursor);
int refNum = -1;
if (nextChar == '{') {
--- a/jdk/src/share/classes/javax/swing/BorderFactory.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/BorderFactory.java Mon Apr 23 16:58:40 2012 -0700
@@ -371,7 +371,7 @@
/**
* Creates a new titled border with the specified title,
* the default border type (determined by the current look and feel),
- * the default text position (sitting on the top line),
+ * the default text position (determined by the current look and feel),
* the default justification (leading), and the default
* font and text color (determined by the current look and feel).
*
@@ -385,7 +385,7 @@
/**
* Creates a new titled border with an empty title,
* the specified border object,
- * the default text position (sitting on the top line),
+ * the default text position (determined by the current look and feel),
* the default justification (leading), and the default
* font and text color (determined by the current look and feel).
*
@@ -400,7 +400,7 @@
/**
* Adds a title to an existing border,
- * with default positioning (sitting on the top line),
+ * with default positioning (determined by the current look and feel),
* default justification (leading) and the default
* font and text color (determined by the current look and feel).
*
@@ -439,7 +439,8 @@
*<li><code>TitledBorder.ABOVE_BOTTOM</code>
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
*<li><code>TitledBorder.BELOW_BOTTOM</code>
- *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
+ *<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position
+ * is determined by the current look and feel)
*</ul>
* @return the <code>TitledBorder</code> object
*/
@@ -477,7 +478,8 @@
*<li><code>TitledBorder.ABOVE_BOTTOM</code>
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
*<li><code>TitledBorder.BELOW_BOTTOM</code>
- *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
+ *<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position
+ * is determined by the current look and feel)
*</ul>
* @param titleFont a Font object specifying the title font
* @return the TitledBorder object
@@ -516,7 +518,8 @@
*<li><code>TitledBorder.ABOVE_BOTTOM</code>
*<li><code>TitledBorder.BOTTOM</code> (sitting on the bottom line)
*<li><code>TitledBorder.BELOW_BOTTOM</code>
- *<li><code>TitledBorder.DEFAULT_POSITION</code> (top)
+ *<li><code>TitledBorder.DEFAULT_POSITION</code> (the title position
+ * is determined by the current look and feel)
*</ul>
* @param titleFont a <code>Font</code> object specifying the title font
* @param titleColor a <code>Color</code> object specifying the title color
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboPopup.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboPopup.java Mon Apr 23 16:58:40 2012 -0700
@@ -26,13 +26,9 @@
package javax.swing.plaf.synth;
import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.plaf.basic.*;
+import javax.swing.plaf.ComboBoxUI;
+import javax.swing.plaf.basic.BasicComboPopup;
import java.awt.*;
-import java.awt.event.*;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeEvent;
-import java.io.Serializable;
/**
@@ -52,6 +48,7 @@
*
* @see #createList
*/
+ @Override
protected void configureList() {
list.setFont( comboBox.getFont() );
list.setCellRenderer( comboBox.getRenderer() );
@@ -67,4 +64,27 @@
}
installListListeners();
}
+
+ /**
+ * @inheritDoc
+ *
+ * Overridden to take into account any popup insets specified in
+ * SynthComboBoxUI
+ */
+ @Override
+ protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
+ ComboBoxUI ui = comboBox.getUI();
+ if (ui instanceof SynthComboBoxUI) {
+ SynthComboBoxUI sui = (SynthComboBoxUI) ui;
+ if (sui.popupInsets != null) {
+ Insets i = sui.popupInsets;
+ return super.computePopupBounds(
+ px + i.left,
+ py + i.top,
+ pw - i.left - i.right,
+ ph - i.top - i.bottom);
+ }
+ }
+ return super.computePopupBounds(px, py, pw, ph);
+ }
}
--- a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java Mon Apr 23 16:58:40 2012 -0700
@@ -31,7 +31,6 @@
import javax.swing.UIManager;
import javax.swing.undo.*;
-import javax.swing.event.ChangeListener;
import javax.swing.event.*;
import javax.swing.tree.TreeNode;
@@ -698,28 +697,31 @@
return;
}
DocumentFilter filter = getDocumentFilter();
+ InsertStringResult insertStringResult = null;
writeLock();
+
try {
if (filter != null) {
filter.insertString(getFilterBypass(), offs, str, a);
- }
- else {
- handleInsertString(offs, str, a);
+ } else {
+ insertStringResult = handleInsertString(offs, str, a);
}
} finally {
writeUnlock();
}
+
+ processInsertStringResult(insertStringResult);
}
/**
* Performs the actual work of inserting the text; it is assumed the
* caller has obtained a write lock before invoking this.
*/
- void handleInsertString(int offs, String str, AttributeSet a)
- throws BadLocationException {
+ private InsertStringResult handleInsertString(int offs, String str, AttributeSet a)
+ throws BadLocationException {
if ((str == null) || (str.length() == 0)) {
- return;
+ return null;
}
UndoableEdit u = data.insertString(offs, str);
DefaultDocumentEvent e =
@@ -746,12 +748,29 @@
insertUpdate(e, a);
// Mark the edit as done.
e.end();
- fireInsertUpdate(e);
+
+ InsertStringResult result = new InsertStringResult();
+
+ result.documentEvent = e;
+
// only fire undo if Content implementation supports it
// undo for the composed text is not supported for now
- if (u != null &&
- (a == null || !a.isDefined(StyleConstants.ComposedTextAttribute))) {
- fireUndoableEditUpdate(new UndoableEditEvent(this, e));
+ if (u != null && (a == null || !a.isDefined(StyleConstants.ComposedTextAttribute))) {
+ result.undoableEditEvent = new UndoableEditEvent(this, e);
+ }
+
+ return result;
+ }
+
+ private void processInsertStringResult(InsertStringResult insertStringResult) {
+ if (insertStringResult == null) {
+ return;
+ }
+
+ fireInsertUpdate(insertStringResult.documentEvent);
+
+ if (insertStringResult.undoableEditEvent != null) {
+ fireUndoableEditUpdate(insertStringResult.undoableEditEvent);
}
}
@@ -2947,12 +2966,10 @@
*/
class UndoRedoDocumentEvent implements DocumentEvent {
private DefaultDocumentEvent src = null;
- private boolean isUndo;
private EventType type = null;
public UndoRedoDocumentEvent(DefaultDocumentEvent src, boolean isUndo) {
this.src = src;
- this.isUndo = isUndo;
if(isUndo) {
if(src.getType().equals(EventType.INSERT)) {
type = EventType.REMOVE;
@@ -3106,13 +3123,23 @@
public void insertString(int offset, String string,
AttributeSet attr) throws
BadLocationException {
- handleInsertString(offset, string, attr);
+ InsertStringResult insertStringResult = handleInsertString(offset, string, attr);
+
+ processInsertStringResult(insertStringResult);
}
public void replace(int offset, int length, String text,
AttributeSet attrs) throws BadLocationException {
handleRemove(offset, length);
- handleInsertString(offset, text, attrs);
+
+ InsertStringResult insertStringResult = handleInsertString(offset, text, attrs);
+
+ processInsertStringResult(insertStringResult);
}
}
+
+ private static class InsertStringResult {
+ DefaultDocumentEvent documentEvent;
+ UndoableEditEvent undoableEditEvent;
+ }
}
--- a/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/javax/swing/text/DefaultEditorKit.java Mon Apr 23 16:58:40 2012 -0700
@@ -24,6 +24,8 @@
*/
package javax.swing.text;
+import sun.awt.SunToolkit;
+
import java.io.*;
import java.awt.*;
import java.awt.event.ActionEvent;
@@ -869,11 +871,18 @@
}
String content = e.getActionCommand();
int mod = e.getModifiers();
- if ((content != null) && (content.length() > 0) &&
- ((mod & ActionEvent.ALT_MASK) == (mod & ActionEvent.CTRL_MASK))) {
- char c = content.charAt(0);
- if ((c >= 0x20) && (c != 0x7F)) {
- target.replaceSelection(content);
+ if ((content != null) && (content.length() > 0)) {
+ boolean isPrintableMask = true;
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ if (tk instanceof SunToolkit) {
+ isPrintableMask = ((SunToolkit)tk).isPrintableCharacterModifiersMask(mod);
+ }
+
+ if (isPrintableMask) {
+ char c = content.charAt(0);
+ if ((c >= 0x20) && (c != 0x7F)) {
+ target.replaceSelection(content);
+ }
}
}
}
--- a/jdk/src/share/classes/sun/awt/AppContext.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/AppContext.java Mon Apr 23 16:58:40 2012 -0700
@@ -46,6 +46,7 @@
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.atomic.AtomicInteger;
/**
* The AppContext is a table referenced by ThreadGroup which stores
@@ -194,6 +195,15 @@
return isDisposed;
}
+ /*
+ * The total number of AppContexts, system-wide. This number is
+ * incremented at the beginning of the constructor, and decremented
+ * at the end of dispose(). getAppContext() checks to see if this
+ * number is 1. If so, it returns the sole AppContext without
+ * checking Thread.currentThread().
+ */
+ private static final AtomicInteger numAppContexts = new AtomicInteger(0);
+
static {
// On the main Thread, we get the ThreadGroup, make a corresponding
// AppContext, and instantiate the Java EventQueue. This way, legacy
@@ -209,22 +219,12 @@
parentThreadGroup = currentThreadGroup.getParent();
}
mainAppContext = new AppContext(currentThreadGroup);
- numAppContexts = 1;
return null;
}
});
}
/*
- * The total number of AppContexts, system-wide. This number is
- * incremented at the beginning of the constructor, and decremented
- * at the end of dispose(). getAppContext() checks to see if this
- * number is 1. If so, it returns the sole AppContext without
- * checking Thread.currentThread().
- */
- private static volatile int numAppContexts;
-
- /*
* The context ClassLoader that was used to create this AppContext.
*/
private final ClassLoader contextClassLoader;
@@ -243,7 +243,7 @@
* @since 1.2
*/
AppContext(ThreadGroup threadGroup) {
- numAppContexts++;
+ numAppContexts.incrementAndGet();
this.threadGroup = threadGroup;
threadGroup2appContext.put(threadGroup, this);
@@ -278,7 +278,7 @@
* @since 1.2
*/
public final static AppContext getAppContext() {
- if (numAppContexts == 1) // If there's only one system-wide,
+ if (numAppContexts.get() == 1) // If there's only one system-wide,
return mainAppContext; // return the main system AppContext.
AppContext appContext = threadAppContext.get();
@@ -513,7 +513,7 @@
this.table.clear(); // Clear out the Hashtable to ease garbage collection
}
- numAppContexts--;
+ numAppContexts.decrementAndGet();
mostRecentKeyValue = null;
}
@@ -804,7 +804,7 @@
return getAppContext().isDisposed();
}
public boolean isMainAppContext() {
- return (numAppContexts == 1);
+ return (numAppContexts.get() == 1);
}
});
}
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Mon Apr 23 16:58:40 2012 -0700
@@ -1126,6 +1126,16 @@
}
/**
+ * Tests whether specified key modifiers mask can be used to enter a printable
+ * character. This is a default implementation of this method, which reflects
+ * the way things work on Windows: here, pressing ctrl + alt allows user to enter
+ * characters from the extended character set (like euro sign or math symbols)
+ */
+ public boolean isPrintableCharacterModifiersMask(int mods) {
+ return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK));
+ }
+
+ /**
* Returns a new input method window, with behavior as specified in
* {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}.
* If the inputContext is not null, the window should return it from its
--- a/jdk/src/share/classes/sun/awt/image/ImageWatched.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ImageWatched.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2003, 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
@@ -143,6 +143,7 @@
if (iw != null && !isWatcher(iw)) {
watcherList = new WeakLink(iw, watcherList);
}
+ watcherList = watcherList.removeWatcher(null);
}
public synchronized boolean isWatcher(ImageObserver iw) {
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -970,7 +970,8 @@
protected void implCloseSelectableChannel() throws IOException {
synchronized (stateLock) {
- nd.preClose(fd);
+ if (state != ST_KILLED)
+ nd.preClose(fd);
ResourceManager.afterUdpClose();
// if member of mulitcast group then invalidate all keys
--- a/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -261,7 +261,8 @@
protected void implCloseSelectableChannel() throws IOException {
synchronized (stateLock) {
- nd.preClose(fd);
+ if (state != ST_KILLED)
+ nd.preClose(fd);
long th = thread;
if (th != 0)
NativeThread.signal(th);
--- a/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -816,7 +816,8 @@
// channel from using the old fd, which might be recycled in the
// meantime and allocated to an entirely different channel.
//
- nd.preClose(fd);
+ if (state != ST_KILLED)
+ nd.preClose(fd);
// Signal native threads, if needed. If a target thread is not
// currently blocked in an I/O operation then no harm is done since
--- a/jdk/src/share/classes/sun/nio/cs/ext/SJIS_0213.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/nio/cs/ext/SJIS_0213.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,8 @@
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Arrays;
import sun.nio.cs.CharsetMapping;
@@ -73,8 +75,12 @@
return new Encoder(this);
}
- static CharsetMapping mapping =
- CharsetMapping.get(SJIS_0213.class.getResourceAsStream("sjis0213.dat"));
+ static CharsetMapping mapping = AccessController.doPrivileged(
+ new PrivilegedAction<CharsetMapping>() {
+ public CharsetMapping run() {
+ return CharsetMapping.get(SJIS_0213.class.getResourceAsStream("sjis0213.dat"));
+ }
+ });
protected static class Decoder extends CharsetDecoder {
protected static final char UNMAPPABLE = CharsetMapping.UNMAPPABLE_DECODING;
--- a/jdk/src/share/classes/sun/security/ec/ECParameters.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ec/ECParameters.java Mon Apr 23 16:58:40 2012 -0700
@@ -87,8 +87,8 @@
if ((data.length == 0) || (data[0] != 4)) {
throw new IOException("Only uncompressed point format supported");
}
- int n = (curve.getField().getFieldSize() + 7 ) >> 3;
- if (data.length != (n * 2) + 1) {
+ int n = data.length / 2;
+ if (n > ((curve.getField().getFieldSize() + 7 ) >> 3)) {
throw new IOException("Point does not match field size");
}
byte[] xb = new byte[n];
--- a/jdk/src/share/classes/sun/security/krb5/Credentials.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/security/krb5/Credentials.java Mon Apr 23 16:58:40 2012 -0700
@@ -330,12 +330,17 @@
CredentialsCache ccache =
CredentialsCache.getInstance(princ, ticketCache);
- if (ccache == null)
+ if (ccache == null) {
return null;
+ }
sun.security.krb5.internal.ccache.Credentials tgtCred =
ccache.getDefaultCreds();
+ if (tgtCred == null) {
+ return null;
+ }
+
if (EType.isSupported(tgtCred.getEType())) {
return tgtCred.setKrbCreds();
} else {
@@ -375,19 +380,21 @@
cache = CredentialsCache.getInstance();
}
if (cache != null) {
- if (DEBUG) {
- System.out.println(">>> KrbCreds found the default ticket " +
- "granting ticket in credential cache.");
- }
sun.security.krb5.internal.ccache.Credentials temp =
cache.getDefaultCreds();
- if (EType.isSupported(temp.getEType())) {
- result = temp.setKrbCreds();
- } else {
+ if (temp != null) {
if (DEBUG) {
- System.out.println(
- ">>> unsupported key type found the default TGT: " +
- temp.getEType());
+ System.out.println(">>> KrbCreds found the default ticket"
+ + " granting ticket in credential cache.");
+ }
+ if (EType.isSupported(temp.getEType())) {
+ result = temp.setKrbCreds();
+ } else {
+ if (DEBUG) {
+ System.out.println(
+ ">>> unsupported key type found the default TGT: " +
+ temp.getEType());
+ }
}
}
}
--- a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -91,9 +91,20 @@
// however they like; if we buffered here, they couldn't.
try {
do {
+ boolean holdRecord = false;
int howmuch;
if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
howmuch = Math.min(0x01, r.availableDataBytes());
+ /*
+ * Nagle's algorithm (TCP_NODELAY) was coming into
+ * play here when writing short (split) packets.
+ * Signal to the OutputRecord code to internally
+ * buffer this small packet until the next outbound
+ * packet (of any type) is written.
+ */
+ if ((len != 1) && (howmuch == 1)) {
+ holdRecord = true;
+ }
} else {
howmuch = Math.min(len, r.availableDataBytes());
}
@@ -108,7 +119,7 @@
off += howmuch;
len -= howmuch;
}
- c.writeRecord(r);
+ c.writeRecord(r, holdRecord);
c.checkWrite();
} while (len > 0);
} catch (Exception e) {
--- a/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -155,8 +155,9 @@
* data to be generated/output before the exception is ever
* generated.
*/
- void writeBuffer(OutputStream s, byte [] buf, int off, int len)
- throws IOException {
+ @Override
+ void writeBuffer(OutputStream s, byte [] buf, int off, int len,
+ int debugOffset) throws IOException {
/*
* Copy data out of buffer, it's ready to go.
*/
@@ -196,7 +197,8 @@
// compress(); // eventually
addMAC(writeMAC);
encrypt(writeCipher);
- write((OutputStream)null); // send down for processing
+ write((OutputStream)null, false, // send down for processing
+ (ByteArrayOutputStream)null);
}
return;
}
--- a/jdk/src/share/classes/sun/security/ssl/OutputRecord.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/OutputRecord.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2010, 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
@@ -28,6 +28,7 @@
import java.io.*;
import java.nio.*;
+import java.util.Arrays;
import javax.net.ssl.SSLException;
import sun.misc.HexDumpEncoder;
@@ -227,6 +228,24 @@
}
/*
+ * Increases the capacity if necessary to ensure that it can hold
+ * at least the number of elements specified by the minimum
+ * capacity argument.
+ *
+ * Note that the increased capacity is only can be used for held
+ * record buffer. Please DO NOT update the availableDataBytes()
+ * according to the expended buffer capacity.
+ *
+ * @see availableDataBytes()
+ */
+ private void ensureCapacity(int minCapacity) {
+ // overflow-conscious code
+ if (minCapacity > buf.length) {
+ buf = Arrays.copyOf(buf, minCapacity);
+ }
+ }
+
+ /*
* Return the type of SSL record that's buffered here.
*/
final byte contentType() {
@@ -243,7 +262,9 @@
* that synchronization be done elsewhere. Also, this does its work
* in a single low level write, for efficiency.
*/
- void write(OutputStream s) throws IOException {
+ void write(OutputStream s, boolean holdRecord,
+ ByteArrayOutputStream heldRecordBuffer) throws IOException {
+
/*
* Don't emit content-free records. (Even change cipher spec
* messages have a byte of data!)
@@ -300,7 +321,49 @@
}
firstMessage = false;
- writeBuffer(s, buf, 0, count);
+ /*
+ * The upper levels may want us to delay sending this packet so
+ * multiple TLS Records can be sent in one (or more) TCP packets.
+ * If so, add this packet to the heldRecordBuffer.
+ *
+ * NOTE: all writes have been synchronized by upper levels.
+ */
+ int debugOffset = 0;
+ if (holdRecord) {
+ /*
+ * If holdRecord is true, we must have a heldRecordBuffer.
+ *
+ * Don't worry about the override of writeBuffer(), because
+ * when holdRecord is true, the implementation in this class
+ * will be used.
+ */
+ writeBuffer(heldRecordBuffer, buf, 0, count, debugOffset);
+ } else {
+ // It's time to send, do we have buffered data?
+ // May or may not have a heldRecordBuffer.
+ if (heldRecordBuffer != null && heldRecordBuffer.size() > 0) {
+ int heldLen = heldRecordBuffer.size();
+
+ // Ensure the capacity of this buffer.
+ ensureCapacity(count + heldLen);
+
+ // Slide everything in the buffer to the right.
+ System.arraycopy(buf, 0, buf, heldLen, count);
+
+ // Prepend the held record to the buffer.
+ System.arraycopy(
+ heldRecordBuffer.toByteArray(), 0, buf, 0, heldLen);
+ count += heldLen;
+
+ // Clear the held buffer.
+ heldRecordBuffer.reset();
+
+ // The held buffer has been dumped, set the debug dump offset.
+ debugOffset = heldLen;
+ }
+ writeBuffer(s, buf, 0, count, debugOffset);
+ }
+
reset();
}
@@ -309,15 +372,17 @@
* we'll override this method and let it take the appropriate
* action.
*/
- void writeBuffer(OutputStream s, byte [] buf, int off, int len)
- throws IOException {
+ void writeBuffer(OutputStream s, byte [] buf, int off, int len,
+ int debugOffset) throws IOException {
s.write(buf, off, len);
s.flush();
+ // Output only the record from the specified debug offset.
if (debug != null && Debug.isOn("packet")) {
try {
HexDumpEncoder hd = new HexDumpEncoder();
- ByteBuffer bb = ByteBuffer.wrap(buf, off, len);
+ ByteBuffer bb = ByteBuffer.wrap(
+ buf, off + debugOffset, len - debugOffset);
System.out.println("[Raw write]: length = " +
bb.remaining());
--- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -374,6 +374,12 @@
*/
private boolean isFirstAppOutputRecord = true;
+ /*
+ * If AppOutputStream needs to delay writes of small packets, we
+ * will use this to store the data until we actually do the write.
+ */
+ private ByteArrayOutputStream heldRecordBuffer = null;
+
//
// CONSTRUCTORS AND INITIALIZATION CODE
//
@@ -654,13 +660,24 @@
//
/*
+ * AppOutputStream calls may need to buffer multiple outbound
+ * application packets.
+ *
+ * All other writeRecord() calls will not buffer, so do not hold
+ * these records.
+ */
+ void writeRecord(OutputRecord r) throws IOException {
+ writeRecord(r, false);
+ }
+
+ /*
* Record Output. Application data can't be sent until the first
* handshake establishes a session.
*
* NOTE: we let empty records be written as a hook to force some
* TCP-level activity, notably handshaking, to occur.
*/
- void writeRecord(OutputRecord r) throws IOException {
+ void writeRecord(OutputRecord r, boolean holdRecord) throws IOException {
/*
* The loop is in case of HANDSHAKE --> ERROR transitions, etc
*/
@@ -731,7 +748,7 @@
try {
if (writeLock.tryLock(getSoLinger(), TimeUnit.SECONDS)) {
try {
- writeRecordInternal(r);
+ writeRecordInternal(r, holdRecord);
} finally {
writeLock.unlock();
}
@@ -779,7 +796,7 @@
} else {
writeLock.lock();
try {
- writeRecordInternal(r);
+ writeRecordInternal(r, holdRecord);
} finally {
writeLock.unlock();
}
@@ -787,11 +804,29 @@
}
}
- private void writeRecordInternal(OutputRecord r) throws IOException {
+ private void writeRecordInternal(OutputRecord r,
+ boolean holdRecord) throws IOException {
+
// r.compress(c);
r.addMAC(writeMAC);
r.encrypt(writeCipher);
- r.write(sockOutput);
+
+ if (holdRecord) {
+ // If we were requested to delay the record due to possibility
+ // of Nagle's being active when finally got to writing, and
+ // it's actually not, we don't really need to delay it.
+ if (getTcpNoDelay()) {
+ holdRecord = false;
+ } else {
+ // We need to hold the record, so let's provide
+ // a per-socket place to do it.
+ if (heldRecordBuffer == null) {
+ // Likely only need 37 bytes.
+ heldRecordBuffer = new ByteArrayOutputStream(40);
+ }
+ }
+ }
+ r.write(sockOutput, holdRecord, heldRecordBuffer);
/*
* Check the sequence number state
--- a/jdk/src/share/classes/sun/tools/java/ClassPath.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/tools/java/ClassPath.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -141,7 +141,7 @@
} else {
StringBuilder sb = new StringBuilder(patharray[0]);
for (int i = 1; i < patharray.length; i++) {
- sb.append(File.separator);
+ sb.append(File.pathSeparatorChar);
sb.append(patharray[i]);
}
this.pathstr = sb.toString();
--- a/jdk/src/share/classes/sun/tools/jcmd/JCmd.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/classes/sun/tools/jcmd/JCmd.java Mon Apr 23 16:58:40 2012 -0700
@@ -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.
*com.sun.tools.attach.AttachNotSupportedException
@@ -142,17 +142,20 @@
// Cast to HotSpotVirtualMachine as this is an
// implementation specific method.
HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
- try (InputStream in = hvm.executeJCmd(command);) {
- // read to EOF and just print output
- byte b[] = new byte[256];
- int n;
- do {
- n = in.read(b);
- if (n > 0) {
- String s = new String(b, 0, n, "UTF-8");
- System.out.print(s);
- }
- } while (n > 0);
+ String lines[] = command .split("\\n");
+ for (String line : lines) {
+ try (InputStream in = hvm.executeJCmd(line);) {
+ // read to EOF and just print output
+ byte b[] = new byte[256];
+ int n;
+ do {
+ n = in.read(b);
+ if (n > 0) {
+ String s = new String(b, 0, n, "UTF-8");
+ System.out.print(s);
+ }
+ } while (n > 0);
+ }
}
vm.detach();
}
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java Mon Apr 23 16:58:40 2012 -0700
@@ -78,7 +78,7 @@
}
try {
// only support legacy JAR URL syntax jar:{uri}!/{entry} for now
- String spec = uri.getSchemeSpecificPart();
+ String spec = uri.getRawSchemeSpecificPart();
int sep = spec.indexOf("!/");
if (sep != -1)
spec = spec.substring(0, sep);
--- a/jdk/src/share/lib/security/java.security Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/lib/security/java.security Mon Apr 23 16:58:40 2012 -0700
@@ -123,7 +123,7 @@
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/lib/security/java.security-macosx Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/lib/security/java.security-macosx Mon Apr 23 16:58:40 2012 -0700
@@ -124,7 +124,7 @@
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,apple.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/lib/security/java.security-solaris Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/lib/security/java.security-solaris Mon Apr 23 16:58:40 2012 -0700
@@ -125,7 +125,7 @@
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/lib/security/java.security-windows Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/lib/security/java.security-windows Mon Apr 23 16:58:40 2012 -0700
@@ -124,7 +124,7 @@
# passed to checkPackageAccess unless the
# corresponding RuntimePermission ("accessClassInPackage."+package) has
# been granted.
-package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
+package.access=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.,com.sun.org.apache.xerces.internal.utils.,com.sun.org.apache.xalan.internal.utils.
#
# List of comma-separated packages that start with or equal this string
--- a/jdk/src/share/native/sun/font/sunFont.c Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/share/native/sun/font/sunFont.c Mon Apr 23 16:58:40 2012 -0700
@@ -29,7 +29,7 @@
#include "jlong.h"
#include "sunfontids.h"
#include "fontscalerdefs.h"
-#include "sun_font_FontManager.h"
+#include "sun_font_SunFontManager.h"
#include "sun_font_NullFontScaler.h"
#include "sun_font_StrikeCache.h"
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Mon Apr 23 16:58:40 2012 -0700
@@ -82,7 +82,7 @@
boolean paintPending = false;
boolean isLayouting = false;
- boolean enabled;
+ private boolean enabled;
// Actually used only by XDecoratedPeer
protected int boundsOperation;
@@ -128,9 +128,6 @@
}
void postInit(XCreateWindowParams params) {
super.postInit(params);
- Color c;
- Font f;
- Cursor cursor;
pSetCursor(target.getCursor());
@@ -143,19 +140,7 @@
reshape(r.x, r.y, r.width, r.height);
}
- enabled = target.isEnabled();
-
- // If any of our heavyweight ancestors are disable, we should be too
- // See 6176875 for more information
- Component comp = target;
- while( !(comp == null || comp instanceof Window) ) {
- comp = comp.getParent();
- if( comp != null && !comp.isEnabled() && !comp.isLightweight() ){
- setEnabled(false);
- break;
- }
- }
- enableLog.fine("Initial enable state: {0}", Boolean.valueOf(enabled));
+ setEnabled(target.isEnabled());
if (target.isVisible()) {
setVisible(true);
@@ -384,45 +369,48 @@
setVisible(false);
}
-
/**
* @see java.awt.peer.ComponentPeer
*/
- public void setEnabled(boolean value) {
- enableLog.fine("{0}ing {1}", (value?"Enabl":"Disabl"), this);
- boolean repaintNeeded = (enabled != value);
- enabled = value;
+ public void setEnabled(final boolean value) {
+ if (enableLog.isLoggable(PlatformLogger.FINE)) {
+ enableLog.fine("{0}ing {1}", (value ? "Enabl" : "Disabl"), this);
+ }
+ boolean status = value;
+ // If any of our heavyweight ancestors are disable, we should be too
+ // See 6176875 for more information
+ final Container cp = SunToolkit.getNativeContainer(target);
+ if (cp != null) {
+ status &= ((XComponentPeer) cp.getPeer()).isEnabled();
+ }
+ synchronized (getStateLock()) {
+ if (enabled == status) {
+ return;
+ }
+ enabled = status;
+ }
+
if (target instanceof Container) {
- Component list[] = ((Container)target).getComponents();
- for (int i = 0; i < list.length; ++i) {
- boolean childEnabled = list[i].isEnabled();
- ComponentPeer p = list[i].getPeer();
- if ( p != null ) {
- p.setEnabled(value && childEnabled);
+ final Component[] list = ((Container) target).getComponents();
+ for (final Component child : list) {
+ final ComponentPeer p = child.getPeer();
+ if (p != null) {
+ p.setEnabled(status && child.isEnabled());
}
}
}
- if (repaintNeeded) {
- repaint();
- }
+ repaint();
}
//
// public so aw/Window can call it
//
- public boolean isEnabled() {
- return enabled;
+ public final boolean isEnabled() {
+ synchronized (getStateLock()) {
+ return enabled;
+ }
}
-
-
- public void enable() {
- setEnabled(true);
- }
-
- public void disable() {
- setEnabled(false);
- }
@Override
public void paint(final Graphics g) {
super.paint(g);
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java Mon Apr 23 16:58:40 2012 -0700
@@ -69,20 +69,26 @@
}
public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {
- try {
- SunToolkit.awtLock();
-
- validateSurface(sg2d);
- int transx = sg2d.transX;
- int transy = sg2d.transY;
+ Region compClip = sg2d.getCompClip();
+ int transX1 = x1 + sg2d.transX;
+ int transY1 = y1 + sg2d.transY;
+ int transX2 = x2 + sg2d.transX;
+ int transY2 = y2 + sg2d.transY;
- XRSurfaceData xrsd = (XRSurfaceData) sg2d.surfaceData;
+ // Non clipped fast path
+ if (compClip.contains(transX1, transY1)
+ && compClip.contains(transX2, transY2)) {
+ try {
+ SunToolkit.awtLock();
- tileManager.addLine(x1 + transx, y1 + transy,
- x2 + transx, y2 + transy);
- tileManager.fillMask(xrsd);
- } finally {
- SunToolkit.awtUnlock();
+ validateSurface(sg2d);
+ tileManager.addLine(transX1, transY1, transX2, transY2);
+ tileManager.fillMask((XRSurfaceData) sg2d.surfaceData);
+ } finally {
+ SunToolkit.awtUnlock();
+ }
+ } else {
+ draw(sg2d, new Line2D.Float(x1, y1, x2, y2));
}
}
--- a/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2009, 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
@@ -84,7 +84,8 @@
protected void implCloseSelectableChannel() throws IOException {
synchronized (stateLock) {
- nd.preClose(fd);
+ if (state != ST_KILLED)
+ nd.preClose(fd);
long th = thread;
if (th != 0)
NativeThread.signal(th);
--- a/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2009, 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
@@ -84,7 +84,8 @@
protected void implCloseSelectableChannel() throws IOException {
synchronized (stateLock) {
- nd.preClose(fd);
+ if (state != ST_KILLED)
+ nd.preClose(fd);
long th = thread;
if (th != 0)
NativeThread.signal(th);
--- a/jdk/src/solaris/native/com/sun/management/MacosxOperatingSystem.c Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/native/com/sun/management/MacosxOperatingSystem.c Mon Apr 23 16:58:40 2012 -0700
@@ -25,16 +25,136 @@
#include "com_sun_management_UnixOperatingSystem.h"
+#include <sys/time.h>
+#include <mach/mach.h>
+#include <mach/task_info.h>
+
+
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
(JNIEnv *env, jobject dummy)
{
- return -1.0; // not available
+ // This code is influenced by the darwin top source
+
+ kern_return_t kr;
+ mach_msg_type_number_t count;
+ host_cpu_load_info_data_t load;
+
+ static jlong last_used = 0;
+ static jlong last_total = 0;
+
+ count = HOST_CPU_LOAD_INFO_COUNT;
+ kr = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&load, &count);
+ if (kr != KERN_SUCCESS) {
+ return -1;
+ }
+
+ jlong used = load.cpu_ticks[CPU_STATE_USER] + load.cpu_ticks[CPU_STATE_NICE] + load.cpu_ticks[CPU_STATE_SYSTEM];
+ jlong total = used + load.cpu_ticks[CPU_STATE_IDLE];
+
+ if (last_used == 0 || last_total == 0) {
+ // First call, just set the last values
+ last_used = used;
+ last_total = total;
+ // return 0 since we have no data, not -1 which indicates error
+ return 0;
+ }
+
+ jlong used_delta = used - last_used;
+ jlong total_delta = total - last_total;
+
+ jdouble cpu = (jdouble) used_delta / total_delta;
+
+ last_used = used;
+ last_total = total;
+
+ return cpu;
}
+
+#define TIME_VALUE_TO_TIMEVAL(a, r) do { \
+ (r)->tv_sec = (a)->seconds; \
+ (r)->tv_usec = (a)->microseconds; \
+} while (0)
+
+
+#define TIME_VALUE_TO_MICROSECONDS(TV) \
+ ((TV).tv_sec * 1000 * 1000 + (TV).tv_usec)
+
+
JNIEXPORT jdouble JNICALL
Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
(JNIEnv *env, jobject dummy)
{
- return -1.0; // not available
-}
+ // This code is influenced by the darwin top source
+
+ struct task_basic_info_64 task_info_data;
+ struct task_thread_times_info thread_info_data;
+ struct timeval user_timeval, system_timeval, task_timeval;
+ struct timeval now;
+ mach_port_t task = mach_task_self();
+ kern_return_t kr;
+
+ static jlong last_task_time = 0;
+ static jlong last_time = 0;
+
+ mach_msg_type_number_t thread_info_count = TASK_THREAD_TIMES_INFO_COUNT;
+ kr = task_info(task,
+ TASK_THREAD_TIMES_INFO,
+ (task_info_t)&thread_info_data,
+ &thread_info_count);
+ if (kr != KERN_SUCCESS) {
+ // Most likely cause: |task| is a zombie.
+ return -1;
+ }
+
+ mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
+ kr = task_info(task,
+ TASK_BASIC_INFO_64,
+ (task_info_t)&task_info_data,
+ &count);
+ if (kr != KERN_SUCCESS) {
+ // Most likely cause: |task| is a zombie.
+ return -1;
+ }
+
+ /* Set total_time. */
+ // thread info contains live time...
+ TIME_VALUE_TO_TIMEVAL(&thread_info_data.user_time, &user_timeval);
+ TIME_VALUE_TO_TIMEVAL(&thread_info_data.system_time, &system_timeval);
+ timeradd(&user_timeval, &system_timeval, &task_timeval);
+
+ // ... task info contains terminated time.
+ TIME_VALUE_TO_TIMEVAL(&task_info_data.user_time, &user_timeval);
+ TIME_VALUE_TO_TIMEVAL(&task_info_data.system_time, &system_timeval);
+ timeradd(&user_timeval, &task_timeval, &task_timeval);
+ timeradd(&system_timeval, &task_timeval, &task_timeval);
+
+ if (gettimeofday(&now, NULL) < 0) {
+ return -1;
+ }
+ jint ncpus = JVM_ActiveProcessorCount();
+ jlong time = TIME_VALUE_TO_MICROSECONDS(now) * ncpus;
+ jlong task_time = TIME_VALUE_TO_MICROSECONDS(task_timeval);
+
+ if ((last_task_time == 0) || (last_time == 0)) {
+ // First call, just set the last values.
+ last_task_time = task_time;
+ last_time = time;
+ // return 0 since we have no data, not -1 which indicates error
+ return 0;
+ }
+
+ jlong task_time_delta = task_time - last_task_time;
+ jlong time_delta = time - last_time;
+ if (time_delta == 0) {
+ return -1;
+ }
+
+ jdouble cpu = (jdouble) task_time_delta / time_delta;
+
+ last_task_time = task_time;
+ last_time = time;
+
+ return cpu;
+ }
--- a/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c Mon Apr 23 16:58:40 2012 -0700
@@ -34,6 +34,13 @@
#include <sys/stat.h>
#if defined(_ALLBSD_SOURCE)
#include <sys/sysctl.h>
+#ifdef __APPLE__
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <mach/mach.h>
+#include <sys/proc_info.h>
+#include <libproc.h>
+#endif
#else
#include <sys/swap.h>
#endif
@@ -150,6 +157,13 @@
avail = (jlong)si.freeswap * si.mem_unit;
return available ? avail : total;
+#elif defined(__APPLE__)
+ struct xsw_usage vmusage;
+ size_t size = sizeof(vmusage);
+ if (sysctlbyname("vm.swapusage", &vmusage, &size, NULL, 0) != 0) {
+ throw_internal_error(env, "sysctlbyname failed");
+ }
+ return available ? (jlong)vmusage.xsu_avail : (jlong)vmusage.xsu_total;
#else /* _ALLBSD_SOURCE */
/*
* XXXBSD: there's no way available to get swap info in
@@ -216,6 +230,15 @@
fclose(fp);
return (jlong)vsize;
+#elif defined(__APPLE__)
+ struct task_basic_info t_info;
+ mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
+
+ kern_return_t res = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
+ if (res != KERN_SUCCESS) {
+ throw_internal_error(env, "task_info failed");
+ }
+ return t_info.virtual_size;
#else /* _ALLBSD_SOURCE */
/*
* XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
@@ -243,6 +266,17 @@
Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
(JNIEnv *env, jobject mbean)
{
+#ifdef __APPLE__
+ struct rusage usage;
+ if (getrusage(RUSAGE_SELF, &usage) != 0) {
+ throw_internal_error(env, "getrusage failed");
+ return -1;
+ }
+ jlong microsecs =
+ usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec +
+ usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec;
+ return microsecs * 1000;
+#else
jlong clk_tck, ns_per_clock_tick;
jlong cpu_time_ns;
struct tms time;
@@ -267,19 +301,32 @@
cpu_time_ns = ((jlong)time.tms_utime + (jlong) time.tms_stime) *
ns_per_clock_tick;
return cpu_time_ns;
+#endif
}
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
(JNIEnv *env, jobject mbean)
{
-#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ mach_msg_type_number_t count;
+ vm_statistics_data_t vm_stats;
+ kern_return_t res;
+
+ count = HOST_VM_INFO_COUNT;
+ res = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vm_stats, &count);
+ if (res != KERN_SUCCESS) {
+ throw_internal_error(env, "host_statistics failed");
+ return -1;
+ }
+ return (jlong)vm_stats.free_count * page_size;
+#elif defined(_ALLBSD_SOURCE)
/*
* XXBSDL no way to do it in FreeBSD
*/
// throw_internal_error(env, "unimplemented in FreeBSD")
return (128 * MB);
-#else
+#else // solaris / linux
jlong num_avail_physical_pages = sysconf(_SC_AVPHYS_PAGES);
return (num_avail_physical_pages * page_size);
#endif
@@ -290,28 +337,75 @@
(JNIEnv *env, jobject mbean)
{
#ifdef _ALLBSD_SOURCE
- jlong result;
+ jlong result = 0;
int mib[2];
size_t rlen;
mib[0] = CTL_HW;
- mib[1] = HW_PHYSMEM;
+ mib[1] = HW_MEMSIZE;
rlen = sizeof(result);
- if (sysctl(mib, 2, &result, &rlen, NULL, 0) == -1)
- result = 256 * MB;
-
- return (result);
-#else
+ if (sysctl(mib, 2, &result, &rlen, NULL, 0) != 0) {
+ throw_internal_error(env, "sysctl failed");
+ return -1;
+ }
+ return result;
+#else // solaris / linux
jlong num_physical_pages = sysconf(_SC_PHYS_PAGES);
return (num_physical_pages * page_size);
#endif
}
+
+
JNIEXPORT jlong JNICALL
Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
(JNIEnv *env, jobject mbean)
{
-#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+ // This code is influenced by the darwin lsof source
+ pid_t my_pid;
+ struct proc_bsdinfo bsdinfo;
+ struct proc_fdinfo *fds;
+ int nfiles;
+ kern_return_t kres;
+ int res;
+ size_t fds_size;
+
+ kres = pid_for_task(mach_task_self(), &my_pid);
+ if (res != KERN_SUCCESS) {
+ throw_internal_error(env, "pid_for_task failed");
+ return -1;
+ }
+
+ // get the maximum number of file descriptors
+ res = proc_pidinfo(my_pid, PROC_PIDTBSDINFO, 0, &bsdinfo, PROC_PIDTBSDINFO_SIZE);
+ if (res <= 0) {
+ throw_internal_error(env, "proc_pidinfo with PROC_PIDTBSDINFO failed");
+ return -1;
+ }
+
+ // allocate memory to hold the fd information (we don't acutally use this information
+ // but need it to get the number of open files)
+ fds_size = bsdinfo.pbi_nfiles * sizeof(struct proc_fdinfo);
+ fds = malloc(fds_size);
+ if (fds == NULL) {
+ JNU_ThrowOutOfMemoryError(env, "could not allocate space for file descriptors");
+ return -1;
+ }
+
+ // get the list of open files - the return value is the number of bytes
+ // proc_pidinfo filled in
+ res = proc_pidinfo(my_pid, PROC_PIDLISTFDS, 0, fds, fds_size);
+ if (res <= 0) {
+ free(fds);
+ throw_internal_error(env, "proc_pidinfo failed for PROC_PIDLISTFDS");
+ return -1;
+ }
+ nfiles = res / sizeof(struct proc_fdinfo);
+ free(fds);
+
+ return nfiles;
+#elif defined(_ALLBSD_SOURCE)
/*
* XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
*/
--- a/jdk/src/solaris/native/sun/awt/fontpath.c Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/native/sun/awt/fontpath.c Mon Apr 23 16:58:40 2012 -0700
@@ -583,9 +583,6 @@
}
#include <dlfcn.h>
-#if !(defined(__linux__) || defined(MACOSX))
-#include <link.h>
-#endif
#include "fontconfig.h"
--- a/jdk/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h Mon Apr 23 16:58:40 2012 -0700
@@ -28,7 +28,7 @@
#include <stdlib.h>
#ifndef MACOSX
-#include <link.h>
+#include <dlfcn.h>
#endif
#include "jvm_md.h"
#include "J2D_GL/glx.h"
--- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c Mon Apr 23 16:58:40 2012 -0700
@@ -70,7 +70,6 @@
#ifdef __solaris__
/* Solaris 10 will not have these symbols at runtime */
-#include <link.h>
typedef Picture (*XRenderCreateLinearGradientFuncType)
(Display *dpy,
--- a/jdk/test/ProblemList.txt Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/ProblemList.txt Mon Apr 23 16:58:40 2012 -0700
@@ -161,6 +161,26 @@
# Need to be marked othervm, or changed to be samevm safe
com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java generic-all
+# 7162111
+demo/jvmti/mtrace/TraceJFrame.java macosx-all
+javax/script/CauseExceptionTest.java macosx-all
+javax/script/GetInterfaceTest.java macosx-all
+javax/script/JavaScriptScopeTest.java macosx-all
+javax/script/NullUndefinedVarTest.java macosx-all
+javax/script/PluggableContextTest.java macosx-all
+javax/script/ProviderTest.sh macosx-all
+javax/script/RhinoExceptionTest.java macosx-all
+javax/script/StringWriterPrintTest.java macosx-all
+javax/script/Test1.java macosx-all
+javax/script/Test2.java macosx-all
+javax/script/Test3.java macosx-all
+javax/script/Test4.java macosx-all
+javax/script/Test5.java macosx-all
+javax/script/Test6.java macosx-all
+javax/script/Test7.java macosx-all
+javax/script/Test8.java macosx-all
+javax/script/UnescapedBracketRegExTest.java macosx-all
+javax/script/VersionTest.java macosx-all
############################################################################
# jdk_net
@@ -202,6 +222,8 @@
sun/net/www/protocol/http/B6299712.java macosx-all
java/net/CookieHandler/CookieManagerTest.java macosx-all
+# JPRT needs to set 127.0.0.1 in proxy bypass list
+java/net/URLClassLoader/closetest/CloseTest.java macosx-all
############################################################################
# jdk_io
@@ -252,6 +274,9 @@
# 7132247
java/rmi/registry/readTest/readTest.sh windows-all
+# 7142596
+java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java generic-all
+
############################################################################
# jdk_security
--- a/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh Mon Apr 23 16:58:40 2012 -0700
@@ -83,6 +83,13 @@
total_swap=`free -b | grep -i swap | awk '{print $2}'`
runOne GetTotalSwapSpaceSize $total_swap
;;
+ Darwin )
+ # $ sysctl -n vm.swapusage
+ # total = 8192.00M used = 7471.11M free = 720.89M (encrypted)
+ swap=`/usr/sbin/sysctl -n vm.swapusage | awk '{ print $3 }' | awk -F . '{ print $1 }'` || exit 2
+ total_swap=`expr $swap \* 1024 \* 1024` || exit 2
+ runOne GetTotalSwapSpaceSize $total_swap
+ ;;
* )
runOne GetTotalSwapSpaceSize "sanity-only"
;;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/demo/zipfs/ZFSTests.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,56 @@
+/*
+ * 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 7156873
+ @summary ZipFileSystem regression tests
+ */
+
+
+import java.net.URI;
+import java.nio.file.*;
+import java.util.Map;
+import java.util.HashMap;
+
+public class ZFSTests {
+
+ public static void main(String[] args) throws Throwable {
+ test7156873();
+ }
+
+ static void test7156873() throws Throwable {
+ String DIRWITHSPACE = "testdir with spaces";
+ Path dir = Paths.get(DIRWITHSPACE);
+ Path path = Paths.get(DIRWITHSPACE, "file.zip");
+ try {
+ Files.createDirectory(dir);
+ URI uri = URI.create("jar:" + path.toUri());
+ Map<String, Object> env = new HashMap<String, Object>();
+ env.put("create", "true");
+ try (FileSystem fs = FileSystems.newFileSystem(uri, env)) {}
+ } finally {
+ Files.deleteIfExists(path);
+ Files.deleteIfExists(dir);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/7097771/bug7097771.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,81 @@
+/*
+ * 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 sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.Util;
+
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Frame;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/*
+ @test
+ @bug 7097771
+ @summary setEnabled does not work for components in disabled containers.
+ @author sergey.bylokhov@oracle.com: area=awt.component
+ @library ../../regtesthelpers
+ @build Util
+ @run main bug7097771
+*/
+public final class bug7097771 extends Frame implements ActionListener {
+
+ private static volatile boolean action;
+
+ public static void main(final String[] args) throws AWTException {
+ final bug7097771 frame = new bug7097771();
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+ final Button button = new Button();
+ button.addActionListener(frame);
+ frame.add(button);
+ frame.setVisible(true);
+ sleep();
+ frame.setEnabled(false);
+ button.setEnabled(false);
+ button.setEnabled(true);
+ sleep();
+ Util.clickOnComp(button, new Robot());
+ sleep();
+ frame.dispose();
+ if (action) {
+ throw new RuntimeException("Button is not disabled.");
+ }
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ action = true;
+ }
+
+ private static void sleep() {
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ignored) {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/TestWrapped.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,76 @@
+/*
+ * 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 6282388
+ * @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit
+ * @author artem.ananiev@sun.com: area=awt.headless
+ * @run shell WrappedToolkitTest.sh
+ */
+
+import java.awt.*;
+
+import java.lang.reflect.*;
+
+import sun.awt.*;
+
+public class TestWrapped
+{
+ public static void main(String[] args)
+ {
+ try
+ {
+ if (args.length != 1) {
+ System.err.println("No correct toolkit class name is specified, test is not run");
+ System.exit(0);
+ }
+
+ String correctToolkitClassName = args[0];
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ Class tkClass = tk.getClass();
+ if (!tkClass.getName().equals("sun.awt.HeadlessToolkit"))
+ {
+ System.err.println(tkClass.getName());
+ System.err.println("Error: default toolkit is not an instance of HeadlessToolkit");
+ System.exit(-1);
+ }
+
+ Field f = tkClass.getDeclaredField("tk");
+ f.setAccessible(true);
+ Class wrappedClass = f.get(tk).getClass();
+ if (!wrappedClass.getName().equals(correctToolkitClassName)) {
+ System.err.println(wrappedClass.getName());
+ System.err.println("Error: wrapped toolkit is not an instance of " + correctToolkitClassName);
+ System.exit(-1);
+ }
+ }
+ catch (Exception z)
+ {
+ z.printStackTrace(System.err);
+ System.exit(-1);
+ }
+
+ System.exit(0);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Toolkit/Headless/WrappedToolkitTest/WrappedToolkitTest.sh Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,179 @@
+#!/bin/ksh -p
+
+#
+# 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 6282388
+# @summary Tests that AWT use correct toolkit to be wrapped into HeadlessToolkit
+# @author artem.ananiev@sun.com: area=awt.headless
+# @compile TestWrapped.java
+# @run shell WrappedToolkitTest.sh
+
+# Beginning of subroutines:
+status=1
+
+#Call this from anywhere to fail the test with an error message
+# usage: fail "reason why the test failed"
+fail()
+ { echo "The test failed :-("
+ echo "$*" 1>&2
+ echo "exit status was $status"
+ exit $status
+ } #end of fail()
+
+#Call this from anywhere to pass the test with a message
+# usage: pass "reason why the test passed if applicable"
+pass()
+ { echo "The test passed!!!"
+ echo "$*" 1>&2
+ exit 0
+ } #end of pass()
+
+# end of subroutines
+
+
+# The beginning of the script proper
+
+# Checking for proper OS
+OS=`uname -s`
+case "$OS" in
+ SunOS )
+ VAR="One value for Sun"
+ DEFAULT_JDK=/usr/local/java/jdk1.2/solaris
+ FILESEP="/"
+ ;;
+
+ Linux )
+ VAR="A different value for Linux"
+ DEFAULT_JDK=/usr/local/java/jdk1.4/linux-i386
+ FILESEP="/"
+ ;;
+
+ Windows* | CYGWIN* )
+ VAR="A different value for Win32"
+ DEFAULT_JDK=/usr/local/java/jdk1.2/win32
+ FILESEP="\\"
+ ;;
+
+ # catch all other OSs
+ * )
+ echo "Unrecognized system! $OS"
+ fail "Unrecognized system! $OS"
+ ;;
+esac
+
+# check that some executable or other file you need is available, abort if not
+# note that the name of the executable is in the fail string as well.
+# this is how to check for presence of the compiler, etc.
+#RESOURCE=`whence SomeProgramOrFileNeeded`
+#if [ "${RESOURCE}" = "" ] ;
+# then fail "Need SomeProgramOrFileNeeded to perform the test" ;
+#fi
+
+# Want this test to run standalone as well as in the harness, so do the
+# following to copy the test's directory into the harness's scratch directory
+# and set all appropriate variables:
+
+if [ -z "${TESTJAVA}" ] ; then
+ # TESTJAVA is not set, so the test is running stand-alone.
+ # TESTJAVA holds the path to the root directory of the build of the JDK
+ # to be tested. That is, any java files run explicitly in this shell
+ # should use TESTJAVA in the path to the java interpreter.
+ # So, we'll set this to the JDK spec'd on the command line. If none
+ # is given on the command line, tell the user that and use a cheesy
+ # default.
+ # THIS IS THE JDK BEING TESTED.
+ if [ -n "$1" ] ;
+ then TESTJAVA=$1
+ else echo "no JDK specified on command line so using default!"
+ TESTJAVA=$DEFAULT_JDK
+ fi
+ TESTSRC=.
+ TESTCLASSES=.
+ STANDALONE=1;
+fi
+echo "JDK under test is: $TESTJAVA"
+
+#Deal with .class files:
+if [ -n "${STANDALONE}" ] ; then
+ # then compile all .java files (if there are any) into .class files
+ if [ -a *.java ]; then
+ ${TESTJAVA}/bin/javac$ ./*.java ;
+ fi
+ # else in harness so copy all the class files from where jtreg put them
+ # over to the scratch directory this test is running in.
+ else cp ${TESTCLASSES}/*.class . ;
+fi
+
+#if in test harness, then copy the entire directory that the test is in over
+# to the scratch directory. This catches any support files needed by the test.
+if [ -z "${STANDALONE}" ] ;
+ then cp ${TESTSRC}/* .
+fi
+
+#Just before executing anything, make sure it has executable permission!
+chmod 777 ./*
+
+############### YOUR TEST CODE HERE!!!!!!! #############
+
+case "$OS" in
+ Windows* | CYGWIN* )
+ ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+ TestWrapped sun.awt.windows.WToolkit
+ status=$?
+ if [ ! $status -eq "0" ]; then
+ fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit";
+ fi
+ ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+ -Dawt.toolkit=sun.awt.windows.WToolkit \
+ TestWrapped sun.awt.windows.WToolkit
+ status=$?
+ if [ ! $status -eq "0" ]; then
+ fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.windows.WToolkit";
+ fi
+ ;;
+
+ SunOS | Linux )
+ ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+ -Dawt.toolkit=sun.awt.X11.XToolkit \
+ TestWrapped sun.awt.X11.XToolkit
+ status=$?
+ if [ ! $status -eq "0" ]; then
+ fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit";
+ fi
+ AWT_TOOLKIT=XToolkit ${TESTJAVA}/bin/java -Djava.awt.headless=true \
+ TestWrapped sun.awt.X11.XToolkit
+ status=$?
+ if [ ! $status -eq "0" ]; then
+ fail "Test FAILED: toolkit wrapped into HeadlessToolkit is not an instance of sun.awt.xawt.XToolkit";
+ fi
+ ;;
+
+esac
+
+pass "All the tests are PASSED";
+
+#For additional examples of how to write platform independent KSH scripts,
+# see the jtreg file itself. It is a KSH script for both Solaris and Win32
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,47 @@
+/*
+ * 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 7146431
+ * @summary Test that internal JAXP packages cannot be accessed
+ */
+
+public class CheckPackageAccess {
+
+ public static void main(String[] args) throws Exception {
+
+ String[] pkgs = new String[] {
+ "com.sun.org.apache.xerces.internal.utils.",
+ "com.sun.org.apache.xalan.internal.utils." };
+ SecurityManager sm = new SecurityManager();
+ System.setSecurityManager(sm);
+ for (String pkg : pkgs) {
+ System.out.println("Checking package access for " + pkg);
+ try {
+ sm.checkPackageAccess(pkg);
+ throw new Exception("Expected SecurityException not thrown");
+ } catch (SecurityException se) { }
+ }
+ }
+}
--- a/jdk/test/java/nio/channels/Selector/OpRead.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/java/nio/channels/Selector/OpRead.java Mon Apr 23 16:58:40 2012 -0700
@@ -58,7 +58,10 @@
boolean done = false;
int failCount = 0;
while (!done) {
- if (selector.select() > 0) {
+ int nSelected = selector.select();
+ if (nSelected > 0) {
+ if (nSelected > 1)
+ throw new RuntimeException("More than one channel selected");
Set<SelectionKey> keys = selector.selectedKeys();
Iterator<SelectionKey> iterator = keys.iterator();
while (iterator.hasNext()) {
--- a/jdk/test/java/nio/charset/coders/StreamTimeout.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/java/nio/charset/coders/StreamTimeout.java Mon Apr 23 16:58:40 2012 -0700
@@ -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
@@ -27,51 +27,56 @@
* when the underlying byte stream times out
*/
-import java.net.*;
-import java.io.*;
-
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.InterruptedIOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.ServerSocket;
+import java.net.Socket;
public class StreamTimeout {
+ static final PrintStream log = System.err;
+ static String charset = "US-ASCII";
- private static PrintStream log = System.err;
-
- private static String charset = "US-ASCII";
+ private static class Client extends Thread implements Closeable {
+ private final Socket so;
- private static Object lock = new Object();
- private static synchronized void waitABit(int millisec) {
- synchronized(lock) {
- try {
- lock.wait(millisec);
- } catch (InterruptedException e) {
- //ignore
- }
+ Client(int port) throws IOException {
+ so = new Socket("127.0.0.1", port);
}
- }
- private static class Client extends Thread {
+ @Override
public void run() {
try {
- Socket so = new Socket("127.0.0.1", 22222);
Writer wr = new OutputStreamWriter(so.getOutputStream(),
- charset);
+ charset);
wr.write("ab");
wr.flush();
} catch (IOException x) {
log.print("Unexpected exception in writer: ");
x.printStackTrace();
- System.exit(1);
}
}
+
+ @Override
+ public void close() throws IOException {
+ so.close();
+ }
}
private static void gobble(InputStream is, Reader rd,
- int ec, boolean force)
- throws Exception
- {
+ int ec, boolean force)
+ throws Exception
+ {
int a = is.available();
boolean r = rd.ready();
log.print("" + a + " bytes available, "
- + "reader " + (r ? "" : "not ") + "ready");
+ + "reader " + (r ? "" : "not ") + "ready");
if (!r && !force) {
log.println();
return;
@@ -84,10 +89,10 @@
throw x;
}
log.println(", read() ==> "
- + (c >= 0 ? ("'" + (char)c + "'" ): "EOF"));
+ + (c >= 0 ? ("'" + (char)c + "'" ): "EOF"));
if (c != ec)
throw new Exception("Incorrect value read: Expected "
- + ec + ", read " + (char)c);
+ + ec + ", read " + (char)c);
}
public static void main(String[] args) throws Exception {
@@ -95,43 +100,49 @@
if (args.length > 0)
charset = args[0];
- ServerSocket ss = new ServerSocket(22222);
- Thread cl = new Client();
- cl.start();
- Socket s = ss.accept();
- s.setSoTimeout(150);
- InputStream is = s.getInputStream();
- Reader rd = new InputStreamReader(is, charset);
+ try(ServerSocket ss = new ServerSocket(0);
+ Client cl = new Client(ss.getLocalPort())) {
+
+ cl.start();
+
+ try(Socket s = ss.accept()) {
+ s.setSoTimeout(150);
- while (is.available() <= 0)
- Thread.yield();
+ try(InputStream is = s.getInputStream();
+ Reader rd = new InputStreamReader(is, charset)) {
- gobble(is, rd, 'a', false);
- gobble(is, rd, 'b', false);
- gobble(is, rd, -1, false);
+ while (is.available() <= 0)
+ Thread.yield();
+
+ gobble(is, rd, 'a', false);
+ gobble(is, rd, 'b', false);
+ gobble(is, rd, -1, false);
- boolean caught = false;
- try {
- gobble(is, rd, -1, true);
- } catch (InterruptedIOException e) {
- log.println("Read timed out, as expected");
- caught = true;
- }
- if (!caught) {
- log.println("Read did not time out, test inapplicable");
- return;
- }
+ boolean caught = false;
+ try {
+ gobble(is, rd, -1, true);
+ } catch (InterruptedIOException e) {
+ log.println("Read timed out, as expected");
+ caught = true;
+ }
+ if (!caught) {
+ log.println("Read did not time out, test inapplicable");
+ return;
+ }
- caught = false;
- try {
- gobble(is, rd, -1, true);
- } catch (InterruptedIOException x) {
- log.println("Second read timed out, as expected");
- caught = true;
+ caught = false;
+ try {
+ gobble(is, rd, -1, true);
+ } catch (InterruptedIOException x) {
+ log.println("Second read timed out, as expected");
+ caught = true;
+ }
+ if (!caught)
+ throw new Exception("Second read completed");
+ }
+ }
+
+ cl.join();
}
- if (!caught)
- throw new Exception("Second read completed");
-
}
-
}
--- a/jdk/test/java/security/CodeSource/Implies.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/java/security/CodeSource/Implies.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 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
@@ -23,25 +23,42 @@
/*
* @test
- * @bug 4866847
- * @summary NullPointerException from CodeSource.matchLocation
+ * @bug 4866847 7152564 7155693
+ * @summary various CodeSource.implies tests
*/
import java.security.CodeSource;
-import java.net.*;
+import java.net.URL;
public class Implies {
public static void main(String[] args) throws Exception {
URL thisURL = new URL("http", "localhost", "file");
URL thatURL = new URL("http", null, "file");
+ // should not throw NullPointerException
+ testImplies(thisURL, thatURL, false);
+
+ thisURL = new URL("http", "localhost", "dir/-");
+ thatURL = new URL("HTTP", "localhost", "dir/file");
+ // protocol check should ignore case
+ testImplies(thisURL, thatURL, true);
+
+ thisURL = new URL("http", "localhost", 80, "dir/-");
+ thatURL = new URL("HTTP", "localhost", "dir/file");
+ // port check should match default port of thatURL
+ testImplies(thisURL, thatURL, true);
+
+ System.out.println("test passed");
+ }
+
+ private static void testImplies(URL thisURL, URL thatURL, boolean result)
+ throws SecurityException
+ {
CodeSource thisCs =
new CodeSource(thisURL, (java.security.cert.Certificate[]) null);
CodeSource thatCs =
new CodeSource(thatURL, (java.security.cert.Certificate[]) null);
-
- if (thisCs.implies(thatCs)) {
+ if (thisCs.implies(thatCs) != result) {
throw new SecurityException("test failed");
}
- System.out.println("test passed");
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/AbstractCollection/ToArrayTest.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,215 @@
+/*
+ * 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 7121314
+ * @summary AbstractCollection.toArray(T[]) doesn't return the given array
+ * in concurrent modification.
+ * @author Ulf Zibis, David Holmes
+ */
+
+import java.util.AbstractCollection;
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class ToArrayTest {
+
+ static class TestCollection<E> extends AbstractCollection<E> {
+ private final E[] elements;
+ private int[] sizes;
+ private int nextSize;
+
+ public TestCollection(E[] elements) {
+ this.elements = elements;
+ setSizeSequence(new int[] { elements.length });
+ }
+
+ /*
+ * Sets the values that size() will return on each use. The next
+ * call to size will return sizes[0], then sizes[1] etc. This allows us
+ * to emulate a concurrent change to the contents of the collection
+ * without having to perform concurrent changes. If sizes[n+1] contains
+ * a larger value, the collection will appear to have shrunk when
+ * iterated; if a smaller value then the collection will appear to have
+ * grown when iterated.
+ */
+ void setSizeSequence(int... sizes) {
+ this.sizes = sizes;
+ nextSize = 0;
+ }
+
+ /* can change collection's size after each invocation */
+ @Override
+ public int size() {
+ return sizes[nextSize == sizes.length - 1 ? nextSize : nextSize++];
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new Iterator<E>() {
+ int pos = 0;
+
+ public boolean hasNext() {
+ return pos < sizes[nextSize];
+ }
+ public E next() {
+ return elements[pos++];
+ }
+ public void remove() {
+ throw new UnsupportedOperationException(
+ "Not supported yet.");
+ }
+ };
+ }
+ }
+
+ static final Object[] OBJECTS = { new Object(), new Object(), new Object() };
+ static final TestCollection<?> CANDIDATE = new TestCollection<Object>(OBJECTS);
+ static final int CAP = OBJECTS.length; // capacity of the CANDIDATE
+ static final int LAST = CAP - 1; // last possible array index
+ Object[] a;
+ Object[] res;
+
+ int last() {
+ return a.length - 1;
+ }
+
+ protected void test() throws Throwable {
+ // Check array type conversion
+ res = new TestCollection<>(new Object[] { "1", "2" }).toArray(new String[0]);
+ check(res instanceof String[]);
+ check(res.length == 2);
+ check(res[1] == "2");
+
+ // Check incompatible type of target array
+ try {
+ res = CANDIDATE.toArray(new String[CAP]);
+ check(false);
+ } catch (Throwable t) {
+ check(t instanceof ArrayStoreException);
+ }
+
+ // Check more elements than a.length
+ a = new Object[CAP - 1]; // appears too small
+ res = CANDIDATE.toArray(a);
+ check(res != a);
+ check(res[LAST] != null);
+
+ // Check equal elements as a.length
+ a = new Object[CAP]; // appears to match
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] != null);
+
+ // Check equal elements as a.length
+ a = new Object[CAP + 1]; // appears too big
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] == null);
+
+ // Check less elements than expected, but more than a.length
+ a = new Object[CAP - 2]; // appears too small
+ CANDIDATE.setSizeSequence(CAP, CAP - 1);
+ res = CANDIDATE.toArray(a);
+ check(res != a);
+ check(res.length == CAP - 1);
+ check(res[LAST - 1] != null);
+
+ // Check less elements than expected, but equal as a.length
+ a = Arrays.copyOf(OBJECTS, CAP); // appears to match
+ CANDIDATE.setSizeSequence(CAP, CAP - 1);
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] == null);
+
+ // Check more elements than expected and more than a.length
+ a = new Object[CAP - 1]; // appears to match
+ CANDIDATE.setSizeSequence(CAP - 1, CAP);
+ res = CANDIDATE.toArray(a);
+ check(res != a);
+ check(res[LAST] != null);
+
+ // Check more elements than expected, but equal as a.length
+ a = new Object[CAP - 1]; // appears to match
+ CANDIDATE.setSizeSequence(CAP - 2, CAP - 1);
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] != null);
+
+ // Check more elements than expected, but less than a.length
+ a = Arrays.copyOf(OBJECTS, CAP); // appears to match
+ CANDIDATE.setSizeSequence(CAP - 2, CAP - 1);
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] == null);
+
+ test_7121314();
+ }
+
+ /*
+ * Major target of this testcase, bug 7121314.
+ */
+ protected void test_7121314() throws Throwable {
+ // Check equal elements as a.length, but less than expected
+ a = new Object[CAP - 1]; // appears too small
+ CANDIDATE.setSizeSequence(CAP, CAP - 1);
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] != null);
+
+ // Check less elements than a.length and less than expected
+ a = Arrays.copyOf(OBJECTS, CAP - 1); // appears too small
+ CANDIDATE.setSizeSequence(CAP, CAP - 2);
+ res = CANDIDATE.toArray(a);
+ check(res == a);
+ check(res[last()] == null);
+
+ }
+
+ public static void main(String[] args) throws Throwable {
+ ToArrayTest testcase = new ToArrayTest();
+ try {
+ testcase.test();
+ } catch (Throwable t) {
+ unexpected(t);
+ }
+
+ System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+ if (failed > 0) throw new Exception("Some tests failed");
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ static volatile int passed = 0, failed = 0;
+ static void pass() { passed++; }
+ static void fail() { failed++; Thread.dumpStack(); }
+ static void fail(String msg) { System.out.println(msg); fail(); }
+ static void unexpected(Throwable t) { failed++; t.printStackTrace(); }
+ static void check(boolean cond) { if (cond) pass(); else fail(); }
+ static void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else {System.out.println(x + " not equal to " + y); fail(); }
+ }
+}
+
+
--- a/jdk/test/java/util/regex/RegExTest.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/java/util/regex/RegExTest.java Mon Apr 23 16:58:40 2012 -0700
@@ -33,6 +33,7 @@
* 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
* 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
* 6350801 6676425 6878475 6919132 6931676 6948903 6990617 7014645 7039066
+ * 7067045
*/
import java.util.regex.*;
@@ -852,6 +853,17 @@
if (!result.equals(toSupplementaries("zzz\\t$\\$zzz")))
failCount++;
+ // IAE should be thrown if backslash or '$' is the last character
+ // in replacement string
+ try {
+ "\uac00".replaceAll("\uac00", "$");
+ "\uac00".replaceAll("\uac00", "\\");
+ failCount++;
+ } catch (IllegalArgumentException iie) {
+ } catch (Exception e) {
+ failCount++;
+ }
+
report("Literal replacement");
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/DirectAudio/bug6400879.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 6400879
+ @bug 7100140
+ @summary Tests that Start/Stop sequence doesn't hang
+ @author Alexey Menkov
+ @run main bug6400879
+ */
+
+import javax.sound.sampled.*;
+
+public class bug6400879 extends Thread {
+
+ public static void main(String args[]) throws Exception {
+ bug6400879 pThis = new bug6400879();
+ //pThis.init();
+ pThis.setDaemon(true);
+ pThis.start();
+ monitor(pThis);
+ }
+
+ static final long BLOCK_TIMEOUT = 5000; // 5 sec
+
+ // monitors that pThis doesn't hang
+ public static void monitor(bug6400879 pThis) throws Exception {
+ long prevLoop = -1;
+ long prevTime = currentTimeMillis();
+ while (pThis.isAlive()) {
+ if (pThis.loopCounter == prevLoop) {
+ if (currentTimeMillis() - prevTime > BLOCK_TIMEOUT) {
+ // block!
+ log("Test FAILED.");
+ throw new RuntimeException("Test FAILED: thread has been blocked!");
+ }
+ } else {
+ prevLoop = pThis.loopCounter;
+ prevTime = currentTimeMillis();
+ }
+ delay(500); // sleep for 0.5 sec
+ }
+ log("Test sucessfully passed.");
+ }
+
+ volatile long loopCounter = 0;
+ final long LOOPS_PER_LINE = 100;
+
+ public void run() {
+ SourceDataLine line = null;
+
+ DataLine.Info line_info = new DataLine.Info(SourceDataLine.class, null);
+ Line.Info infos[] = AudioSystem.getSourceLineInfo(line_info);
+
+ log("total " + infos.length + " lines");
+
+ for (int lineNum = 0; lineNum < infos.length; lineNum++) {
+ try {
+ line = (SourceDataLine)AudioSystem.getLine(infos[lineNum]);
+ log("testing line: " + line);
+ line.open(line.getFormat());
+ for (int i=0; i<LOOPS_PER_LINE; i++) {
+ log("start->stop (" + i + ")");
+ line.start();
+ line.stop();
+ log(" - OK");
+ loopCounter++;
+ }
+ line.close();
+ line = null;
+ } catch (LineUnavailableException e1) {
+ log("LineUnavailableException caught, test okay.");
+ log(e1.getMessage());
+ } catch (SecurityException e2) {
+ log("SecurityException caught, test okay.");
+ log(e2.getMessage());
+ } catch (IllegalArgumentException e3) {
+ log("IllegalArgumentException caught, test okay.");
+ log(e3.getMessage());
+ }
+ if (line != null) {
+ line.close();
+ line = null;
+ }
+ }
+
+ }
+
+
+ // helper routines
+ static long startTime = currentTimeMillis();
+ static long currentTimeMillis() {
+ //return System.nanoTime() / 1000000L;
+ return System.currentTimeMillis();
+ }
+ static void log(String s) {
+ long time = currentTimeMillis() - startTime;
+ long ms = time % 1000;
+ time /= 1000;
+ long sec = time % 60;
+ time /= 60;
+ long min = time % 60;
+ time /= 60;
+ System.out.println(""
+ + (time < 10 ? "0" : "") + time
+ + ":" + (min < 10 ? "0" : "") + min
+ + ":" + (sec < 10 ? "0" : "") + sec
+ + "." + (ms < 10 ? "00" : (ms < 100 ? "0" : "")) + ms
+ + " (" + Thread.currentThread().getName() + ") " + s);
+ }
+ static void delay(int millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e) {}
+ }
+}
--- a/jdk/test/javax/sound/sampled/FileWriter/AlawEncoderSync.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/javax/sound/sampled/FileWriter/AlawEncoderSync.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,6 +1,32 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 6938426
+ * @bug 7058852
* @summary Tests that Alaw encoder works properly in multithreaded environment
* @author Alex Menkov
*/
@@ -34,7 +60,7 @@
threads[i].start();
}
- for (int i=1; i<THREAD_COUNT; i++) {
+ for (int i=0; i<THREAD_COUNT; i++) {
try {
threads[i].join();
} catch (InterruptedException ex) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/border/Test7149090.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,84 @@
+/*
+ * 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 7149090
+ @summary Nimbus:BorderFactory.createTitledBorder() the DEFAULT position of a title is not the same as the TOP
+ @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.TitledBorder;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Test7149090 {
+ private static final Object[][] DEFAULT_TITLE_POSITIONS = {
+ {"Metal", TitledBorder.TOP},
+ {"Motif", TitledBorder.TOP},
+ {"Windows", TitledBorder.TOP},
+ {"Nimbus", TitledBorder.ABOVE_TOP},
+ };
+
+ public static void main(String[] args) throws Exception {
+ for (UIManager.LookAndFeelInfo lookAndFeel : UIManager.getInstalledLookAndFeels()) {
+ for (Object[] defaultTitlePosition : DEFAULT_TITLE_POSITIONS) {
+ if (defaultTitlePosition[0].equals(lookAndFeel.getName())) {
+ UIManager.setLookAndFeel(lookAndFeel.getClassName());
+
+ final int expectedPosition = (Integer) defaultTitlePosition[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ List<TitledBorder> borders = new ArrayList<>();
+
+ borders.add(BorderFactory.createTitledBorder(new EmptyBorder(0, 0, 0, 0), "Title"));
+
+ try {
+ Method getPositionMethod = TitledBorder.class.getDeclaredMethod("getPosition");
+
+ getPositionMethod.setAccessible(true);
+
+ for (TitledBorder border : borders) {
+ int position = (Integer) getPositionMethod.invoke(border);
+
+ if (position != expectedPosition) {
+ throw new RuntimeException("Invalid title position");
+ }
+ }
+ } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+
+ System.out.println("Test passed for LookAndFeel " + lookAndFeel.getName());
+ }
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/synth/7158712/bug7158712.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,116 @@
+/*
+ * 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 7158712
+ @summary Synth Property "ComboBox.popupInsets" is ignored
+ @library ../../../regtesthelpers
+ @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboPopup;
+import javax.swing.plaf.synth.SynthLookAndFeel;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.io.ByteArrayInputStream;
+import java.util.concurrent.Callable;
+
+public class bug7158712 {
+ private static final String SYNTH_XML = "<synth>" +
+ " <style id=\"all\">" +
+ " <font name=\"Dialog\" size=\"12\"/>" +
+ " </style>" +
+ " <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
+ " <style id=\"arrowButton\">" +
+ " <property key=\"ArrowButton.size\" type=\"integer\" value=\"18\"/>" +
+ " </style>" +
+ " <bind style=\"arrowButton\" type=\"region\" key=\"ArrowButton\"/>" +
+ " <style id=\"comboBox\">" +
+ " <property key=\"ComboBox.popupInsets\" type=\"insets\" value=\"-5 -5 5 -5\"/>" +
+ " </style>" +
+ " <bind style=\"comboBox\" type=\"region\" key=\"ComboBox\"/>" +
+ "</synth>";
+
+ private static JComboBox<String> comboBox;
+
+ public static void main(String[] args) throws Exception {
+ Robot robot = new Robot();
+
+ robot.setAutoDelay(500);
+
+ SynthLookAndFeel laf = new SynthLookAndFeel();
+
+ laf.load(new ByteArrayInputStream(SYNTH_XML.getBytes("UTF8")), bug7158712.class);
+
+ UIManager.setLookAndFeel(laf);
+
+ EventQueue.invokeAndWait(new Runnable() {
+ public void run() {
+ comboBox = new JComboBox<>(
+ new String[]{"Very Looooooooooooooooooooong Text Item 1", "Item 2"});
+
+ JFrame frame = new JFrame();
+
+ frame.add(comboBox, BorderLayout.NORTH);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setSize(new Dimension(400, 300));
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+ }
+ });
+
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+
+ Point comboBoxLocation = Util.invokeOnEDT(new Callable<Point>() {
+ @Override
+ public Point call() throws Exception {
+ return comboBox.getLocationOnScreen();
+ }
+ });
+
+ robot.mouseMove(comboBoxLocation.x, comboBoxLocation.y);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ BasicComboPopup popup = (BasicComboPopup) comboBox.getAccessibleContext().getAccessibleChild(0);
+
+ Point popupPoint = popup.getLocationOnScreen();
+ Point comboBoxPoint = comboBox.getLocationOnScreen();
+
+ if (comboBoxPoint.x - 5 != popupPoint.x ||
+ comboBoxPoint.y + comboBox.getHeight() - 5 != popupPoint.y) {
+ throw new RuntimeException("Invalid popup coordinates. Popup location: " + popupPoint +
+ ", comboBox location: " + comboBoxPoint);
+ }
+
+ System.out.println("Test bug7158712 passed");
+ }
+ });
+ }
+}
--- a/jdk/test/javax/swing/regtesthelpers/Util.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java Mon Apr 23 16:58:40 2012 -0700
@@ -24,8 +24,10 @@
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.Callable;
/**
* <p>This class contains utilities useful for regression testing.
@@ -153,4 +155,31 @@
robot.keyRelease(keys[i]);
}
}
+
+ /**
+ * Invokes the <code>task</code> on the EDT thread.
+ *
+ * @return result of the <code>task</code>
+ */
+ public static <T> T invokeOnEDT(final Callable<T> task) throws Exception {
+ final List<T> result = new ArrayList<>(1);
+ final Exception[] exception = new Exception[1];
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ result.add(task.call());
+ } catch (Exception e) {
+ exception[0] = e;
+ }
+ }
+ });
+
+ if (exception[0] != null) {
+ throw exception[0];
+ }
+
+ return result.get(0);
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/AbstractDocument/7146146/bug7146146.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,77 @@
+/*
+ * 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 7146146
+ @summary Deadlock between subclass of AbstractDocument and UndoManager
+ @author Pavel Porvatov
+*/
+
+import javax.swing.text.BadLocationException;
+import javax.swing.text.PlainDocument;
+import javax.swing.text.StringContent;
+import javax.swing.undo.UndoManager;
+
+public class bug7146146 {
+ public static void main(String[] args) throws Exception {
+ for (int i = 0; i < 1000; i++) {
+ System.out.print("Iteration " + i);
+
+ test();
+
+ System.out.print(" passed");
+ }
+ }
+
+ private static void test() throws Exception {
+ final PlainDocument doc = new PlainDocument(new StringContent());
+ final UndoManager undoManager = new UndoManager();
+
+ doc.addUndoableEditListener(undoManager);
+ doc.insertString(0, "<Test 1>", null);
+
+ Thread t1 = new Thread("Thread 1") {
+ @Override
+ public void run() {
+ try {
+ doc.insertString(0, "<Test 2>", null);
+ } catch (BadLocationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+
+ Thread t2 = new Thread("Thread 2") {
+ @Override
+ public void run() {
+ undoManager.undo();
+ }
+ };
+
+ t1.start();
+ t2.start();
+
+ t1.join();
+ t2.join();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/awt/image/ImageWatched/AddNoLeak.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,59 @@
+/*
+ * 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.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.ImageConsumer;
+import java.awt.Image;
+import java.awt.Container;
+
+/* @test 1.0 12/01/17
+ @bug 7104151
+ @summary Make sure that we don't leak image observers (or related objects)
+ @run main/othervm AddNoLeak
+ @author David Buck
+*/
+
+public class AddNoLeak {
+ public static void main(String[] args) {
+ System.setProperty("java.awt.headless", "true");
+ Container cont = new Container();
+ Image img = cont.createImage(new DummyImageSource());
+ for(int i=0;i < 15000;i++) {
+ img.getWidth(new ImageObserver() {
+ public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {return false;}
+ });
+ if (i % 100 == 0) {
+ System.gc();
+ }
+ }
+ }
+
+ private static class DummyImageSource implements ImageProducer {
+ public void addConsumer(ImageConsumer ic){}
+ public boolean isConsumer(ImageConsumer ic){return false;}
+ public void removeConsumer(ImageConsumer ic){}
+ public void startProduction(ImageConsumer ic){}
+ public void requestTopDownLeftRightResend(ImageConsumer ic){}
+ }
+}
--- a/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.java Mon Apr 23 16:58:40 2012 -0700
@@ -54,8 +54,12 @@
public SharedMemoryPixmapsTest() {
testFrame = new Frame("SharedMemoryPixmapsTest");
testFrame.add(new TestComponent());
+ testFrame.setUndecorated(true);
+ testFrame.setResizable(false);
testFrame.pack();
+ testFrame.setLocationRelativeTo(null);
testFrame.setVisible(true);
+ testFrame.toFront();
}
public static void main(String[] args) {
--- a/jdk/test/sun/net/www/protocol/jar/B4957695.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/sun/net/www/protocol/jar/B4957695.java Mon Apr 23 16:58:40 2012 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,6 @@
/**
* @test
* @bug 4957695
- * @library ../../httptest/
- * @build HttpCallback HttpServer ClosedChannelList HttpTransaction AbstractCallback
* @summary URLJarFile.retrieve does not delete tmpFile on IOException
*/
@@ -34,8 +32,56 @@
public class B4957695 {
- static int count = 0;
- static boolean error = false;
+ static Server server;
+
+ static class Server extends Thread {
+ final ServerSocket srv;
+ static final byte[] requestEnd = new byte[] {'\r', '\n', '\r', '\n'};
+
+ Server(ServerSocket s) {
+ srv = s;
+ }
+
+ void readOneRequest(InputStream is) throws IOException {
+ int requestEndCount = 0, r;
+ while ((r = is.read()) != -1) {
+ if (r == requestEnd[requestEndCount]) {
+ requestEndCount++;
+ if (requestEndCount == 4) {
+ break;
+ }
+ } else {
+ requestEndCount = 0;
+ }
+ }
+ }
+
+ public void run() {
+ try (Socket s = srv.accept()) {
+ // read HTTP request from client
+ readOneRequest(s.getInputStream());
+ try (OutputStreamWriter ow =
+ new OutputStreamWriter((s.getOutputStream()))) {
+ FileInputStream fin = new FileInputStream("foo1.jar");
+ int length = fin.available();
+ byte[] b = new byte[length-10];
+ fin.read(b, 0, length-10);
+ ow.write("HTTP/1.0 200 OK\r\n");
+
+ // Note: The client expects length bytes.
+ ow.write("Content-Length: " + length + "\r\n");
+ ow.write("Content-Type: text/html\r\n");
+ ow.write("\r\n");
+
+ // Note: The (buggy) server only sends length-10 bytes.
+ ow.write(new String(b));
+ ow.flush();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
static void read (InputStream is) throws IOException {
int c,len=0;
@@ -45,32 +91,13 @@
System.out.println ("read " + len + " bytes");
}
- static class CallBack extends AbstractCallback {
-
- public void request (HttpTransaction req, int count) {
- try {
- System.out.println ("Request received");
- req.setResponseEntityBody (new FileInputStream ("foo1.jar"));
- System.out.println ("content length " + req.getResponseHeader (
- "Content-length"
- ));
- req.sendPartialResponse (200, "Ok");
- req.abortiveClose();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- };
-
- static HttpServer server;
-
public static void main (String[] args) throws Exception {
String tmpdir = System.getProperty("java.io.tmpdir");
String[] list1 = listTmpFiles(tmpdir);
- //server = new HttpServer (new CallBack(), 10, 1, 0);
- server = new HttpServer (new CallBack(), 1, 5, 0);
- int port = server.getLocalPort();
+ ServerSocket serverSocket = new ServerSocket(0);
+ server = new Server(serverSocket);
+ server.start();
+ int port = serverSocket.getLocalPort();
System.out.println ("Server: listening on port: " + port);
URL url = new URL ("jar:http://localhost:"+port+"!/COPYRIGHT");
try {
@@ -81,14 +108,12 @@
} catch (IOException e) {
System.out.println ("Received IOException as expected");
}
- server.terminate();
String[] list2 = listTmpFiles(tmpdir);
if (!sameList (list1, list2)) {
throw new RuntimeException ("some jar_cache files left behind");
}
}
-
static String[] listTmpFiles (String d) {
File dir = new File (d);
return dir.list (new FilenameFilter () {
--- a/jdk/test/sun/nio/ch/SelProvider.java Thu Apr 19 12:18:58 2012 -0700
+++ b/jdk/test/sun/nio/ch/SelProvider.java Mon Apr 23 16:58:40 2012 -0700
@@ -38,20 +38,9 @@
if ("SunOS".equals(osname)) {
expected = "sun.nio.ch.DevPollSelectorProvider";
} else if ("Linux".equals(osname)) {
- String[] vers = osver.split("\\.", 0);
- if (vers.length >= 2) {
- int major = Integer.parseInt(vers[0]);
- int minor = Integer.parseInt(vers[1]);
- if (major > 2 || (major == 2 && minor >= 6)) {
- expected = "sun.nio.ch.EPollSelectorProvider";
- } else {
- expected = "sun.nio.ch.PollSelectorProvider";
- }
- } else {
- throw new RuntimeException("Test does not recognize this operating system");
- }
+ expected = "sun.nio.ch.EPollSelectorProvider";
} else if (osname.startsWith("Mac OS")) {
- expected = "sun.nio.ch.PollSelectorProvider";
+ expected = "sun.nio.ch.KQueueSelectorProvider";
} else
return;
if (!spName.equals(expected))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/nio/cs/TestSJIS0213_SM.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,36 @@
+/*
+ * 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 7152690
+ @summary Initialize SJIS_0213 charset with SecurityManager enabled
+ */
+public class TestSJIS0213_SM {
+ public static void main(String[] args) throws Throwable {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null) {
+ System.setSecurityManager(new SecurityManager());
+ }
+ java.nio.charset.Charset.forName("SJIS_0213");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/rmi/rmic/classpath/RMICClassPathTest.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/* @test
+ * @bug 6610897
+ * @summary New constructor in sun.tools.java.ClassPath builds a path using
+ * File.separator instead of File.pathSeparator
+ * @run main RMICClassPathTest
+ */
+
+import java.io.File;
+
+import sun.rmi.rmic.BatchEnvironment;
+
+public class RMICClassPathTest {
+ public static void main(String[] args) throws Exception {
+ String sysPath = "/home/~user/jdk/jre/lib/rt.jar";
+ String extDir = "";
+ String clPath = "/home/~user/user.jar" + File.pathSeparator +
+ "/home/~user/user2.jar" + File.pathSeparator +
+ "/home/~user/user3.jar";
+
+ String cpStr = BatchEnvironment.createClassPath(clPath, sysPath, extDir).toString();
+
+ String[] paths = cpStr.split(File.pathSeparator);
+
+ if (paths.length != 4) {
+ throw new Exception("ClassPath length is not correct: the expected length is 4 and the actual length is " + paths.length);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/ccache/EmptyCC.java Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,83 @@
+/*
+ * 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 7158329
+ * @summary NPE in sun.security.krb5.Credentials.acquireDefaultCreds()
+ * @compile -XDignore.symbol.file EmptyCC.java
+ * @run main EmptyCC
+ */
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import sun.security.krb5.Credentials;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.internal.ccache.CredentialsCache;
+
+public class EmptyCC {
+ public static void main(String[] args) throws Exception {
+ final PrincipalName pn = new PrincipalName("dummy@FOO.COM");
+ final String ccache = "tmpcc";
+
+ if (args.length == 0) {
+ // Main process, write the ccache and launch sub process
+ CredentialsCache cache = CredentialsCache.create(pn, ccache);
+ cache.save();
+
+ // java -cp $test.classes EmptyCC readcc
+ ProcessBuilder pb = new ProcessBuilder(
+ new File(new File(System.getProperty("java.home"), "bin"),
+ "java").getPath(),
+ "-cp",
+ System.getProperty("test.classes"),
+ "EmptyCC",
+ "readcc"
+ );
+
+ pb.environment().put("KRB5CCNAME", ccache);
+ pb.redirectErrorStream(true);
+
+ Process p = pb.start();
+ try (InputStream ins = p.getInputStream()) {
+ byte[] buf = new byte[8192];
+ int n;
+ while ((n = ins.read(buf)) > 0) {
+ System.out.write(buf, 0, n);
+ }
+ }
+ if (p.waitFor() != 0) {
+ throw new Exception("Test failed");
+ }
+ } else {
+ // Sub process, read the ccache
+ String cc = System.getenv("KRB5CCNAME");
+ if (!cc.equals(ccache)) {
+ throw new Exception("env not set correctly");
+ }
+ Credentials.acquireTGTFromCache(pn, null);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jcmd/dcmd-big-script.txt Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,95 @@
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jcmd/jcmd-big-script.sh Mon Apr 23 16:58:40 2012 -0700
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+#
+# 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 7154822
+# @summary test if we can send a file over 1024 bytes large via jcmd -f
+# @author David Buck
+#
+# @library ../common
+# @build SimpleApplication ShutdownSimpleApplication
+# @run shell jcmd-big-script.sh
+
+. ${TESTSRC}/../common/CommonSetup.sh
+. ${TESTSRC}/../common/ApplicationSetup.sh
+
+# Start application and use PORTFILE for coordination
+PORTFILE="${TESTCLASSES}"/shutdown.port
+startApplication SimpleApplication "${PORTFILE}"
+
+failed=0;
+
+# -f <script>
+rm -f jcmd.out 2>/dev/null
+set +e # even if jcmd fails, we do not want abort the script yet.
+${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-big-script.txt > jcmd.out 2>&1
+status="$?"
+set -e
+if [ "$status" != 0 ]; then
+ echo "jcmd command returned non-zero exit code (status=$status). Failed."
+ failed=1;
+fi
+cat jcmd.out
+set +e # if the test passes, grep will "fail" with an exit code of 1
+grep Exception jcmd.out > /dev/null 2>&1
+status="$?"
+set -e
+if [ "$status" = 0 ]; then
+ echo "Output of \"jcmd [pid] -f dcmd-big-script.txt\" contains string \"Exception\". Failed."
+ failed=1;
+fi
+
+# clean up
+rm -f jcmd.out 2>/dev/null
+stopApplication "${PORTFILE}"
+waitForApplication
+
+exit $failed