Merge
This commit is contained in:
commit
d331cf663e
@ -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
|
||||
|
@ -131,8 +131,9 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
|
||||
# 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 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
|
||||
_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 @@ ifeq ($(DEBUG_BINARIES), true)
|
||||
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)
|
||||
|
@ -138,8 +138,9 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
|
||||
# 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 @@ ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
|
||||
_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 @@ ifeq ($(FASTDEBUG), true)
|
||||
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.
|
||||
|
@ -113,9 +113,7 @@ _JUNK_ := $(shell \
|
||||
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
|
||||
|
@ -181,8 +181,17 @@ $(ACTUAL_LIBRARY):: $(OBJDIR)/$(LIBRARY).lcf
|
||||
$(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 @@ else # LIBRARY
|
||||
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
|
||||
|
@ -189,6 +189,15 @@ endif
|
||||
$(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 @@ else
|
||||
-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 @@ ifeq ($(PLATFORM), windows)
|
||||
$(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::
|
||||
|
@ -873,7 +873,9 @@ ifeq ($(PLATFORM), windows)
|
||||
-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 @@ ifeq ($(PLATFORM), windows)
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -36,7 +36,7 @@ include $(BUILDDIR)/common/Defs.gmk
|
||||
#
|
||||
# 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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -27,6 +27,8 @@
|
||||
# Makefile for building simple launchers
|
||||
#
|
||||
|
||||
PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
|
||||
|
||||
BUILDDIR = ..
|
||||
PACKAGE = launcher
|
||||
PRODUCT = sun
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -62,7 +62,7 @@ FILES_export = \
|
||||
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 \
|
||||
|
@ -52,7 +52,6 @@ include FILES_c.gmk
|
||||
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 \
|
||||
|
@ -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
|
||||
|
@ -213,16 +213,8 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
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 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
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 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
// 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 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
|
||||
// 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,32 +36,34 @@ import sun.awt.SunToolkit;
|
||||
|
||||
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 @@ public abstract class LWCursorManager {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -39,12 +39,8 @@ final class LWRepaintArea extends RepaintArea {
|
||||
@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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -71,6 +72,15 @@ final class LWTextAreaPeer
|
||||
return getDelegate().getView();
|
||||
}
|
||||
|
||||
@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();
|
||||
|
@ -31,6 +31,7 @@ import java.awt.Point;
|
||||
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 @@ final class LWTextFieldPeer
|
||||
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
|
||||
|
@ -784,9 +784,8 @@ public class LWWindowPeer
|
||||
}
|
||||
mouseClickButtons &= ~eventButtonMask;
|
||||
}
|
||||
|
||||
notifyUpdateCursor();
|
||||
}
|
||||
notifyUpdateCursor();
|
||||
}
|
||||
|
||||
public void dispatchMouseWheelEvent(long when, int x, int y, int modifiers,
|
||||
@ -1057,6 +1056,10 @@ public class LWWindowPeer
|
||||
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);
|
||||
|
@ -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 @@ public class CCursorManager extends LWCursorManager {
|
||||
}
|
||||
|
||||
@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 @@ public class CCursorManager extends LWCursorManager {
|
||||
}
|
||||
|
||||
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 @@ public class CCursorManager extends LWCursorManager {
|
||||
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 @@ public class CCursorManager extends LWCursorManager {
|
||||
if (isDragging) {
|
||||
throw new RuntimeException("Invalid Drag state in CCursorManager!");
|
||||
}
|
||||
|
||||
isDragging = true;
|
||||
|
||||
dragPos = new Point(x, y);
|
||||
}
|
||||
|
||||
|
@ -88,13 +88,20 @@ public class CEmbeddedFrame extends EmbeddedFrame {
|
||||
responder.handleScrollEvent(x, y, modifierFlags, deltaX, deltaY);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -29,10 +29,14 @@ import java.awt.*;
|
||||
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 @@ public class CImage extends CFRetainedResource {
|
||||
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 @@ public class CImage extends CFRetainedResource {
|
||||
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) {
|
||||
|
@ -117,7 +117,7 @@ final class CPlatformResponder {
|
||||
* 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 @@ final class CPlatformResponder {
|
||||
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 @@ final class CPlatformResponder {
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public class CPlatformView extends CFRetainedResource {
|
||||
|
||||
private void deliverKeyEvent(NSEvent event) {
|
||||
responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
|
||||
event.getCharactersIgnoringModifiers(), event.getKeyCode());
|
||||
event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
|
||||
}
|
||||
|
||||
private void deliverWindowDidExposeEvent() {
|
||||
|
@ -661,11 +661,19 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
@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 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -647,6 +647,15 @@ public class LWCToolkit extends LWToolkit {
|
||||
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 {
|
||||
|
@ -245,6 +245,12 @@ public final class NSEvent {
|
||||
*/
|
||||
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);
|
||||
|
@ -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 @@ public class DefaultSelectorProvider {
|
||||
* Returns the default SelectorProvider.
|
||||
*/
|
||||
public static SelectorProvider create() {
|
||||
return new sun.nio.ch.PollSelectorProvider();
|
||||
return new sun.nio.ch.KQueueSelectorProvider();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @@ class KQueueArrayWrapper {
|
||||
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;
|
||||
|
@ -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 @@ class KQueueSelectorImpl
|
||||
// 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 @@ class KQueueSelectorImpl
|
||||
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 @@ class KQueueSelectorImpl
|
||||
fd1 = (int)fds;
|
||||
kqueueWrapper = new KQueueArrayWrapper();
|
||||
kqueueWrapper.initInterrupt(fd0, fd1);
|
||||
fdToKey = new HashMap<>();
|
||||
fdMap = new HashMap<>();
|
||||
totalChannels = 1;
|
||||
}
|
||||
|
||||
@ -82,8 +98,6 @@ class KQueueSelectorImpl
|
||||
if (closed)
|
||||
throw new ClosedSelectorException();
|
||||
processDeregisterQueue();
|
||||
if (timeout == 0 && totalChannels == 1)
|
||||
return 0;
|
||||
try {
|
||||
begin();
|
||||
entries = kqueueWrapper.poll(timeout);
|
||||
@ -94,10 +108,9 @@ class KQueueSelectorImpl
|
||||
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 @@ class KQueueSelectorImpl
|
||||
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 @@ class KQueueSelectorImpl
|
||||
interruptTriggered = false;
|
||||
}
|
||||
}
|
||||
|
||||
return numKeysUpdated;
|
||||
}
|
||||
|
||||
@ -145,6 +175,12 @@ class KQueueSelectorImpl
|
||||
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 @@ class KQueueSelectorImpl
|
||||
|
||||
|
||||
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 @@ class KQueueSelectorImpl
|
||||
|
||||
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 @@ class KQueueSelectorImpl
|
||||
|
||||
|
||||
public void putEventOps(SelectionKeyImpl ski, int ops) {
|
||||
if (closed)
|
||||
throw new ClosedSelectorException();
|
||||
int fd = IOUtil.fdVal(ski.channel.getFD());
|
||||
kqueueWrapper.setInterest(fd, ops);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -124,7 +124,7 @@ const keyTable[] =
|
||||
{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 @@ const nsKeyToJavaModifierTable[] =
|
||||
* 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 @@ static struct _char {
|
||||
}
|
||||
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 @@ static unichar
|
||||
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 @@ NsKeyModifiersToJavaModifiers(NSUInteger nsFlags)
|
||||
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 @@ jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags)
|
||||
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_ENTER(env);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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 @@ static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
|
||||
|
||||
}
|
||||
|
||||
- (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 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
[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 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
[self.javaPlatformWindow setJObject:nil withEnv:env];
|
||||
self.growBoxWindow = nil;
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
@ -321,14 +260,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
// 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 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
// 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 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
}
|
||||
[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_NOT_APPKIT_THREAD;
|
||||
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 @@ AWT_ASSERT_NOT_APPKIT_THREAD;
|
||||
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_NOT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
[window setAlphaValue:alpha];
|
||||
[window.growBoxWindow setAlphaValue:alpha];
|
||||
}];
|
||||
|
||||
JNF_COCOA_EXIT(env);
|
||||
|
@ -648,6 +648,10 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
|
||||
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;
|
||||
|
@ -70,19 +70,8 @@ static void CImage_CopyNSImageIntoArray
|
||||
[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 @@ AWT_ASSERT_ANY_THREAD;
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, buffer, src, JNI_ABORT);
|
||||
|
||||
NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
|
||||
[nsImage addRepresentation:imageRep];
|
||||
[imageRep release];
|
||||
return imageRep;
|
||||
}
|
||||
|
||||
if (nsImage != nil) {
|
||||
CFRetain(nsImage); // GC
|
||||
/*
|
||||
* 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;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -114,6 +114,23 @@ class VMConnection {
|
||||
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 @@ class VMConnection {
|
||||
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;
|
||||
|
@ -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 @@ public final class HttpCookie implements Cloneable {
|
||||
* 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>
|
||||
|
@ -269,7 +269,7 @@ public final class Files {
|
||||
* 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>
|
||||
*
|
||||
|
@ -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 @@ public class CodeSource implements java.io.Serializable {
|
||||
*
|
||||
* @return a hash code value for this object.
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (location != null)
|
||||
return location.hashCode();
|
||||
@ -133,6 +133,7 @@ public class CodeSource implements java.io.Serializable {
|
||||
*
|
||||
* @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 @@ public class CodeSource implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* 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 @@ public class CodeSource implements java.io.Serializable {
|
||||
* <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 @@ public class CodeSource implements java.io.Serializable {
|
||||
*
|
||||
* <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 @@ public class CodeSource implements java.io.Serializable {
|
||||
* <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,92 +371,96 @@ public class CodeSource implements java.io.Serializable {
|
||||
*
|
||||
* @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))
|
||||
if ((that == null) || (that.location == null))
|
||||
return false;
|
||||
|
||||
if (location.equals(that.location))
|
||||
return true;
|
||||
|
||||
if (!location.getProtocol().equalsIgnoreCase(that.location.getProtocol()))
|
||||
return false;
|
||||
|
||||
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;
|
||||
|
||||
if (location.equals(that.location))
|
||||
return true;
|
||||
|
||||
if (!location.getProtocol().equals(that.location.getProtocol()))
|
||||
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.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))
|
||||
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.getRef() == null)
|
||||
return true;
|
||||
else
|
||||
return location.getRef().equals(that.location.getRef());
|
||||
}
|
||||
|
||||
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.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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
// everything matches
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string describing this CodeSource, telling its
|
||||
* URL and certificates.
|
||||
*
|
||||
* @return information about this CodeSource.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("(");
|
||||
|
@ -170,6 +170,7 @@ public abstract class AbstractCollection<E> implements Collection<E> {
|
||||
* @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 @@ public abstract class AbstractCollection<E> implements Collection<E> {
|
||||
|
||||
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 @@ public abstract class AbstractCollection<E> implements Collection<E> {
|
||||
* @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()) {
|
||||
|
@ -516,7 +516,7 @@ public abstract class AbstractList<E> extends AbstractCollection<E> implements L
|
||||
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();
|
||||
|
@ -443,7 +443,7 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
|
||||
|
||||
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 @@ public abstract class AbstractMap<K,V> implements Map<K,V> {
|
||||
* @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 abstract class AbstractMap<K,V> implements Map<K,V> {
|
||||
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 abstract class AbstractMap<K,V> implements Map<K,V> {
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public abstract class AbstractSet<E> extends AbstractCollection<E> implements Se
|
||||
|
||||
if (!(o instanceof Set))
|
||||
return false;
|
||||
Collection c = (Collection) o;
|
||||
Collection<?> c = (Collection<?>) o;
|
||||
if (c.size() != size())
|
||||
return false;
|
||||
try {
|
||||
|
@ -813,7 +813,8 @@ public class ArrayDeque<E> extends AbstractCollection<E>
|
||||
*/
|
||||
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 @@ public class ArrayDeque<E> extends AbstractCollection<E>
|
||||
/**
|
||||
* Deserialize this deque.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
|
@ -300,8 +300,7 @@ public class ArrayList<E> extends AbstractList<E>
|
||||
*/
|
||||
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;
|
||||
|
@ -560,6 +560,7 @@ public class Arrays {
|
||||
* 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 @@ public class Arrays {
|
||||
* 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 @@ public class Arrays {
|
||||
|
||||
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 @@ public class Arrays {
|
||||
* @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 @@ public class Arrays {
|
||||
* @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 @@ public class Arrays {
|
||||
* @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 @@ public class Arrays {
|
||||
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 @@ public class Arrays {
|
||||
return a.clone();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] toArray(T[] a) {
|
||||
int size = size();
|
||||
if (a.length < size)
|
||||
@ -3634,7 +3643,7 @@ public class Arrays {
|
||||
if (element == null) {
|
||||
buf.append("null");
|
||||
} else {
|
||||
Class eClass = element.getClass();
|
||||
Class<?> eClass = element.getClass();
|
||||
|
||||
if (eClass.isArray()) {
|
||||
if (eClass == byte[].class)
|
||||
|
@ -840,7 +840,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
||||
* 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 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
||||
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;
|
||||
|
@ -150,6 +150,7 @@ public class Collections {
|
||||
* 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 @@ public class Collections {
|
||||
* @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 @@ public class Collections {
|
||||
* 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 @@ public class Collections {
|
||||
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 @@ public class Collections {
|
||||
* @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 @@ public class Collections {
|
||||
* @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 @@ public class Collections {
|
||||
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 @@ public class Collections {
|
||||
* || 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 @@ public class Collections {
|
||||
* @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 @@ public class Collections {
|
||||
* @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 @@ public class Collections {
|
||||
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 @@ public class Collections {
|
||||
};
|
||||
}
|
||||
|
||||
@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 @@ public class Collections {
|
||||
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 @@ public class Collections {
|
||||
|
||||
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 @@ public class Collections {
|
||||
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());
|
||||
}
|
||||
|
@ -114,7 +114,6 @@ class ComparableTimSort {
|
||||
|
||||
// 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 @@ class ComparableTimSort {
|
||||
* @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 @@ class ComparableTimSort {
|
||||
* @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 @@ class ComparableTimSort {
|
||||
* (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 @@ class ComparableTimSort {
|
||||
* (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 @@ class ComparableTimSort {
|
||||
else
|
||||
newSize = Math.min(newSize, a.length >>> 1);
|
||||
|
||||
@SuppressWarnings({"unchecked", "UnnecessaryLocalVariable"})
|
||||
Object[] newArray = new Object[newSize];
|
||||
tmp = newArray;
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ public final class Currency implements Serializable {
|
||||
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 ++) {
|
||||
|
@ -120,11 +120,12 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
* 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 class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
*/
|
||||
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 class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
*/
|
||||
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 class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
*
|
||||
* @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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
* 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 @@ public class EnumMap<K extends Enum<K>, V> extends AbstractMap<K, V>
|
||||
* 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
|
||||
{
|
||||
|
@ -88,11 +88,11 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
|
||||
/**
|
||||
* 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 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
|
||||
* @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 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
|
||||
*
|
||||
* @return a copy of this set
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public EnumSet<E> clone() {
|
||||
try {
|
||||
return (EnumSet<E>) super.clone();
|
||||
@ -375,7 +376,7 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
|
||||
* 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 @@ public abstract class EnumSet<E extends Enum<E>> extends AbstractSet<E>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class HashMap<K,V>
|
||||
/**
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
*
|
||||
* @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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
/**
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
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 @@ public class HashMap<K,V>
|
||||
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 class HashMap<K,V>
|
||||
*/
|
||||
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 @@ public class HashMap<K,V>
|
||||
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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
*
|
||||
* @return a shallow copy of this map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object clone() {
|
||||
HashMap<K,V> result = null;
|
||||
try {
|
||||
@ -674,7 +685,7 @@ public class HashMap<K,V>
|
||||
} 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 class HashMap<K,V>
|
||||
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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
* 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 @@ public class HashMap<K,V>
|
||||
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 class HashMap<K,V>
|
||||
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 @@ public class HashMap<K,V>
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -247,6 +247,7 @@ public class HashSet<E>
|
||||
*
|
||||
* @return a shallow copy of this set
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object clone() {
|
||||
try {
|
||||
HashSet<E> newSet = (HashSet<E>) super.clone();
|
||||
@ -296,7 +297,7 @@ public class HashSet<E>
|
||||
// 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 @@ public class HashSet<E>
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class Hashtable<K,V>
|
||||
/**
|
||||
* 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 @@ public class Hashtable<K,V>
|
||||
if (initialCapacity==0)
|
||||
initialCapacity = 1;
|
||||
this.loadFactor = loadFactor;
|
||||
table = new Entry[initialCapacity];
|
||||
table = new Entry<?,?>[initialCapacity];
|
||||
threshold = (int)(initialCapacity * loadFactor);
|
||||
}
|
||||
|
||||
@ -288,9 +288,9 @@ public class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
* @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 @@ public class Hashtable<K,V>
|
||||
* @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 @@ public class Hashtable<K,V>
|
||||
* 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 @@ public class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
}
|
||||
|
||||
// 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 @@ public class Hashtable<K,V>
|
||||
}
|
||||
|
||||
// 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 @@ public class Hashtable<K,V>
|
||||
* @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 @@ public class Hashtable<K,V>
|
||||
* 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 class Hashtable<K,V>
|
||||
*/
|
||||
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 class Hashtable<K,V>
|
||||
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 class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
|
||||
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 @@ public class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
|
||||
// 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 @@ public class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
* 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 @@ public class Hashtable<K,V>
|
||||
// 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 @@ public class Hashtable<K,V>
|
||||
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 class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
* 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 class Hashtable<K,V>
|
||||
}
|
||||
|
||||
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 @@ public class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
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 @@ public class Hashtable<K,V>
|
||||
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++;
|
||||
|
@ -327,6 +327,7 @@ public class IdentityHashMap<K,V>
|
||||
*
|
||||
* @see #put(Object, Object)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public V get(Object key) {
|
||||
Object k = maskNull(key);
|
||||
Object[] tab = table;
|
||||
@ -431,7 +432,8 @@ public class IdentityHashMap<K,V>
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
}
|
||||
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 class IdentityHashMap<K,V>
|
||||
*/
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
}
|
||||
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
|
||||
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 class IdentityHashMap<K,V>
|
||||
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 @@ public class IdentityHashMap<K,V>
|
||||
|
||||
// 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 @@ public class IdentityHashMap<K,V>
|
||||
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);
|
||||
|
@ -40,7 +40,7 @@ public class IllegalFormatConversionException extends IllegalFormatException {
|
||||
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
|
||||
|
@ -46,7 +46,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
// 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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
return unseen != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E next() {
|
||||
if (!hasNext())
|
||||
throw new NoSuchElementException();
|
||||
@ -176,11 +177,11 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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;
|
||||
|
||||
|
@ -246,11 +246,12 @@ public class LinkedHashMap<K,V>
|
||||
* 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 class LinkedHashMap<K,V>
|
||||
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 @@ public class LinkedHashMap<K,V>
|
||||
* 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);
|
||||
|
@ -61,12 +61,12 @@ package java.util;
|
||||
*/
|
||||
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<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -449,6 +449,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
* 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 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
(forgetMeNot != null && !forgetMeNot.isEmpty());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E next() {
|
||||
if (expectedModCount != modCount)
|
||||
throw new ConcurrentModificationException();
|
||||
@ -571,8 +573,10 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
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 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
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 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
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 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
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 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
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 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
queue[k] = key;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void siftDownUsingComparator(int k, E x) {
|
||||
int half = size >>> 1;
|
||||
while (k < half) {
|
||||
@ -708,6 +717,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
* 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]);
|
||||
|
@ -824,7 +824,7 @@ class Properties extends Hashtable<Object,Object> {
|
||||
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 @@ class Properties extends Hashtable<Object,Object> {
|
||||
* @see #stringPropertyNames
|
||||
*/
|
||||
public Enumeration<?> propertyNames() {
|
||||
Hashtable h = new Hashtable();
|
||||
Hashtable<String,Object> h = new Hashtable<>();
|
||||
enumerate(h);
|
||||
return h.keys();
|
||||
}
|
||||
@ -1026,10 +1026,10 @@ class Properties extends Hashtable<Object,Object> {
|
||||
*/
|
||||
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 @@ class Properties extends Hashtable<Object,Object> {
|
||||
*/
|
||||
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 @@ class Properties extends Hashtable<Object,Object> {
|
||||
* @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 @@ class Properties extends Hashtable<Object,Object> {
|
||||
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) {
|
||||
|
@ -442,7 +442,7 @@ implements Serializable
|
||||
* 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 @@ implements Serializable
|
||||
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 @@ implements Serializable
|
||||
perms.put(propName, new PropertyPermission(propName, actions));
|
||||
}
|
||||
} else {
|
||||
perms.put(propName, permission);
|
||||
perms.put(propName, pp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,7 +533,7 @@ implements Serializable
|
||||
// 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 @@ implements Serializable
|
||||
//System.out.println("check "+name);
|
||||
|
||||
synchronized (this) {
|
||||
x = (PropertyPermission) perms.get(name);
|
||||
x = perms.get(name);
|
||||
}
|
||||
|
||||
if (x != null) {
|
||||
@ -570,7 +570,7 @@ implements Serializable
|
||||
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 @@ implements Serializable
|
||||
*
|
||||
* @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 @@ implements Serializable
|
||||
// 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 @@ implements Serializable
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
*/
|
||||
private long elements = 0L;
|
||||
|
||||
RegularEnumSet(Class<E>elementType, Enum[] universe) {
|
||||
RegularEnumSet(Class<E>elementType, Enum<?>[] universe) {
|
||||
super(elementType, universe);
|
||||
}
|
||||
|
||||
@ -96,6 +96,7 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
return unseen != 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E next() {
|
||||
if (unseen == 0)
|
||||
throw new NoSuchElementException();
|
||||
@ -139,11 +140,11 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
typeCheck(e);
|
||||
|
||||
long oldElements = elements;
|
||||
elements |= (1L << ((Enum)e).ordinal());
|
||||
elements |= (1L << ((Enum<?>)e).ordinal());
|
||||
return elements != oldElements;
|
||||
}
|
||||
|
||||
@ -173,12 +174,12 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
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;
|
||||
|
@ -294,7 +294,8 @@ public abstract class ResourceBundle {
|
||||
/**
|
||||
* 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 @@ public abstract class ResourceBundle {
|
||||
* 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 @@ public abstract class ResourceBundle {
|
||||
return cl;
|
||||
}
|
||||
|
||||
private static native Class[] getClassContext();
|
||||
private static native Class<?>[] getClassContext();
|
||||
|
||||
/**
|
||||
* A wrapper of ClassLoader.getSystemClassLoader().
|
||||
|
@ -218,20 +218,20 @@ public final class ServiceLoader<S>
|
||||
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 @@ public final class ServiceLoader<S>
|
||||
// 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 @@ public final class ServiceLoader<S>
|
||||
// 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;
|
||||
|
@ -428,7 +428,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
||||
// 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 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
||||
|
||||
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;
|
||||
|
@ -307,7 +307,7 @@ public class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
* 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 @@ public class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
* @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 class TreeMap<K,V>
|
||||
*/
|
||||
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 class TreeMap<K,V>
|
||||
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 class TreeMap<K,V>
|
||||
*/
|
||||
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 @@ public class TreeMap<K,V>
|
||||
* @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 @@ public class TreeMap<K,V>
|
||||
* @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 class TreeMap<K,V>
|
||||
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 class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
}
|
||||
|
||||
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 class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
return tailSet(fromElement, true);
|
||||
}
|
||||
public NavigableSet<E> descendingSet() {
|
||||
return new KeySet(m.descendingMap());
|
||||
return new KeySet<>(m.descendingMap());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1184,6 +1187,7 @@ public class TreeMap<K,V>
|
||||
/**
|
||||
* 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 class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
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 class TreeMap<K,V>
|
||||
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 class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
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 @@ public class TreeMap<K,V>
|
||||
* @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 @@ public class TreeMap<K,V>
|
||||
* @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 @@ public class TreeMap<K,V>
|
||||
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;
|
||||
|
@ -302,7 +302,7 @@ public class TreeSet<E> extends AbstractSet<E>
|
||||
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 @@ public class TreeSet<E> extends AbstractSet<E>
|
||||
*
|
||||
* @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 @@ public class TreeSet<E> extends AbstractSet<E>
|
||||
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
|
||||
|
@ -186,7 +186,7 @@ public class WeakHashMap<K,V>
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Entry<K,V>[] newTable(int n) {
|
||||
return (Entry<K,V>[]) new Entry[n];
|
||||
return (Entry<K,V>[]) new Entry<?,?>[n];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -759,16 +759,19 @@ public final class Matcher implements MatchResult {
|
||||
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 == '{') {
|
||||
|
@ -371,7 +371,7 @@ public class BorderFactory
|
||||
/**
|
||||
* 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 @@ public class BorderFactory
|
||||
/**
|
||||
* 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 @@ public class BorderFactory
|
||||
|
||||
/**
|
||||
* 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 @@ public class BorderFactory
|
||||
*<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 @@ public class BorderFactory
|
||||
*<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 @@ public class BorderFactory
|
||||
*<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
|
||||
|
@ -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 @@ class SynthComboPopup extends BasicComboPopup {
|
||||
*
|
||||
* @see #createList
|
||||
*/
|
||||
@Override
|
||||
protected void configureList() {
|
||||
list.setFont( comboBox.getFont() );
|
||||
list.setCellRenderer( comboBox.getRenderer() );
|
||||
@ -67,4 +64,27 @@ class SynthComboPopup extends BasicComboPopup {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import java.text.Bidi;
|
||||
|
||||
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 @@ public abstract class AbstractDocument implements Document, Serializable {
|
||||
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 @@ public abstract class AbstractDocument implements Document, Serializable {
|
||||
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 @@ public abstract class AbstractDocument implements Document, Serializable {
|
||||
*/
|
||||
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 abstract class AbstractDocument implements Document, Serializable {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public class DefaultEditorKit extends EditorKit {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import sun.util.logging.PlatformLogger;
|
||||
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 @@ public final class AppContext {
|
||||
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,21 +219,11 @@ public final class AppContext {
|
||||
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.
|
||||
*/
|
||||
@ -243,7 +243,7 @@ public final class AppContext {
|
||||
* @since 1.2
|
||||
*/
|
||||
AppContext(ThreadGroup threadGroup) {
|
||||
numAppContexts++;
|
||||
numAppContexts.incrementAndGet();
|
||||
|
||||
this.threadGroup = threadGroup;
|
||||
threadGroup2appContext.put(threadGroup, this);
|
||||
@ -278,7 +278,7 @@ public final class AppContext {
|
||||
* @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 @@ public final class AppContext {
|
||||
this.table.clear(); // Clear out the Hashtable to ease garbage collection
|
||||
}
|
||||
|
||||
numAppContexts--;
|
||||
numAppContexts.decrementAndGet();
|
||||
|
||||
mostRecentKeyValue = null;
|
||||
}
|
||||
@ -804,7 +804,7 @@ public final class AppContext {
|
||||
return getAppContext().isDisposed();
|
||||
}
|
||||
public boolean isMainAppContext() {
|
||||
return (numAppContexts == 1);
|
||||
return (numAppContexts.get() == 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1125,6 +1125,16 @@ public abstract class SunToolkit extends Toolkit
|
||||
return InputEvent.ALT_MASK;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}.
|
||||
|
@ -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 @@ public abstract class ImageWatched {
|
||||
if (iw != null && !isWatcher(iw)) {
|
||||
watcherList = new WeakLink(iw, watcherList);
|
||||
}
|
||||
watcherList = watcherList.removeWatcher(null);
|
||||
}
|
||||
|
||||
public synchronized boolean isWatcher(ImageObserver iw) {
|
||||
|
@ -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 @@ class DatagramChannelImpl
|
||||
|
||||
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
|
||||
|
@ -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 @@ class ServerSocketChannelImpl
|
||||
|
||||
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);
|
||||
|
@ -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 @@ class SocketChannelImpl
|
||||
// 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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user