# HG changeset patch # User jlaskey # Date 1360013398 14400 # Node ID 41654275896d98bae5f8f1dd0d10358247b8ea00 # Parent a8bbd962f34a915043f6c7aa51e73bbd61d6bbf8# Parent e202f43a8b8a3944fffdccb27a434d34a159c391 Merge diff -r a8bbd962f34a -r 41654275896d .hgtags --- a/.hgtags Mon Jan 28 16:29:10 2013 -0400 +++ b/.hgtags Mon Feb 04 17:29:58 2013 -0400 @@ -195,3 +195,4 @@ 2a5af0f766d0acd68a81fb08fe11fd66795f86af jdk8-b71 32a57e645e012a1f0665c075969ca598e0dbb948 jdk8-b72 733885f57e14cc27f5a5ff0dffe641d2fa3c704a jdk8-b73 +57d5d954462831ac353a1f40d3bb05ddb4620952 jdk8-b74 diff -r a8bbd962f34a -r 41654275896d make/Makefile --- a/make/Makefile Mon Jan 28 16:29:10 2013 -0400 +++ b/make/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -237,6 +237,9 @@ ifeq ($(PLATFORM), macosx) SUBDIRS += apple endif +ifeq ($(PLATFORM), windows) + SUBDIRS += bridge +endif SUBDIRS_tools = launchers SUBDIRS_misc = org jpda diff -r a8bbd962f34a -r 41654275896d make/bridge/AccessBridgeJava/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/AccessBridgeJava/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,93 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building AccessBridge +# +BUILDDIR = ../.. +PRODUCT = java +PACKAGE = com.sun.java.accessibility + +include $(BUILDDIR)/common/Defs.gmk +JARFILE = $(EXTDIR)/access-bridge$(ABSUFFIX).jar + +ifeq ($(ARCH_DATA_MODEL), 64) + ABPLATFORM = 64bit + ABSUFFIX = -64 +else +ifeq ($(ARCH_DATA_MODEL), 32) +ifdef ABLEGACY + ABSUFFIX = + ABPLATFORM = legacy +else + ABPLATFORM = 32bit + ABSUFFIX = -32 +endif +endif +endif + +# +# Java files to compile. +# +FILES_java = com/sun/java/accessibility/AccessBridge.java + +# +# Location for the newly built classfiles. +# +CLASSDESTDIR = $(TEMPDIR)/classes + +# +# Rules +# +CLASSDESTDIR = $(TEMPDIR)/classes + +FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class) + +build: prebuild + +prebuild: + $(CP) $(CLOSED_PLATFORM_SRC)/classes/com/sun/java/accessibility/$(ABPLATFORM)/AccessBridge.java \ + $(CLOSED_PLATFORM_SRC)/classes/com/sun/java/accessibility + +all : build $(JARFILE) + +# +# JAR file +# +$(JARFILE): \ + $(FILES_class) + $(BOOT_JAR_CMD) -cf $(JARFILE) \ + -C $(CLASSDESTDIR) com \ + $(BOOT_JAR_JFLAGS) + @$(java-vm-cleanup) + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk + +clean clobber:: + $(RM) -r $(CLASSDESTDIR) \ + $(EXTDIR)/$(JARFILE) diff -r a8bbd962f34a -r 41654275896d make/bridge/JAWTAccessBridge/Files_cpp.gmk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/JAWTAccessBridge/Files_cpp.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,29 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Native files to compile. +FILES_cpp = \ + JAWTAccessBridge.cpp diff -r a8bbd962f34a -r 41654275896d make/bridge/JAWTAccessBridge/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/JAWTAccessBridge/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,69 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building JAWTAccessBridge +# + +BUILDDIR = ../.. +LIBRARY = JAWTAccessBridge$(ABSUFFIX) +include $(BUILDDIR)/common/Defs.gmk + +# Indicate we want the C++ compiler to do the linking. +CPLUSPLUSLIBRARY=true + +ifeq ($(ARCH_DATA_MODEL), 64) + ABSUFFIX = -64 + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_64 + ABRIDGE_MACHINE=X64 +else +ifeq ($(ARCH_DATA_MODEL), 32) + ABRIDGE_MACHINE=I386 +ifdef ABLEGACY + ABSUFFIX = + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_LEGACY +else + ABSUFFIX = -32 + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_32 +endif +endif +endif + +include FILES_cpp.gmk + +VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc + +OTHER_CPPFLAGS += -D$(ACCESSBRIDGE_ARCH) -I "$(INCLUDEDIR)" -I "$(PLATFORM_INCLUDE)" +LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ + uuid.lib odbc32.lib odbccp32.lib /subsystem:windows /dll /incremental:no /machine:$(ABRIDGE_MACHINE) \ + /def:$(CLOSED_PLATFORM_SRC)/native/sun/bridge/JAWTAccessBridge.DEF /libpath:"$(LIBDIR)" + +# +# Rules +# +include $(BUILDDIR)/common/Library.gmk + +vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.RC $(CLOSED_PLATFORM_SRC)/native/sun/bridge diff -r a8bbd962f34a -r 41654275896d make/bridge/Jabswitch/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/Jabswitch/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,63 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building jabswitch.exe +# + +BUILDDIR = ../.. +PROGRAM = jabswitch +include $(BUILDDIR)/common/Defs.gmk + +# Indicate we want the C++ compiler to do the linking. +CPLUSPLUSLIBRARY=true + +VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc +VERSIONRES = $(TEMPDIR)/AccessBridgeStatusWindow.res + +JAB_EXE= $(TEMPDIR)/jabswitch.exe + +JAB_SRC = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/jabswitch.cpp + +JAB_MANIFEST_INP = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/jabswitch.manifest +JAB_MANIFEST_OUT = $(TEMPDIR)/jabswitch.exe.intermediate.manifest + +RC_FLAGS += /fo "$(VERSIONRES)" +OTHER_CPPFLAGS += /MD /Fo"$(TEMPDIR)/" /Fd"$(TEMPDIR)/" /analyze- /Od /Gd /nologo /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /RTC1 /W3 /ZI /Zc:wchar_t /EHsc +LDDFLAGS += Advapi32.lib Version.lib User32.lib + +all: buildexe copyfilejab + +buildexe : + $(CD) $(TEMPDIR) + $(RC) $(RC_FLAGS) $(VERSIONINFO_RESOURCE) + $(CC) $(CPPFLAGS) $(JAB_SRC) $(LDDFLAGS) $(VERSIONRES) -o $(JAB_EXE) + $(MT) /nologo /verbose /manifest $(JAB_MANIFEST_INP) /outputresource:$(JAB_EXE) + +copyfilejab : + $(CP) $(JAB_EXE) $(BINDIR) + +vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.rc $(CLOSED_PLATFORM_SRC)/native/sun/bridge diff -r a8bbd962f34a -r 41654275896d make/bridge/Jaccess/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/Jaccess/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,85 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building jaccess +# +BUILDDIR = ../.. +PRODUCT = java +PACKAGE = com.sun.java.accessibility.jaccess + +include $(BUILDDIR)/common/Defs.gmk +JARFILE = $(EXTDIR)/jaccess.jar + +# +# Java files to compile. +# +#AUTO_FILES_JAVA_DIRS = $(CLOSED_PLATFORM_SRC)/bridge +FILES_java = \ + com/sun/java/accessibility/util/AccessibilityEventMonitor.java \ + com/sun/java/accessibility/util/AccessibilityListenerList.java \ + com/sun/java/accessibility/util/AWTEventMonitor.java \ + com/sun/java/accessibility/util/EventID.java \ + com/sun/java/accessibility/util/EventQueueMonitor.java \ + com/sun/java/accessibility/util/GUIInitializedListener.java \ + com/sun/java/accessibility/util/GUIInitializedMulticaster.java \ + com/sun/java/accessibility/util/SwingEventMonitor.java \ + com/sun/java/accessibility/util/TopLevelWindowListener.java \ + com/sun/java/accessibility/util/TopLevelWindowMulticaster.java \ + com/sun/java/accessibility/util/Translator.java \ + com/sun/java/accessibility/util/java/awt/ButtonTranslator.java \ + com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java \ + com/sun/java/accessibility/util/java/awt/LabelTranslator.java \ + com/sun/java/accessibility/util/java/awt/ListTranslator.java \ + com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java + +# +# Rules +# +CLASSDESTDIR = $(TEMPDIR)/classes + +FILES_class = $(FILES_java:%.java=$(CLASSDESTDIR)/%.class) + +all : build $(JARFILE) + +# +# JAR file +# +$(JARFILE): \ + $(FILES_class) + $(BOOT_JAR_CMD) -cf $(JARFILE) \ + -C $(CLASSDESTDIR) com \ + $(BOOT_JAR_JFLAGS) + @$(java-vm-cleanup) + + +# +# Rules +# +include $(BUILDDIR)/common/Classes.gmk + +clean clobber:: + $(RM) -r $(CLASSDESTDIR) \ + $(EXTDIR)/$(JARFILE) diff -r a8bbd962f34a -r 41654275896d make/bridge/JavaAccessBridge/Files_cpp.gmk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/JavaAccessBridge/Files_cpp.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,33 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Native files to compile. +FILES_cpp = \ + AccessBridgeATInstance.cpp \ + AccessBridgeDebug.cpp \ + AccessBridgeJavaEntryPoints.cpp \ + AccessBridgeMessages.cpp \ + JavaAccessBridge.cpp diff -r a8bbd962f34a -r 41654275896d make/bridge/JavaAccessBridge/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/JavaAccessBridge/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,90 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building JavaAccessBridge.DLL +# + +BUILDDIR = ../.. +LIBRARY = JavaAccessBridge$(ABSUFFIX) +include $(BUILDDIR)/common/Defs.gmk + +# Indicate we want the C++ compiler to do the linking. +CPLUSPLUSLIBRARY=true + +ifeq ($(ARCH_DATA_MODEL), 64) + ABSUFFIX = -64 + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_64 + ABRIDGE_MACHINE=X64 +else +ifeq ($(ARCH_DATA_MODEL), 32) + ABRIDGE_MACHINE=I386 +ifdef ABLEGACY + ABSUFFIX = + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_LEGACY +else + ABSUFFIX = -32 + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_32 +endif +endif +endif + +include FILES_cpp.gmk + +PLATFORM_INCLUDE_BRIDGE = $(PLATFORM_INCLUDE)/bridge + +VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc + +OTHER_CPPFLAGS += -D$(ACCESSBRIDGE_ARCH) -I "$(INCLUDEDIR)" -I "$(PLATFORM_INCLUDE)" +LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib \ + odbc32.lib odbccp32.lib /subsystem:windows /dll /incremental:no /machine:$(ABRIDGE_MACHINE) \ + /def:$(CLOSED_PLATFORM_SRC)/native/sun/bridge/JavaAccessBridge.DEF /libpath:"$(LIBDIR)" + +all : build postbuild + +postbuild : + $(MKDIR) -p $(PLATFORM_INCLUDE_BRIDGE) + $(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/accessibility.properties $(LIBDIR) + $(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeCallbacks.h $(PLATFORM_INCLUDE_BRIDGE) + $(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeCalls.h $(PLATFORM_INCLUDE_BRIDGE) + $(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgePackages.h $(PLATFORM_INCLUDE_BRIDGE) + $(CP) $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeCalls.c $(PLATFORM_INCLUDE_BRIDGE) + +# +# Rules +# +include $(BUILDDIR)/common/Library.gmk + +vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.DEF $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.rc $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.c $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.h $(CLOSED_PLATFORM_SRC)/native/sun/bridge + +# +# Extra clean rule. +# +clean clobber:: + $(RM) $(FILES_h) diff -r a8bbd962f34a -r 41654275896d make/bridge/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,65 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building Java Access Bridge +# + +BUILDDIR = .. +include $(BUILDDIR)/common/Defs.gmk + +# +# +ifndef OPENJDK +ifeq ($(PLATFORM), windows) +include $(BUILDDIR)/common/Subdirs.gmk + +# +# build for 32 and 64 bit (new api) +# +SUBDIRS = Jaccess JavaAccessBridge WindowsAccessBridge JAWTAccessBridge AccessBridgeJava Jabswitch +# +# build for legacy +# +ifeq ($(ARCH_DATA_MODEL), 32) +OTHERSUBDIRS_MAKEFLAGS += ABLEGACY=true +OTHERSUBDIRS = JavaAccessBridge WindowsAccessBridge JAWTAccessBridge AccessBridgeJava +endif + +ifeq ($(ARCH_DATA_MODEL), 32) +all build clean clobber :: + $(SUBDIRS-loop) + $(OTHERSUBDIRS-loop) +else +all build clean clobber :: + $(SUBDIRS-loop) +endif + +clean:: + $(RM) -r $(CLASSBINDIR) $(CLASSBINDIR) + +endif # PLATFORM +endif #OPENJDK + diff -r a8bbd962f34a -r 41654275896d make/bridge/WindowsAccessBridge/Files_cpp.gmk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/WindowsAccessBridge/Files_cpp.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,35 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Native files to compile. +FILES_cpp = \ + AccessBridgeJavaVMInstance.cpp \ + AccessBridgeMessageQueue.cpp \ + AccessBridgeMessages.cpp \ + AccessBridgeWindowsEntryPoints.cpp \ + WinAccessBridge.cpp \ + AccessBridgeDebug.cpp \ + AccessBridgeEventHandler.cpp diff -r a8bbd962f34a -r 41654275896d make/bridge/WindowsAccessBridge/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/bridge/WindowsAccessBridge/Makefile Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,71 @@ +# +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# +# Makefile for building WindowsAccessBridge.dll +# + +BUILDDIR = ../.. +LIBRARY = WindowsAccessBridge$(ABSUFFIX) +include $(BUILDDIR)/common/Defs.gmk + +# Indicate we want the C++ compiler to do the linking. +CPLUSPLUSLIBRARY=true + +ifeq ($(ARCH_DATA_MODEL), 64) + ABSUFFIX = -64 + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_64 + ABRIDGE_MACHINE=X64 +else +ifeq ($(ARCH_DATA_MODEL), 32) + ABRIDGE_MACHINE=I386 +ifdef ABLEGACY + ABSUFFIX = + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_LEGACY +else + ABSUFFIX = -32 + ACCESSBRIDGE_ARCH = ACCESSBRIDGE_ARCH_32 +endif +endif +endif + +include FILES_cpp.gmk + +VERSIONINFO_RESOURCE = $(CLOSED_PLATFORM_SRC)/native/sun/bridge/AccessBridgeStatusWindow.rc + +OTHER_CPPFLAGS += -MT -D$(ACCESSBRIDGE_ARCH) -I "$(INCLUDEDIR)" -I "$(PLATFORM_INCLUDE)" +LDLIBS += kernel32.lib user32.lib gdi32.lib winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib \ + ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /subsystem:windows /dll /incremental:no /machine:$(ABRIDGE_MACHINE) \ + /def:$(CLOSED_PLATFORM_SRC)/native/sun/bridge/WinAccessBridge.DEF /libpath:"$(LIBDIR)" + + +# +# Rules +# +include $(BUILDDIR)/common/Library.gmk + +vpath %.cpp $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.DEF $(CLOSED_PLATFORM_SRC)/native/sun/bridge +vpath %.rc $(CLOSED_PLATFORM_SRC)/native/sun/bridge diff -r a8bbd962f34a -r 41654275896d make/netbeans/common/architectures/arch-x86_64.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/netbeans/common/architectures/arch-x86_64.properties Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,32 @@ +# +# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# - Neither the name of Oracle nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +arch=x86_64 diff -r a8bbd962f34a -r 41654275896d make/netbeans/common/architectures/name-Macosx.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make/netbeans/common/architectures/name-Macosx.properties Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,32 @@ +# +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# - Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# - Neither the name of Oracle nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +platform=macosx diff -r a8bbd962f34a -r 41654275896d make/netbeans/common/java-data-native.ent --- a/make/netbeans/common/java-data-native.ent Mon Jan 28 16:29:10 2013 -0400 +++ b/make/netbeans/common/java-data-native.ent Mon Feb 04 17:29:58 2013 -0400 @@ -39,11 +39,11 @@ ${bootstrap.jdk}/jre/lib/rt.jar ${root}/build/${platform}-${arch}/classes ${root}/build/${platform}-${arch}/docs/api - 1.7 + 1.8 ${root}/test - 1.7 + 1.8 diff -r a8bbd962f34a -r 41654275896d make/netbeans/common/java-data-no-native.ent --- a/make/netbeans/common/java-data-no-native.ent Mon Jan 28 16:29:10 2013 -0400 +++ b/make/netbeans/common/java-data-no-native.ent Mon Feb 04 17:29:58 2013 -0400 @@ -37,11 +37,11 @@ ${bootstrap.jdk}/jre/lib/rt.jar ${root}/build/${platform}-${arch}/classes ${root}/build/${platform}-${arch}/docs/api - 1.7 + 1.8 ${root}/test - 1.7 + 1.8 diff -r a8bbd962f34a -r 41654275896d make/netbeans/common/make.xml --- a/make/netbeans/common/make.xml Mon Jan 28 16:29:10 2013 -0400 +++ b/make/netbeans/common/make.xml Mon Feb 04 17:29:58 2013 -0400 @@ -33,7 +33,7 @@ - + @@ -42,6 +42,11 @@ + + + + + diff -r a8bbd962f34a -r 41654275896d make/netbeans/common/shared.xml --- a/make/netbeans/common/shared.xml Mon Jan 28 16:29:10 2013 -0400 +++ b/make/netbeans/common/shared.xml Mon Feb 04 17:29:58 2013 -0400 @@ -85,6 +85,9 @@ + + + @@ -126,10 +129,6 @@ - - - - diff -r a8bbd962f34a -r 41654275896d makefiles/Bundles.gmk --- a/makefiles/Bundles.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/Bundles.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -68,24 +68,25 @@ endif -JDK_FILE_LIST := $(shell $(FIND) $(JDK_IMAGE_DIR) ! -type d) -JRE_FILE_LIST := $(shell $(FIND) $(JRE_IMAGE_DIR) ! -type d) +JDK_FILE_LIST := $(shell $(FIND) $(JDK_IMAGE_DIR)) +JRE_FILE_LIST := $(shell $(FIND) $(JRE_IMAGE_DIR)) -JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR),$(JDK_BUNDLE_DIR)/Home,$(JDK_FILE_LIST)) -JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR),$(JRE_BUNDLE_DIR)/Home,$(JRE_FILE_LIST)) +JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR)/,$(JDK_BUNDLE_DIR)/Home/,$(JDK_FILE_LIST)) +JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR)/,$(JRE_BUNDLE_DIR)/Home/,$(JRE_FILE_LIST)) # The old builds implementation of this did not preserve symlinks so # make sure they are followed and the contents copied instead. -# To fix this, just replace copy with install-file macro. +# To fix this, remove -L +# Copy empty directories (jre/lib/applet). $(JDK_BUNDLE_DIR)/Home/%: $(JDK_IMAGE_DIR)/% $(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@) $(MKDIR) -p $(@D) - $(CP) -f -R -L '$<' '$@' + if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) -f -R -L '$<' '$@'; fi $(JRE_BUNDLE_DIR)/Home/%: $(JRE_IMAGE_DIR)/% $(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@) $(MKDIR) -p $(@D) - $(CP) -f -R -L '$<' '$@' + if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) -f -R -L '$<' '$@'; fi $(JDK_BUNDLE_DIR)/MacOS/libjli.dylib: $(ECHO) Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@) diff -r a8bbd962f34a -r 41654275896d makefiles/CompileJavaClasses.gmk --- a/makefiles/CompileJavaClasses.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/CompileJavaClasses.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -59,6 +59,12 @@ # This gets built on unix platforms implicitly in the old build even though # it's excluded in the closed build. EXCLUDES+=sun/java2d/pisces + + # AccessBridge is compiled separately below. + EXFILES += AccessBridge.java \ + com/sun/java/accessibility/util/java/awt/ChoiceTranslator.java + # This seems to never be built + EXCLUDES += com/sun/java/accessibility/extensions endif endif @@ -248,10 +254,8 @@ # Now we have COPY_PATTERNS, COPY_FILES and COPY_EXTRA ifndef OPENJDK - CLOSED_SRC_DIRS:=$(JDK_TOPDIR)/src/closed/share/classes - ifneq ($(OPENJDK_TARGET_OS_API_DIR),windows) - CLOSED_SRC_DIRS += $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS_API_DIR)/classes - endif + CLOSED_SRC_DIRS:=$(JDK_TOPDIR)/src/closed/share/classes \ + $(JDK_TOPDIR)/src/closed/$(OPENJDK_TARGET_OS_API_DIR)/classes endif MACOSX_SRC_DIRS := @@ -364,8 +368,44 @@ ########################################################################################## -# copy with -a to preserve timestamps so dependencies down the line aren't messed up +ifndef OPENJDK +ifeq ($(OPENJDK_TARGET_OS), windows) +ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + $(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_32,\ + SETUP:=GENERATE_JDKBYTECODE,\ + JAVAC_FLAGS:=-cp $(JDK_OUTPUTDIR)/classes,\ + SRC:=$(JDK_OUTPUTDIR)/gensrc_ab/32bit,\ + BIN:=$(JDK_OUTPUTDIR)/classes_ab/32bit)) + + $(BUILD_ACCESSBRIDGE_32): $(BUILD_JDK) + + $(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_LEGACY,\ + SETUP:=GENERATE_JDKBYTECODE,\ + JAVAC_FLAGS:=-cp $(JDK_OUTPUTDIR)/classes,\ + SRC:=$(JDK_OUTPUTDIR)/gensrc_ab/legacy,\ + BIN:=$(JDK_OUTPUTDIR)/classes_ab/legacy)) + + $(BUILD_ACCESSBRIDGE_LEGACY): $(BUILD_JDK) + +else + + $(eval $(call SetupJavaCompilation,BUILD_ACCESSBRIDGE_64,\ + SETUP:=GENERATE_JDKBYTECODE,\ + JAVAC_FLAGS:=-cp $(JDK_OUTPUTDIR)/classes,\ + SRC:=$(JDK_OUTPUTDIR)/gensrc_ab/64bit,\ + BIN:=$(JDK_OUTPUTDIR)/classes_ab/64bit)) + + $(BUILD_ACCESSBRIDGE_64): $(BUILD_JDK) + +endif +endif +endif + +########################################################################################## + all: $(BUILD_JDK) $(BUILD_ALTCLASSES) $(BUILD_JOBJC) $(BUILD_JOBJC_HEADERS) $(COPY_EXTRA) \ - $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin + $(JDK_OUTPUTDIR)/classes/META-INF/services/com.sun.tools.xjc.Plugin \ + $(BUILD_ACCESSBRIDGE_32) $(BUILD_ACCESSBRIDGE_64) \ + $(BUILD_ACCESSBRIDGE_LEGACY) .PHONY: all diff -r a8bbd962f34a -r 41654275896d makefiles/CompileLaunchers.gmk --- a/makefiles/CompileLaunchers.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/CompileLaunchers.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -596,6 +596,34 @@ endif ########################################################################################## +# jabswitch + +ifndef OPENJDK +ifeq ($(OPENJDK_TARGET_OS),windows) + + $(eval $(call SetupNativeCompilation,BUILD_JABSWITCH,\ + SRC:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge,\ + INCLUDE_FILES:=jabswitch.cpp,\ + LANG:=C++,\ + CFLAGS:=$(filter-out -Zc:wchar_t-,$(CFLAGS_JDKEXE)) -Zc:wchar_t \ + -analyze- -Od -Gd -D_WINDOWS \ + -D_UNICODE -DUNICODE -RTC1 -EHsc,\ + LDFLAGS:=$(LDFLAGS_JDKEXE) \ + Advapi32.lib Version.lib User32.lib,\ + OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/jabswitch,\ + OUTPUT_DIR:=$(JDK_OUTPUTDIR)/bin,\ + PROGRAM:=jabswitch,\ + DEBUG_SYMBOLS:=true,\ + VERSIONINFO_RESOURCE:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/AccessBridgeStatusWindow.rc,\ + RC_FLAGS:=$(RC_FLAGS),\ + MANIFEST:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/jabswitch.manifest)) + + BUILD_LAUNCHERS += $(BUILD_JABSWITCH) + +endif +endif + +########################################################################################## $(BUILD_LAUNCHERS) : $(JDK_TOPDIR)/makefiles/CompileLaunchers.gmk diff -r a8bbd962f34a -r 41654275896d makefiles/CompileNativeLibraries.gmk --- a/makefiles/CompileNativeLibraries.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/CompileNativeLibraries.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -3296,6 +3296,97 @@ ########################################################################################## +ifndef OPENJDK +ifeq ($(OPENJDK_TARGET_OS), windows) + + ACCESSBRIDGE_SRCDIR:=$(JDK_TOPDIR)/src/closed/windows/native/sun/bridge + + define SetupAccessBridge + # Parameter 1 Suffix + # Parameter 2 Machine + # Parameter 3 ACCESSBRIDGE_ARCH_ suffix + + $(call SetupNativeCompilation,BUILD_JAWTACCESSBRIDGE$1,\ + LIBRARY=JAWTAccessBridge$1,\ + OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ + SRC:=$(ACCESSBRIDGE_SRCDIR),\ + INCLUDE_FILES:=JAWTAccessBridge.cpp,\ + LANG:=C++,\ + OPTIMIZATION:=LOW,\ + CFLAGS:=$(CFLAGS_JDKLIB) \ + -DACCESSBRIDGE_ARCH_$3,\ + LDFLAGS:=$(LDFLAGS_JDKLIB) kernel32.lib user32.lib gdi32.lib \ + winspool.lib jawt.lib comdlg32.lib advapi32.lib shell32.lib \ + ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \ + -subsystem:windows -machine:$2 \ + -def:$(ACCESSBRIDGE_SRCDIR)/JAWTAccessBridge.DEF,\ + VERSIONINFO_RESOURCE:=$(ACCESSBRIDGE_SRCDIR)/AccessBridgeStatusWindow.rc,\ + RC_FLAGS:=$(RC_FLAGS),\ + OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawtaccessbridge$1,\ + DEBUG_SYMBOLS:=true) + + $$(BUILD_JAWTACCESSBRIDGE$1): $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX) + + $(call SetupNativeCompilation,BUILD_JAVAACCESSBRIDGE$1,\ + LIBRARY=JavaAccessBridge$1,\ + OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ + SRC:=$(ACCESSBRIDGE_SRCDIR),\ + INCLUDE_FILES:=AccessBridgeATInstance.cpp AccessBridgeDebug.cpp \ + AccessBridgeJavaEntryPoints.cpp \ + AccessBridgeMessages.cpp JavaAccessBridge.cpp,\ + LANG:=C++,\ + OPTIMIZATION:=LOW,\ + CFLAGS:=$(CFLAGS_JDKLIB) \ + -DACCESSBRIDGE_ARCH_$3,\ + LDFLAGS:=$(LDFLAGS_JDKLIB) kernel32.lib user32.lib gdi32.lib \ + winspool.lib comdlg32.lib advapi32.lib shell32.lib \ + ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \ + -subsystem:windows -machine:$2 \ + -def:$(ACCESSBRIDGE_SRCDIR)/JavaAccessBridge.DEF,\ + VERSIONINFO_RESOURCE:=$(ACCESSBRIDGE_SRCDIR)/AccessBridgeStatusWindow.rc,\ + RC_FLAGS:=$(RC_FLAGS),\ + OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjavaaccessbridge$1,\ + DEBUG_SYMBOLS:=true) + + $(call SetupNativeCompilation,BUILD_WINDOWSACCESSBRIDGE$1,\ + LIBRARY=WindowsAccessBridge$1,\ + OUTPUT_DIR:=$(INSTALL_LIBRARIES_HERE),\ + SRC:=$(ACCESSBRIDGE_SRCDIR),\ + INCLUDE_FILES:=AccessBridgeJavaVMInstance.cpp AccessBridgeMessageQueue.cpp \ + AccessBridgeMessages.cpp AccessBridgeWindowsEntryPoints.cpp \ + WinAccessBridge.cpp AccessBridgeDebug.cpp \ + AccessBridgeEventHandler.cpp,\ + LANG:=C++,\ + OPTIMIZATION:=LOW,\ + CFLAGS:=$(filter-out -MD,$(CFLAGS_JDKLIB)) -MT \ + -DACCESSBRIDGE_ARCH_$3,\ + LDFLAGS:=$(LDFLAGS_JDKLIB) kernel32.lib user32.lib gdi32.lib \ + winspool.lib comdlg32.lib advapi32.lib shell32.lib \ + ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib \ + -subsystem:windows -machine:$2 \ + -def:$(ACCESSBRIDGE_SRCDIR)/WinAccessBridge.DEF,\ + VERSIONINFO_RESOURCE:=$(ACCESSBRIDGE_SRCDIR)/AccessBridgeStatusWindow.rc,\ + RC_FLAGS:=$(RC_FLAGS),\ + OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libwindowsaccessbridge$1,\ + DEBUG_SYMBOLS:=true) + + BUILD_LIBRARIES += $$(BUILD_JAWTACCESSBRIDGE$1) $$(BUILD_JAVAACCESSBRIDGE$1) \ + $$(BUILD_WINDOWSACCESSBRIDGE$1) + + endef + + ifeq ($(OPENJDK_TARGET_CPU_BITS),32) + $(eval $(call SetupAccessBridge,-32,I386,32)) + $(eval $(call SetupAccessBridge,,I386,LEGACY)) + else + $(eval $(call SetupAccessBridge,-64,X64,64)) + endif +endif +endif + + +########################################################################################## + all: $(COPY_FILES) $(BUILD_LIBRARIES) .PHONY: all diff -r a8bbd962f34a -r 41654275896d makefiles/CopyFiles.gmk --- a/makefiles/CopyFiles.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/CopyFiles.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -42,7 +42,7 @@ $(INCLUDEDIR)/jvmticmlr.h \ $(INCLUDEDIR)/classfile_constants.h \ $(INCLUDEDIR)/jawt.h \ - $(OPENJDK_TARGET_OS_INCLUDE)/jni_md.h \ + $(OPENJDK_TARGET_OS_INCLUDE)/jni_md.h \ $(OPENJDK_TARGET_OS_INCLUDE)/jawt_md.h $(INCLUDEDIR)/%.h: $(JDK_TOPDIR)/src/share/javavm/export/%.h @@ -59,6 +59,27 @@ ########################################################################################## +ifndef OPENJDK +ifeq ($(OPENJDK_TARGET_OS), windows) + COPY_FILES += $(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgeCallbacks.h \ + $(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgeCalls.h \ + $(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgePackages.h \ + $(OPENJDK_TARGET_OS_INCLUDE)/bridge/AccessBridgeCalls.c \ + $(JDK_OUTPUTDIR)/lib/accessibility.properties + + $(OPENJDK_TARGET_OS_INCLUDE)/bridge/%: \ + $(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/% + $(install-file) + + $(JDK_OUTPUTDIR)/lib/accessibility.properties: \ + $(JDK_TOPDIR)/src/closed/windows/native/sun/bridge/accessibility.properties + $(install-file) + +endif +endif + +########################################################################################## + LIBDIR = $(JDK_OUTPUTDIR)/lib SERVICETAG_LIBDIR = $(LIBDIR)/servicetag @@ -267,10 +288,12 @@ ifeq ($(OPENJDK_TARGET_OS),windows) MSVCR_TARGET := $(JDK_OUTPUTDIR)/bin/$(notdir $(MSVCR_DLL)) + # Chmod to avoid permission issues if bundles are unpacked on unix platforms. $(MSVCR_TARGET): $(MSVCR_DLL) $(MKDIR) -p $(@D) $(RM) $@ $(CP) $< $@ + $(CHMOD) a+rx $@ COPY_FILES += $(MSVCR_TARGET) endif @@ -317,7 +340,7 @@ $(MKDIR) -p $(@D) $(RM) $(JVMCFG) $(PRINTF) "-client KNOWN\n">$(JVMCFG) - $(PRINTF) "-server IGNORE\n">>$(JVMCFG) + $(PRINTF) "-server ALIASED_TO -client\n">>$(JVMCFG) $(PRINTF) "-hotspot ALIASED_TO -client\n">>$(JVMCFG) $(PRINTF) "-classic WARN\n">>$(JVMCFG) $(PRINTF) "-native ERROR\n">>$(JVMCFG) diff -r a8bbd962f34a -r 41654275896d makefiles/CreateJars.gmk --- a/makefiles/CreateJars.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/CreateJars.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -141,6 +141,7 @@ com/sun/crypto/provider \ com/sun/istack/internal/tools \ com/sun/jarsigner \ + com/sun/java/accessibility \ com/sun/javadoc \ com/sun/jdi \ com/sun/net/ssl/internal/ssl \ @@ -941,6 +942,47 @@ ########################################################################################## +ifndef OPENJDK +ifeq ($(OPENJDK_TARGET_OS), windows) + + $(eval $(call SetupArchive,BUILD_JACCESS_JAR,,\ + SRCS:=$(JDK_OUTPUTDIR)/classes,\ + INCLUDES:=com/sun/java/accessibility/util,\ + JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/jaccess.jar,\ + SKIP_METAINF:=true)) + + JARS += $(IMAGES_OUTPUTDIR)/lib/ext/jaccess.jar + + ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + $(eval $(call SetupArchive,BUILD_ACCESSBRIDGE_32_JAR,,\ + SRCS:=$(JDK_OUTPUTDIR)/classes_ab/32bit $(JDK_OUTPUTDIR)/classes,\ + INCLUDES:=com/sun/java/accessibility,\ + JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/access-bridge-32.jar,\ + SKIP_METAINF:=true)) + + $(eval $(call SetupArchive,BUILD_ACCESSBRIDGE_LEGACY_JAR,,\ + SRCS:=$(JDK_OUTPUTDIR)/classes_ab/legacy $(JDK_OUTPUTDIR)/classes,\ + INCLUDES:=com/sun/java/accessibility,\ + JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/access-bridge.jar,\ + SKIP_METAINF:=true)) + + JARS += $(IMAGES_OUTPUTDIR)/lib/ext/access-bridge-32.jar \ + $(IMAGES_OUTPUTDIR)/lib/ext/access-bridge.jar + else + $(eval $(call SetupArchive,BUILD_ACCESSBRIDGE_64_JAR,,\ + SRCS:=$(JDK_OUTPUTDIR)/classes_ab/64bit $(JDK_OUTPUTDIR)/classes,\ + INCLUDES:=com/sun/java/accessibility,\ + EXCLUDES:=com/sun/java/accessibility/util/java,\ + JAR:=$(IMAGES_OUTPUTDIR)/lib/ext/access-bridge-64.jar,\ + SKIP_METAINF:=true)) + + JARS += $(IMAGES_OUTPUTDIR)/lib/ext/access-bridge-64.jar + endif +endif +endif + +########################################################################################## + # # This is an empty jar (only contains manifest) and fits poorly into framework... # create simple rule instead diff -r a8bbd962f34a -r 41654275896d makefiles/GensrcMisc.gmk --- a/makefiles/GensrcMisc.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/GensrcMisc.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -190,3 +190,36 @@ endif + +########################################################################################## + +ifndef OPENJDK +ifeq ($(OPENJDK_TARGET_OS), windows) + + AB_GENSRC_DIR := $(JDK_OUTPUTDIR)/gensrc_ab + AB_SRC_DIR := $(JDK_TOPDIR)/src/closed/windows/classes/com/sun/java/accessibility + + ifeq ($(OPENJDK_TARGET_CPU_BITS), 32) + $(AB_GENSRC_DIR)/32bit/com/sun/java/accessibility/AccessBridge.java: \ + $(AB_SRC_DIR)/32bit/AccessBridge.java + $(install-file) + + $(AB_GENSRC_DIR)/legacy/com/sun/java/accessibility/AccessBridge.java: \ + $(AB_SRC_DIR)/legacy/AccessBridge.java + $(install-file) + + GENSRC_MISC += $(AB_GENSRC_DIR)/32bit/com/sun/java/accessibility/AccessBridge.java \ + $(AB_GENSRC_DIR)/legacy/com/sun/java/accessibility/AccessBridge.java + + else + $(AB_GENSRC_DIR)/64bit/com/sun/java/accessibility/AccessBridge.java: \ + $(AB_SRC_DIR)/64bit/AccessBridge.java + $(install-file) + + GENSRC_MISC += $(AB_GENSRC_DIR)/64bit/com/sun/java/accessibility/AccessBridge.java + + endif +endif +endif + +########################################################################################## \ No newline at end of file diff -r a8bbd962f34a -r 41654275896d makefiles/GensrcSwing.gmk --- a/makefiles/GensrcSwing.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/GensrcSwing.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -68,7 +68,7 @@ # Dummy variable so far, in the old build system it was false by default SWINGBEAN_DEBUG_FLAG = false # GenDocletBeanInfo is compiled in Tools.gmk and picks up from $(JDK_OUTPUTDIR)/btclasses -$(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) $(JDK_OUTPUTDIR)/gensrc/javax/swing/SwingBeanInfoBase.java $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java $(BUILD_TOOLS) +$(JDK_OUTPUTDIR)/gensrc_no_srczip/_the.generated_beaninfo: $(BEANS_SRC) $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java $(JDK_OUTPUTDIR)/gensrc/sun/swing/BeanInfoUtils.java $(BUILD_TOOLS) $(ECHO) Generating beaninfo $(MKDIR) -p $(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing $(JAVA) -Djava.awt.headless=true -jar $(JAVADOC_JARS) -doclet GenDocletBeanInfo \ @@ -84,7 +84,7 @@ # This file is the part of dt.jar # For some reason it is under $(JDK_TOPDIR)/make/tools/swing-beans/javax/swing # Should it be moved under $(JDK_TOPDIR)/src/share/classes/javax/swing instead? -$(JDK_OUTPUTDIR)/gensrc/javax/swing/SwingBeanInfoBase.java: $(DOCLETSRC_DIR)/javax/swing/SwingBeanInfoBase.java +$(JDK_OUTPUTDIR)/gensrc_no_srczip/javax/swing/SwingBeanInfoBase.java: $(DOCLETSRC_DIR)/javax/swing/SwingBeanInfoBase.java $(MKDIR) -p $(@D) $(CP) $< $@ diff -r a8bbd962f34a -r 41654275896d makefiles/GensrcX11Wrappers.gmk --- a/makefiles/GensrcX11Wrappers.gmk Mon Jan 28 16:29:10 2013 -0400 +++ b/makefiles/GensrcX11Wrappers.gmk Mon Feb 04 17:29:58 2013 -0400 @@ -23,84 +23,95 @@ # questions. # +# This file is responsible for extracting the x11 native struct offsets to +# the xawt Java library. The tool needs to be run on the os/arch that +# will host the final jvm, thus the tool cannot be used when cross compiling. -# This file is responsible for extracting the x11 native struct offsets to -# the xawt Java library. This is done by compiling and running a native -# binary, which dumps output to a text file. The offsets differ on 32 and 64 -# bit systems, so care must be taken here. +# To enable cross compiling, the two versions of the generated offset file, +# sizes.32 and sizes.64 are committed into the source code repository. +# These are the ones used. -# Note: Some of the more complex logic here is most likely not needed anymore. +# However when not cross compiling, the offset generator tool is built and +# run, to verify that it still generates the same sizes.32 and sizes.64. GENSRC_X11WRAPPERS := +# Put temporary c-code and executable to calculate offsets here. +# Also put verification offset file here as well. GENSRC_X11WRAPPERS_TMP := $(JDK_OUTPUTDIR)/gensrc_x11wrappers -GENSRC_X11WRAPPERS_DST := $(JDK_OUTPUTDIR)/gensrc +# Put the generated Java classes used to interface X11 from awt here. +GENSRC_X11WRAPPERS_DST := $(JDK_OUTPUTDIR)/gensrc/sun/awt/X11 -GENSRC_SIZER_SRC := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator +# The pre-calculated offset file are stored here: +GENSRC_SIZER_DIR := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator -# Normal case is to generate version according to target bits -GENSRC_SIZES := sizes.$(OPENJDK_TARGET_CPU_BITS) - +# Normal case is to generate only according to target bits +GENSRC_X11_VERSION := $(OPENJDK_TARGET_CPU_BITS) ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) -ifneq ($(OPENJDK_TARGET_OS), linux) -# On all 64-bit systems except Linux, generate both 32 and 64 bit versions -GENSRC_SIZES := sizes.32 sizes.64 -endif + ifneq ($(OPENJDK_TARGET_OS), linux) + # On all 64-bit systems except Linux, generate both 32 and 64 bit versions + GENSRC_X11_VERSION := 32 64 + endif else -ifeq ($(OPENJDK_TARGET_OS), solaris) -# As a special case, solaris 32-bit also generates the 64-bit version -GENSRC_SIZES := sizes.32 sizes.64 -endif + ifeq ($(OPENJDK_TARGET_OS), solaris) + # As a special case, solaris 32-bit also generates the 64-bit version + GENSRC_X11_VERSION := 32 64 + endif endif -########################################################################################## +GENSRC_X11_SIZES_USED := $(addprefix $(GENSRC_X11WRAPPERS_TMP)/sizes.,$(GENSRC_X11_VERSION)) + +# Copy only the sizes.* files that are actually needed. WrapperGenerator picks up any it finds from the +# file prefix it is given so those not needed need to be hidden. +$(GENSRC_X11WRAPPERS_TMP)/sizes.%: $(GENSRC_SIZER_DIR)/sizes.% + $(MKDIR) -p $(@D) + $(RM) '$@' + $(SORT) $< > $@ -$(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.c : $(GENSRC_SIZER_SRC)/xlibtypes.txt $(BUILD_TOOLS) +# Run the tool on the offset files copied from the source repository to generate several Java classes +# used in awt. +$(JDK_OUTPUTDIR)/gensrc/_the.generated.x11 : $(GENSRC_X11_SIZES_USED) $(BUILD_TOOLS) + $(MKDIR) -p $(GENSRC_X11WRAPPERS_DST) + $(TOOL_WRAPPERGENERATOR) $(GENSRC_X11WRAPPERS_DST) $(GENSRC_SIZER_DIR)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizes + $(TOUCH) $@ + +GENSRC_X11WRAPPERS += $(JDK_OUTPUTDIR)/gensrc/_the.generated.x11 + +ifneq ($(COMPILE_TYPE),cross) + # This is not a cross compile, regenerate the offset file, so that we + # can compare it with the version in the source code repository. + + # Generate the C code for the program that will output the offset file. + $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c : $(GENSRC_SIZER_DIR)/xlibtypes.txt $(BUILD_TOOLS) $(ECHO) "Generating X11 wrapper ($*-bit version)" $(MKDIR) -p $(@D) - $(RM) $@ - $(TOOL_WRAPPERGENERATOR) $(@D) $< "sizer" $* + $(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $* -$(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.c + # Compile the C code into an executable. + $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c $(MKDIR) -p $(@D) - $(RM) $@ $@.tmp - (cd $(@D) && $(BUILD_CC) -m$* -o $@.tmp $< \ + (cd $(@D) && $(CC) -m$* -o $@ $< \ $(X_CFLAGS) \ $(X_LIBS) \ -I$(JDK_OUTPUTDIR)/include \ -I$(JDK_TOPDIR)/src/share/javavm/export \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \ - -I$(JDK_TOPDIR)//src/share/native/common \ + -I$(JDK_TOPDIR)/src/share/native/common \ -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \ -I$(JDK_TOPDIR)/src/solaris/native/sun/awt \ -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \ -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils -lc) - $(MV) $@.tmp $@ + + .PRECIOUS: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c -# Run the generated sizer binary to create the sizes text file -$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.% : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe + # Run the executable create the offset file and check that it is identical + # to the offset file in the source code repository. + $(GENSRC_X11WRAPPERS_TMP)/sizes.%.verification : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe $(MKDIR) -p $(@D) - $(RM) $@ $@.tmp - $< > $@.tmp - $(MV) $@.tmp $@ + $(GENSRC_X11WRAPPERS_TMP)/sizer.$*.exe | $(SORT) > $@.tmp + $(ECHO) Verifying $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp to $(GENSRC_X11WRAPPERS_TMP)/sizes.$* + $(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp $(GENSRC_X11WRAPPERS_TMP)/sizes.$* + mv $@.tmp $@ -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86) - # On solaris-x86 we also need to create the 64-bit version, but we can't run a 64-bit binary - # As a workaround, copy this from a pre-generated file. -$(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386 - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ + GENSRC_X11WRAPPERS += $(GENSRC_X11WRAPPERS_TMP)/sizes.$(OPENJDK_TARGET_CPU_BITS).verification endif -$(GENSRC_X11WRAPPERS_DST)/_the.generated.x11 : $(foreach S,$(GENSRC_SIZES),$(GENSRC_X11WRAPPERS_TMP)/sizer/$(S)) $(BUILD_TOOLS) - $(RM) $@ - $(MKDIR) -p $(@D)/sun/awt/X11 - $(TOOL_WRAPPERGENERATOR) $(@D)/sun/awt/X11 $(GENSRC_SIZER_SRC)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes -ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86_64) - # On solaris-x86_64, as a safety measure, compare the generated file with the checked-in version - $(ECHO) COMPARING $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 and $(GENSRC_SIZER_SRC)/sizes.64-solaris-i386 - $(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 $(GENSRC_SIZER_SRC)/sizes.64-solaris-i386 -endif - $(TOUCH) $@ - -GENSRC_X11WRAPPERS += $(GENSRC_X11WRAPPERS_DST)/_the.generated.x11 diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/com/apple/laf/AquaKeyBindings.java --- a/src/macosx/classes/com/apple/laf/AquaKeyBindings.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/com/apple/laf/AquaKeyBindings.java Mon Feb 04 17:29:58 2013 -0400 @@ -142,6 +142,21 @@ })); } + LateBoundInputMap getPasswordFieldInputMap() { + return new LateBoundInputMap(new SimpleBinding(getTextFieldInputMap().getBindings()), + // nullify all the bindings that may discover space characters in the text + new SimpleBinding(new String[] { + "alt LEFT", null, + "alt KP_LEFT", null, + "alt RIGHT", null, + "alt KP_RIGHT", null, + "shift alt LEFT", null, + "shift alt KP_LEFT", null, + "shift alt RIGHT", null, + "shift alt KP_RIGHT", null, + })); + } + LateBoundInputMap getMultiLineTextInputMap() { return new LateBoundInputMap(new SimpleBinding(commonTextEditorBindings), new SimpleBinding(new String[] { "ENTER", DefaultEditorKit.insertBreakAction, diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/com/apple/laf/AquaLookAndFeel.java --- a/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/com/apple/laf/AquaLookAndFeel.java Mon Feb 04 17:29:58 2013 -0400 @@ -697,7 +697,7 @@ "Panel.foreground", black, "Panel.opaque", useOpaqueComponents, - "PasswordField.focusInputMap", aquaKeyBindings.getTextFieldInputMap(), + "PasswordField.focusInputMap", aquaKeyBindings.getPasswordFieldInputMap(), "PasswordField.font", controlFont, "PasswordField.background", textBackground, "PasswordField.foreground", textForeground, diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/com/apple/laf/AquaPainter.java --- a/src/macosx/classes/com/apple/laf/AquaPainter.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/com/apple/laf/AquaPainter.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,6 @@ import sun.java2d.*; import sun.print.*; import apple.laf.*; -import apple.laf.JRSUIConstants.Widget; import apple.laf.JRSUIUtils.NineSliceMetricsProvider; abstract class AquaPainter { @@ -63,7 +62,7 @@ } static AquaPainter create(final T state, final NineSliceMetricsProvider metricsProvider) { - return new AquaNineSlicingImagePainter(state, metricsProvider); + return new AquaNineSlicingImagePainter<>(state, metricsProvider); } abstract void paint(final Graphics2D g, final T stateToPaint, final Component c); @@ -71,7 +70,7 @@ final Rectangle boundsRect = new Rectangle(); final JRSUIControl control; T state; - public AquaPainter(final JRSUIControl control, final T state) { + AquaPainter(final JRSUIControl control, final T state) { this.control = control; this.state = state; } @@ -94,14 +93,14 @@ protected final HashMap slicedControlImages; protected final NineSliceMetricsProvider metricsProvider; - public AquaNineSlicingImagePainter(final T state) { + AquaNineSlicingImagePainter(final T state) { this(state, null); } - public AquaNineSlicingImagePainter(final T state, final NineSliceMetricsProvider metricsProvider) { + AquaNineSlicingImagePainter(final T state, final NineSliceMetricsProvider metricsProvider) { super(new JRSUIControl(false), state); this.metricsProvider = metricsProvider; - slicedControlImages = new HashMap(); + slicedControlImages = new HashMap<>(); } @Override @@ -127,7 +126,7 @@ } static class AquaSingleImagePainter extends AquaPainter { - public AquaSingleImagePainter(final T state) { + AquaSingleImagePainter(final T state) { super(new JRSUIControl(false), state); } @@ -137,12 +136,12 @@ } static void paintFromSingleCachedImage(final Graphics2D g, final JRSUIControl control, final JRSUIState controlState, final Component c, final Rectangle boundsRect) { - Rectangle clipRect = g.getClipBounds(); - Rectangle intersection = boundsRect.intersection(clipRect); + final Rectangle clipRect = g.getClipBounds(); + final Rectangle intersection = boundsRect.intersection(clipRect); if (intersection.width <= 0 || intersection.height <= 0) return; - int imgX1 = intersection.x - boundsRect.x; - int imgY1 = intersection.y - boundsRect.y; + final int imgX1 = intersection.x - boundsRect.x; + final int imgY1 = intersection.y - boundsRect.y; final GraphicsConfiguration config = g.getDeviceConfiguration(); final ImageCache cache = ImageCache.getInstance(); @@ -150,19 +149,14 @@ if (image == null) { image = new BufferedImage(boundsRect.width, boundsRect.height, BufferedImage.TYPE_INT_ARGB_PRE); cache.setImage(image, config, boundsRect.width, boundsRect.height, controlState); - } else { - g.drawImage(image, intersection.x, intersection.y, intersection.x + intersection.width, intersection.y + intersection.height, - imgX1, imgY1, imgX1 + intersection.width, imgY1 + intersection.height, null); - return; - } + final WritableRaster raster = image.getRaster(); + final DataBufferInt buffer = (DataBufferInt)raster.getDataBuffer(); - final WritableRaster raster = image.getRaster(); - final DataBufferInt buffer = (DataBufferInt)raster.getDataBuffer(); - - control.set(controlState); - control.paint(SunWritableRaster.stealData(buffer, 0), - image.getWidth(), image.getHeight(), 0, 0, boundsRect.width, boundsRect.height); - SunWritableRaster.markDirty(buffer); + control.set(controlState); + control.paint(SunWritableRaster.stealData(buffer, 0), + image.getWidth(), image.getHeight(), 0, 0, boundsRect.width, boundsRect.height); + SunWritableRaster.markDirty(buffer); + } g.drawImage(image, intersection.x, intersection.y, intersection.x + intersection.width, intersection.y + intersection.height, imgX1, imgY1, imgX1 + intersection.width, imgY1 + intersection.height, null); @@ -173,7 +167,7 @@ final JRSUIControl control; final JRSUIState state; - public RecyclableJRSUISlicedImageControl(final JRSUIControl control, final JRSUIState state, final NineSliceMetrics metrics) { + RecyclableJRSUISlicedImageControl(final JRSUIControl control, final JRSUIState state, final NineSliceMetrics metrics) { super(metrics); this.control = control; this.state = state; diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/com/apple/laf/ImageCache.java --- a/src/macosx/classes/com/apple/laf/ImageCache.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/com/apple/laf/ImageCache.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,7 @@ import java.util.*; import java.util.concurrent.locks.*; +import apple.laf.JRSUIConstants; import apple.laf.JRSUIState; import com.apple.laf.AquaUtils.RecyclableSingleton; @@ -38,9 +39,9 @@ * SoftReferences so they will be dropped by the GC if heap memory gets tight. When our size hits max pixel count least * recently requested images are removed first. */ -class ImageCache { +final class ImageCache { // Ordered Map keyed by args hash, ordered by most recent accessed entry. - private final LinkedHashMap map = new LinkedHashMap(16, 0.75f, true); + private final LinkedHashMap map = new LinkedHashMap<>(16, 0.75f, true); // Maximum number of pixels to cache, this is used if maxCount private final int maxPixelCount; @@ -50,7 +51,7 @@ // Lock for concurrent access to map private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Reference queue for tracking lost softreferences to images in the cache - private final ReferenceQueue referenceQueue = new ReferenceQueue(); + private final ReferenceQueue referenceQueue = new ReferenceQueue<>(); // Singleton Instance private static final RecyclableSingleton instance = new RecyclableSingleton() { @@ -63,11 +64,11 @@ return instance.get(); } - public ImageCache(final int maxPixelCount) { + ImageCache(final int maxPixelCount) { this.maxPixelCount = maxPixelCount; } - public ImageCache() { + ImageCache() { this((8 * 1024 * 1024) / 4); // 8Mb of pixels } @@ -99,10 +100,13 @@ * @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key * @param w The image width, used as part of cache key * @param h The image height, used as part of cache key - * @param args Other arguments to use as part of the cache key - * @return true if the image could be cached or false if the image is too big + * @return true if the image could be cached, false otherwise. */ public boolean setImage(final Image image, final GraphicsConfiguration config, final int w, final int h, final JRSUIState state) { + if (state.is(JRSUIConstants.Animating.YES)) { + return false; + } + final int hash = hash(config, w, h, state); lock.writeLock().lock(); @@ -167,7 +171,7 @@ private final int h; private final JRSUIState state; - public PixelCountSoftReference(final Image referent, final ReferenceQueue q, final int pixelCount, final int hash, final GraphicsConfiguration config, final int w, final int h, final JRSUIState state) { + PixelCountSoftReference(final Image referent, final ReferenceQueue q, final int pixelCount, final int hash, final GraphicsConfiguration config, final int w, final int h, final JRSUIState state) { super(referent, q); this.pixelCount = pixelCount; this.hash = hash; diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/awt/CGraphicsDevice.java --- a/src/macosx/classes/sun/awt/CGraphicsDevice.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/awt/CGraphicsDevice.java Mon Feb 04 17:29:58 2013 -0400 @@ -30,6 +30,7 @@ import java.awt.Window; import java.awt.AWTPermission; import java.awt.DisplayMode; +import java.util.Objects; import sun.java2d.opengl.CGLGraphicsConfig; @@ -122,12 +123,12 @@ boolean fsSupported = isFullScreenSupported(); if (fsSupported && old != null) { - // enter windowed mode (and restore original display mode) - exitFullScreenExclusive(old); + // restore original display mode and enter windowed mode. if (originalMode != null) { setDisplayMode(originalMode); originalMode = null; } + exitFullScreenExclusive(old); } super.setFullScreenWindow(w); @@ -186,13 +187,20 @@ } @Override - public void setDisplayMode(DisplayMode dm) { + public void setDisplayMode(final DisplayMode dm) { if (dm == null) { throw new IllegalArgumentException("Invalid display mode"); } - nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(), dm.getBitDepth(), dm.getRefreshRate()); - if (isFullScreenSupported() && getFullScreenWindow() != null) { - getFullScreenWindow().setSize(dm.getWidth(), dm.getHeight()); + if (!Objects.equals(dm, getDisplayMode())) { + final Window w = getFullScreenWindow(); + if (w != null) { + exitFullScreenExclusive(w); + } + nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(), + dm.getBitDepth(), dm.getRefreshRate()); + if (isFullScreenSupported() && w != null) { + enterFullScreenExclusive(w); + } } } diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/LWComponentPeer.java --- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java Mon Feb 04 17:29:58 2013 -0400 @@ -1226,7 +1226,7 @@ sendEventToDelegate(e); } - private void sendEventToDelegate(final AWTEvent e) { + protected void sendEventToDelegate(final AWTEvent e) { synchronized (getDelegateLock()) { if (getDelegate() == null || !isShowing() || !isEnabled()) { return; diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/LWScrollPanePeer.java --- a/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/LWScrollPanePeer.java Mon Feb 04 17:29:58 2013 -0400 @@ -29,6 +29,7 @@ import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; import java.awt.*; +import java.awt.event.MouseWheelEvent; import java.awt.peer.ScrollPanePeer; import java.util.List; @@ -52,6 +53,21 @@ } @Override + public void handleEvent(AWTEvent e) { + if (e instanceof MouseWheelEvent) { + MouseWheelEvent wheelEvent = (MouseWheelEvent) e; + //java.awt.ScrollPane consumes the event + // in case isWheelScrollingEnabled() is true, + // forcibly send the consumed event to the delegate + if (getTarget().isWheelScrollingEnabled() && wheelEvent.isConsumed()) { + sendEventToDelegate(wheelEvent); + } + } else { + super.handleEvent(e); + } + } + + @Override public void stateChanged(final ChangeEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/LWTextFieldPeer.java --- a/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/LWTextFieldPeer.java Mon Feb 04 17:29:58 2013 -0400 @@ -34,7 +34,7 @@ import java.awt.event.FocusEvent; import java.awt.peer.TextFieldPeer; -import javax.swing.JPasswordField; +import javax.swing.*; import javax.swing.text.JTextComponent; final class LWTextFieldPeer @@ -48,7 +48,7 @@ @Override protected JPasswordField createDelegate() { - return new JTextAreaDelegate(); + return new JPasswordFieldDelegate(); } @Override @@ -69,9 +69,18 @@ public void setEchoChar(final char echoChar) { synchronized (getDelegateLock()) { getDelegate().setEchoChar(echoChar); - getDelegate().putClientProperty("JPasswordField.cutCopyAllowed", - getDelegate().echoCharIsSet() - ? Boolean.FALSE : Boolean.TRUE); + final boolean cutCopyAllowed; + final String focusInputMapKey; + if (echoChar != 0) { + cutCopyAllowed = false; + focusInputMapKey = "PasswordField.focusInputMap"; + } else { + cutCopyAllowed = true; + focusInputMapKey = "TextField.focusInputMap"; + } + getDelegate().putClientProperty("JPasswordField.cutCopyAllowed", cutCopyAllowed); + InputMap inputMap = (InputMap) UIManager.get(focusInputMapKey); + SwingUtilities.replaceUIInputMap(getDelegate(), JComponent.WHEN_FOCUSED, inputMap); } } @@ -106,11 +115,11 @@ super.handleJavaFocusEvent(e); } - private final class JTextAreaDelegate extends JPasswordField { + private final class JPasswordFieldDelegate extends JPasswordField { // Empty non private constructor was added because access to this // class shouldn't be emulated by a synthetic accessor method. - JTextAreaDelegate() { + JPasswordFieldDelegate() { super(); } diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/LWToolkit.java --- a/src/macosx/classes/sun/lwawt/LWToolkit.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/LWToolkit.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -539,7 +539,7 @@ @Override public void ungrab(Window w) { if (w.getPeer() != null) { - ((LWWindowPeer)w.getPeer()).ungrab(); + ((LWWindowPeer)w.getPeer()).ungrab(false); } } } diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/LWWindowPeer.java --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,7 @@ private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.lwawt.focus.LWWindowPeer"); - private PlatformWindow platformWindow; + private final PlatformWindow platformWindow; // Window bounds reported by the native system (as opposed to // regular bounds inherited from LWComponentPeer which are @@ -554,12 +554,14 @@ /** * Called by the {@code PlatformWindow} when this window is moved/resized by - * user. There's no notifyReshape() in LWComponentPeer as the only - * components which could be resized by user are top-level windows. + * user or window insets are changed. There's no notifyReshape() in + * LWComponentPeer as the only components which could be resized by user are + * top-level windows. */ public final void notifyReshape(int x, int y, int w, int h) { final boolean moved; final boolean resized; + final boolean invalid = updateInsets(platformWindow.getInsets()); synchronized (getStateLock()) { moved = (x != sysX) || (y != sysY); resized = (w != sysW) || (h != sysH); @@ -570,7 +572,7 @@ } // Check if anything changed - if (!moved && !resized) { + if (!moved && !resized && !invalid) { return; } // First, update peer's bounds @@ -584,10 +586,10 @@ } // Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events - if (moved) { + if (moved || invalid) { handleMove(x, y, true); } - if (resized) { + if (resized || invalid) { handleResize(w, h, true); repaintPeer(); } @@ -999,27 +1001,21 @@ } } - /* - * Request the window insets from the delegate and compares it - * with the current one. This method is mostly called by the - * delegate, e.g. when the window state is changed and insets - * should be recalculated. - * + /** + * Request the window insets from the delegate and compares it with the + * current one. This method is mostly called by the delegate, e.g. when the + * window state is changed and insets should be recalculated. + *

* This method may be called on the toolkit thread. */ - public boolean updateInsets(Insets newInsets) { - boolean changed = false; + public final boolean updateInsets(final Insets newInsets) { synchronized (getStateLock()) { - changed = (insets.equals(newInsets)); + if (insets.equals(newInsets)) { + return false; + } insets = newInsets; } - - if (changed) { - replaceSurfaceData(); - repaintPeer(); - } - - return changed; + return true; } public static LWWindowPeer getWindowUnderCursor() { @@ -1208,13 +1204,19 @@ grabbingWindow = this; } - void ungrab() { + final void ungrab(boolean doPost) { if (isGrabbing()) { grabbingWindow = null; - postEvent(new UngrabEvent(getTarget())); + if (doPost) { + postEvent(new UngrabEvent(getTarget())); + } } } + void ungrab() { + ungrab(true); + } + private boolean isGrabbing() { return this == grabbingWindow; } diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java --- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Mon Feb 04 17:29:58 2013 -0400 @@ -273,8 +273,31 @@ @Override protected ByteArrayOutputStream convertFileListToBytes(ArrayList fileList) throws IOException { - // TODO Auto-generated method stub - return null; + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + for (int i = 0; i < fileList.size(); i++) + { + byte[] bytes = fileList.get(i).getBytes(); + bos.write(bytes, 0, bytes.length); + bos.write(0); + } + return bos; + } + + @Override + protected boolean isURIListFormat(long format) { + String nat = getNativeForFormat(format); + if (nat == null) { + return false; + } + try { + DataFlavor df = new DataFlavor(nat); + if (df.getPrimaryType().equals("text") && df.getSubType().equals("uri-list")) { + return true; + } + } catch (Exception e) { + // Not a MIME format. + } + return false; } } diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/macosx/CPlatformView.java --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Mon Feb 04 17:29:58 2013 -0400 @@ -27,7 +27,6 @@ import java.awt.*; import java.awt.geom.Rectangle2D; -import java.awt.image.VolatileImage; import sun.awt.CGraphicsConfig; import sun.awt.CGraphicsEnvironment; @@ -89,29 +88,8 @@ return peer; } - public void enterFullScreenMode(final long nsWindowPtr) { + public void enterFullScreenMode() { CWrapper.NSView.enterFullScreenMode(ptr); - - // REMIND: CGLSurfaceData expects top-level's size - // and therefore we need to account insets before - // recreating the surface data - Insets insets = peer.getInsets(); - - Rectangle screenBounds; - final long screenPtr = CWrapper.NSWindow.screen(nsWindowPtr); - try { - screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds(); - } finally { - CWrapper.NSObject.release(screenPtr); - } - - // the move/size notification from the underlying system comes - // but it contains a bounds smaller than the whole screen - // and therefore we need to create the synthetic notifications - peer.notifyReshape(screenBounds.x - insets.left, - screenBounds.y - insets.bottom, - screenBounds.width + insets.left + insets.right, - screenBounds.height + insets.top + insets.bottom); } public void exitFullScreenMode() { diff -r a8bbd962f34a -r 41654275896d src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Mon Feb 04 17:29:58 2013 -0400 @@ -38,7 +38,6 @@ import sun.java2d.SurfaceData; import sun.java2d.opengl.CGLSurfaceData; import sun.lwawt.*; -import sun.lwawt.LWWindowPeer.PeerType; import sun.util.logging.PlatformLogger; import com.apple.laf.*; @@ -58,7 +57,6 @@ private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr); private static native void nativeSetNSWindowMinimizedIcon(long nsWindowPtr, long nsImage); private static native void nativeSetNSWindowRepresentedFilename(long nsWindowPtr, String representedFilename); - private static native void nativeSetNSWindowSecurityWarningPositioning(long nsWindowPtr, double x, double y, float biasX, float biasY); private static native void nativeSetEnabled(long nsWindowPtr, boolean isEnabled); private static native void nativeSynthesizeMouseEnteredExitedEvents(); private static native void nativeDispose(long nsWindowPtr); @@ -197,7 +195,8 @@ // 1) setting native bounds via nativeSetBounds() call // 2) getting notification from the native level via deliverMoveResizeEvent() private Rectangle nativeBounds = new Rectangle(0, 0, 0, 0); - private volatile boolean isFullScreenMode = false; + private volatile boolean isFullScreenMode; + private boolean isFullScreenAnimationOn; private Window target; private LWWindowPeer peer; @@ -415,8 +414,10 @@ @Override // PlatformWindow public Insets getInsets() { - final Insets insets = nativeGetNSWindowInsets(getNSWindowPtr()); - return insets; + if (!isFullScreenMode) { + return nativeGetNSWindowInsets(getNSWindowPtr()); + } + return new Insets(0, 0, 0, 0); } @Override // PlatformWindow @@ -728,7 +729,19 @@ @Override public void enterFullScreenMode() { isFullScreenMode = true; - contentView.enterFullScreenMode(getNSWindowPtr()); + contentView.enterFullScreenMode(); + // the move/size notification from the underlying system comes + // but it contains a bounds smaller than the whole screen + // and therefore we need to create the synthetic notifications + Rectangle screenBounds; + final long screenPtr = CWrapper.NSWindow.screen(getNSWindowPtr()); + try { + screenBounds = CWrapper.NSScreen.frame(screenPtr).getBounds(); + } finally { + CWrapper.NSObject.release(screenPtr); + } + peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width, + screenBounds.height); } @Override @@ -875,11 +888,10 @@ final Rectangle oldB = nativeBounds; nativeBounds = new Rectangle(x, y, width, height); peer.notifyReshape(x, y, width, height); - if (byUser && !oldB.getSize().equals(nativeBounds.getSize())) { + if ((byUser && !oldB.getSize().equals(nativeBounds.getSize())) + || isFullScreenAnimationOn) { flushBuffers(); } - //TODO validateSurface already called from notifyReshape - validateSurface(); } private void deliverWindowClosingEvent() { @@ -924,6 +936,10 @@ return false; } + if (blocker instanceof CPrinterDialogPeer) { + return true; + } + CPlatformWindow pWindow = (CPlatformWindow)blocker.getPlatformWindow(); pWindow.orderAboveSiblings(); @@ -975,27 +991,19 @@ orderAboveSiblings(); } - private void updateDisplay() { - EventQueue.invokeLater(new Runnable() { - public void run() { - validateSurface(); - } - }); + private void windowWillEnterFullScreen() { + isFullScreenAnimationOn = true; + } + + private void windowDidEnterFullScreen() { + isFullScreenAnimationOn = false; } - private void updateWindowContent() { - ComponentEvent resizeEvent = new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED); - SunToolkit.postEvent(SunToolkit.targetToAppContext(target), resizeEvent); + private void windowWillExitFullScreen() { + isFullScreenAnimationOn = true; } - private void windowWillEnterFullScreen() { - updateWindowContent(); - } - private void windowDidEnterFullScreen() { - updateDisplay(); + private void windowDidExitFullScreen() { + isFullScreenAnimationOn = false; } - private void windowWillExitFullScreen() { - updateWindowContent(); - } - private void windowDidExitFullScreen() {} } diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/AWTSurfaceLayers.m --- a/src/macosx/native/sun/awt/AWTSurfaceLayers.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.m Mon Feb 04 17:29:58 2013 -0400 @@ -101,8 +101,7 @@ JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - AWT_ASSERT_APPKIT_THREAD; - + CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); surfaceLayers = [[AWTSurfaceLayers alloc] initWithWindowLayer: windowLayer]; CFRetain(surfaceLayers); @@ -127,7 +126,6 @@ AWTSurfaceLayers *surfaceLayers = OBJC(surfaceLayersPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ - AWT_ASSERT_APPKIT_THREAD; CGRect rect = CGRectMake(x, y, width, height); [surfaceLayers setBounds: rect]; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/AWTView.m --- a/src/macosx/native/sun/awt/AWTView.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/AWTView.m Mon Feb 04 17:29:58 2013 -0400 @@ -1243,8 +1243,7 @@ jobject cPlatformView = (*env)->NewGlobalRef(env, obj); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - AWT_ASSERT_APPKIT_THREAD; - + CALayer *windowLayer = jlong_to_ptr(windowLayerPtr); AWTView *view = [[AWTView alloc] initWithRect:rect platformView:cPlatformView @@ -1274,8 +1273,7 @@ NSView *view = (NSView *)jlong_to_ptr(viewPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ - AWT_ASSERT_APPKIT_THREAD; - + if (toResize) { [view setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable]; } else { @@ -1308,8 +1306,7 @@ NSWindow *window = [view window]; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - AWT_ASSERT_APPKIT_THREAD; - + ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue]; }]; @@ -1336,8 +1333,7 @@ NSView *view = (NSView *)jlong_to_ptr(viewPtr); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - AWT_ASSERT_APPKIT_THREAD; - + NSRect viewBounds = [view bounds]; NSRect frameInWindow = [view convertRect:viewBounds toView:nil]; rect = [[view window] convertRectToScreen:frameInWindow]; @@ -1366,9 +1362,7 @@ JNF_COCOA_ENTER(env); NSView *nsView = OBJC(viewPtr); - [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSPoint ptWindowCoords = [[nsView window] mouseLocationOutsideOfEventStream]; NSPoint ptViewCoords = [nsView convertPoint:ptWindowCoords fromView:nil]; underMouse = [nsView hitTest:ptViewCoords] != nil; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/AWTWindow.m --- a/src/macosx/native/sun/awt/AWTWindow.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/AWTWindow.m Mon Feb 04 17:29:58 2013 -0400 @@ -738,14 +738,12 @@ __block AWTWindow *window = nil; JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env]; NSView *contentView = OBJC(contentViewPtr); NSRect frameRect = NSMakeRect(x, y, w, h); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow styleBits:styleBits @@ -770,11 +768,9 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; @@ -807,12 +803,10 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); CMenuBar *menuBar = OBJC(menuBarPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; @@ -838,14 +832,12 @@ jobject ret = NULL; JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); __block NSRect contentRect = NSZeroRect; __block NSRect frame = NSZeroRect; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ frame = [nsWindow frame]; contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]]; @@ -873,14 +865,12 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSRect jrect = NSMakeRect(originX, originY, width, height); // TODO: not sure we need displayIfNeeded message in our view NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; @@ -913,7 +903,6 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; if (minW < 1) minW = 1; if (minH < 1) minH = 1; @@ -921,8 +910,7 @@ if (maxH < 1) maxH = 1; NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; @@ -949,12 +937,9 @@ (JNIEnv *env, jclass clazz, jlong windowPtr) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow orderBack:nil]; }]; @@ -970,11 +955,9 @@ (JNIEnv *env, jclass clazz, jlong windowPtr) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ if (![nsWindow isKeyWindow]) { [nsWindow makeKeyAndOrderFront:nsWindow]; @@ -995,7 +978,6 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); [nsWindow performSelectorOnMainThread:@selector(setTitle:) @@ -1016,15 +998,9 @@ JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); - if ([NSThread isMainThread]) { + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow invalidateShadow]; - } else { - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - - [nsWindow invalidateShadow]; - }]; - } + }]; JNF_COCOA_EXIT(env); } @@ -1060,13 +1036,10 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); NSImage *image = OBJC(nsImagePtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setMiniwindowImage:image]; }]; @@ -1082,13 +1055,10 @@ (JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)]; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setRepresentedURL:url]; }]; @@ -1097,22 +1067,6 @@ /* * Class: sun_lwawt_macosx_CPlatformWindow - * Method: nativeSetNSWindowSecurityWarningPositioning - * Signature: (JDDFF)V - */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowSecurityWarningPositioning -(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble x, jdouble y, jfloat biasX, jfloat biasY) -{ -JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; - - [JNFException raise:env as:kRuntimeException reason:"unimplemented"]; - -JNF_COCOA_EXIT(env); -} - -/* - * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeGetTopmostPlatformWindowUnderMouse * Signature: (J)V */ @@ -1144,10 +1098,8 @@ (JNIEnv *env, jclass clazz) { JNF_COCOA_ENTER(env); - AWT_ASSERT_NOT_APPKIT_THREAD; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; }]; @@ -1168,7 +1120,7 @@ SEL toggleFullScreenSelector = @selector(toggleFullScreen:); if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow performSelector:toggleFullScreenSelector withObject:nil]; }]; @@ -1181,7 +1133,7 @@ JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; [window setEnabled: isEnabled]; @@ -1196,7 +1148,7 @@ JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; if ([AWTWindow lastKeyWindow] == window) { diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/ApplicationDelegate.m --- a/src/macosx/native/sun/awt/ApplicationDelegate.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/ApplicationDelegate.m Mon Feb 04 17:29:58 2013 -0400 @@ -515,10 +515,9 @@ JNIEXPORT void JNICALL Java_com_apple_eawt_Application_nativeInitializeApplicationDelegate (JNIEnv *env, jclass clz) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); // Force initialization to happen on AppKit thread! - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ApplicationDelegate sharedDelegate]; }]; JNF_COCOA_EXIT(env); @@ -532,10 +531,9 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeOpenCocoaAboutWindow (JNIEnv *env, jclass clz) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp orderFrontStandardAboutPanel:nil]; }]; @@ -550,10 +548,9 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeReplyToAppShouldTerminate (JNIEnv *env, jclass clz, jboolean doTerminate) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp replyToApplicationShouldTerminate:doTerminate]; }]; @@ -568,7 +565,6 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeRegisterForNotification (JNIEnv *env, jclass clz, jint notificationType) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(_registerForNotification:) onObject:[ApplicationDelegate class] @@ -586,13 +582,10 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockMenu (JNIEnv *env, jclass clz, jlong nsMenuPtr) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); NSMenu *menu = (NSMenu *)jlong_to_ptr(nsMenuPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ApplicationDelegate sharedDelegate].fDockMenu = menu; }]; @@ -607,14 +600,13 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconImage (JNIEnv *env, jclass clz, jlong nsImagePtr) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); NSImage *_image = (NSImage *)jlong_to_ptr(nsImagePtr); - [JNFRunLoop performOnMainThread:@selector(_setDockIconImage:) - on:[ApplicationDelegate class] - withObject:_image - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(_setDockIconImage:) + on:[ApplicationDelegate class] + withObject:_image + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -629,12 +621,9 @@ { __block NSImage *image = nil; -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ image = [ApplicationDelegate _dockIconImage]; CFRetain(image); }]; @@ -652,13 +641,10 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconBadge (JNIEnv *env, jclass clz, jstring badge) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); NSString *badgeString = JNFJavaToNSString(env, badge); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSDockTile *dockTile = [NSApp dockTile]; [dockTile setBadgeLabel:badgeString]; [dockTile display]; @@ -675,12 +661,9 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestActivation (JNIEnv *env, jclass clz, jboolean allWindows) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSApplicationActivationOptions options = allWindows ? NSApplicationActivateAllWindows : 0; options |= NSApplicationActivateIgnoringOtherApps; // without this, nothing happens! [[NSRunningApplication currentApplication] activateWithOptions:options]; @@ -697,12 +680,9 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestUserAttention (JNIEnv *env, jclass clz, jboolean critical) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp requestUserAttention:critical ? NSCriticalRequest : NSInformationalRequest]; }]; @@ -717,13 +697,12 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeOpenHelpViewer (JNIEnv *env, jclass clz) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThread:@selector(showHelp:) - on:NSApp - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(showHelp:) + on:NSApp + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -736,7 +715,6 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeEnableSuddenTermination (JNIEnv *env, jclass clz) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [[NSProcessInfo processInfo] enableSuddenTermination]; // Foundation thread-safe @@ -752,7 +730,6 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeDisableSuddenTermination (JNIEnv *env, jclass clz) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [[NSProcessInfo processInfo] disableSuddenTermination]; // Foundation thread-safe @@ -768,12 +745,9 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState (JNIEnv *env, jclass clz, jint menuID, jboolean visible, jboolean enabled) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate]; switch (menuID) { case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT: @@ -796,12 +770,10 @@ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetDefaultMenuBar (JNIEnv *env, jclass clz, jlong cMenuBarPtr) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ApplicationDelegate sharedDelegate].fDefaultMenuBar = menu; }]; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CClipboard.m --- a/src/macosx/native/sun/awt/CClipboard.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CClipboard.m Mon Feb 04 17:29:58 2013 -0400 @@ -109,7 +109,6 @@ } - (void) javaDeclareTypes:(NSArray *)inTypes withOwner:(jobject)inClipboard jniEnv:(JNIEnv *)inEnv { - AWT_ASSERT_NOT_APPKIT_THREAD; //NSLog(@"CClipboard javaDeclareTypes %@ withOwner", inTypes); @@ -134,7 +133,6 @@ - (NSArray *) javaGetTypes { - AWT_ASSERT_NOT_APPKIT_THREAD; NSMutableArray *args = [NSMutableArray arrayWithCapacity:1]; [ThreadUtilities performOnMainThread:@selector(_nativeGetTypes:) onObject:self withObject:args waitUntilDone:YES awtMode:YES]; @@ -152,7 +150,6 @@ } - (void) javaSetData:(NSData *)inData forType:(NSString *) inFormat { - AWT_ASSERT_NOT_APPKIT_THREAD; CClipboardUpdate *newUpdate = [[CClipboardUpdate alloc] initWithData:inData withFormat:inFormat]; [ThreadUtilities performOnMainThread:@selector(_nativeSetData:) onObject:self withObject:newUpdate waitUntilDone:YES awtMode:YES]; @@ -171,7 +168,6 @@ } - (NSData *) javaGetDataForType:(NSString *) inFormat { - AWT_ASSERT_NOT_APPKIT_THREAD; NSMutableArray *args = [NSMutableArray arrayWithObject:inFormat]; [ThreadUtilities performOnMainThread:@selector(_nativeGetDataForType:) onObject:self withObject:args waitUntilDone:YES awtMode:YES]; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CCursorManager.m --- a/src/macosx/native/sun/awt/CCursorManager.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CCursorManager.m Mon Feb 04 17:29:58 2013 -0400 @@ -74,7 +74,6 @@ (JNIEnv *env, jclass class, jint type, jstring name) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSString *cursorName = JNFJavaToNSString(env, name); SEL cursorSelector = (type == sun_lwawt_macosx_CCursorManager_NAMED_CURSOR) ? lookupCursorSelectorForName(cursorName) : lookupCursorSelectorForType(type); @@ -87,9 +86,7 @@ [JNFException raise:env as:kNoSuchMethodException reason:"missing NSCursor selector"]; } - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ setCursorOnAppKitThread([[NSCursor class] performSelector:cursorSelector]); }]; @@ -101,12 +98,9 @@ (JNIEnv *env, jclass class, jlong imgPtr, jdouble x, jdouble y) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSImage *image = (NSImage *)jlong_to_ptr(imgPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:(NSPoint){ x, y }]; setCursorOnAppKitThread(cursor); @@ -127,8 +121,6 @@ __block NSPoint pt = NSZeroPoint; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - AWT_ASSERT_APPKIT_THREAD; - pt = ConvertNSScreenPoint(env, [NSEvent mouseLocation]); }]; @@ -144,13 +136,11 @@ Java_sun_lwawt_macosx_CCursorManager_nativeSetAllowsCursorSetInBackground (JNIEnv *env, jclass class, jboolean allows) { - JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; SEL allowsSetInBackground_SEL = @selector(javaSetAllowsCursorSetInBackground:); if ([[NSCursor class] respondsToSelector:allowsSetInBackground_SEL]) { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSMethodSignature *allowsSetInBackground_sig = [[NSCursor class] methodSignatureForSelector:allowsSetInBackground_SEL]; NSInvocation *invocation = diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CDesktopPeer.m --- a/src/macosx/native/sun/awt/CDesktopPeer.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CDesktopPeer.m Mon Feb 04 17:29:58 2013 -0400 @@ -36,8 +36,6 @@ JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenURI (JNIEnv *env, jclass clz, jstring uri) { - // AWT_ASSERT_ANY_THREAD - OSStatus status = noErr; JNF_COCOA_ENTER(env); @@ -63,8 +61,6 @@ JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CDesktopPeer__1lsOpenFile (JNIEnv *env, jclass clz, jstring jpath, jboolean print) { - // AWT_ASSERT_ANY_THREAD - OSStatus status = noErr; JNF_COCOA_ENTER(env); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CDragSourceContextPeer.m --- a/src/macosx/native/sun/awt/CDragSourceContextPeer.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CDragSourceContextPeer.m Mon Feb 04 17:29:58 2013 -0400 @@ -46,7 +46,7 @@ __block CDragSource* dragSource = nil; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ dragSource = [[CDragSource alloc] init:jthis component:jcomponent peer:jpeer control:controlObj transferable:jtransferable triggerEvent:jtrigger dragPosX:jdragposx dragPosY:jdragposy modifiers:jextmodifiers clickCount:jclickcount timeStamp:jtimestamp @@ -103,7 +103,7 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CDragSourceContextPeer_setNativeCursor (JNIEnv *env, jobject jthis, jlong nativeDragSourceVal, jobject jcursor, jint jcursortype) { - AWT_ASSERT_NOT_APPKIT_THREAD; + //AWT_ASSERT_NOT_APPKIT_THREAD; //JNF_COCOA_ENTER(env); // jobject gCursor = JNFNewGlobalRef(env, jcursor); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CImage.m --- a/src/macosx/native/sun/awt/CImage.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CImage.m Mon Feb 04 17:29:58 2013 -0400 @@ -108,7 +108,6 @@ jlong result = 0L; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height); if (imageRep) { @@ -139,7 +138,6 @@ jlong result = 0L; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; jsize num = (*env)->GetArrayLength(env, buffers); NSMutableArray * reps = [NSMutableArray arrayWithCapacity: num]; @@ -187,7 +185,6 @@ NSImage *image = nil; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; IconRef iconRef; if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) { @@ -212,7 +209,6 @@ NSImage *image = nil; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; NSString *path = JNFNormalizedNSStringForPath(env, file); image = [[NSImage alloc] initByReferencingFile:path]; @@ -234,10 +230,9 @@ __block NSImage *image = nil; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; NSString *path = JNFNormalizedNSStringForPath(env, file); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ image = [[NSWorkspace sharedWorkspace] iconForFile:path]; [image setScalesWhenResized:TRUE]; if (image) CFRetain(image); // GC @@ -259,7 +254,6 @@ NSImage *image = nil; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; image = [NSImage imageNamed:JNFJavaToNSString(env, name)]; if (image) CFRetain(image); // GC @@ -278,7 +272,6 @@ (JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint w, jint h) { JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; NSImage *img = (NSImage *)jlong_to_ptr(nsImgPtr); jint *dst = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL); @@ -301,7 +294,6 @@ jobject size = NULL; JNF_COCOA_ENTER(env); -AWT_ASSERT_ANY_THREAD; size = NSToJavaSize(env, [(NSImage *)jlong_to_ptr(nsImgPtr) size]); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CInputMethod.m --- a/src/macosx/native/sun/awt/CInputMethod.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CInputMethod.m Mon Feb 04 17:29:58 2013 -0400 @@ -153,7 +153,7 @@ __block NSString *keyboardInfo = NULL; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ keyboardInfo = [inputMethodController performSelector:@selector(currentInputMethodName)]; [keyboardInfo retain]; }]; @@ -177,7 +177,7 @@ JNF_COCOA_ENTER(env); AWTView *view = (AWTView *)jlong_to_ptr(nativePeer); JNFJObjectWrapper *inputMethodWrapper = [[JNFJObjectWrapper alloc] initWithJObject:inputMethod withEnv:env]; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [CInputMethod _nativeNotifyPeerWithView:view inputMethod:inputMethodWrapper]; }]; @@ -196,7 +196,7 @@ JNF_COCOA_ENTER(env); AWTView *view = (AWTView *)jlong_to_ptr(nativePeer); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [CInputMethod _nativeEndComposition:view]; }]; @@ -216,7 +216,7 @@ __block NSString *isoAbbreviation; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ isoAbbreviation = (NSString *) [inputMethodController performSelector:@selector(currentInputMethodLocale)]; [isoAbbreviation retain]; }]; @@ -259,7 +259,7 @@ NSString *localeStr = JNFJavaToNSString(env, locale); [localeStr retain]; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [CInputMethod setKeyboardLayout:localeStr]; }]; @@ -293,7 +293,7 @@ __block NSArray *selectableArray = nil; JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ selectableArray = (NSArray *)[inputMethodController performSelector:@selector(availableInputMethodLocales)]; [selectableArray retain]; }]; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CMenu.m --- a/src/macosx/native/sun/awt/CMenu.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CMenu.m Mon Feb 04 17:29:58 2013 -0400 @@ -55,12 +55,10 @@ //- (void)finalize { [super finalize]; } - (void)addJavaSubmenu:(CMenu *)submenu { -AWT_ASSERT_NOT_APPKIT_THREAD; [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) onObject:self withObject:submenu waitUntilDone:YES awtMode:YES]; } - (void)addJavaMenuItem:(CMenuItem *)theMenuItem { -AWT_ASSERT_NOT_APPKIT_THREAD; [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) onObject:self withObject:theMenuItem waitUntilDone:YES awtMode:YES]; } @@ -70,7 +68,6 @@ } - (void)setJavaMenuTitle:(NSString *)title { -AWT_ASSERT_NOT_APPKIT_THREAD; if (title) { [ThreadUtilities performOnMainThread:@selector(setNativeMenuTitle_OnAppKitThread:) onObject:self withObject:title waitUntilDone:YES awtMode:YES]; @@ -95,7 +92,6 @@ } - (void)deleteJavaItem:(jint)index { -AWT_ASSERT_NOT_APPKIT_THREAD; [ThreadUtilities performOnMainThread:@selector(deleteNativeJavaItem_OnAppKitThread:) onObject:self withObject:[NSNumber numberWithInt:index] waitUntilDone:YES awtMode:YES]; } diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CMenuComponent.m --- a/src/macosx/native/sun/awt/CMenuComponent.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CMenuComponent.m Mon Feb 04 17:29:58 2013 -0400 @@ -80,10 +80,10 @@ { JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThread:@selector(disposer) - on:((id)jlong_to_ptr(menuItemObj)) - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(disposer) + on:((id)jlong_to_ptr(menuItemObj)) + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CMenuItem.m --- a/src/macosx/native/sun/awt/CMenuItem.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CMenuItem.m Mon Feb 04 17:29:58 2013 -0400 @@ -104,7 +104,6 @@ } - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers { -AWT_ASSERT_NOT_APPKIT_THREAD; NSUInteger modifierMask = 0; @@ -126,8 +125,7 @@ modifierMask = JavaModifiersToNsKeyModifiers(modifiers, NO); } - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [fMenuItem setKeyEquivalent:theKeyEquivalent]; [fMenuItem setKeyEquivalentModifierMask:modifierMask]; [fMenuItem setTitle:theLabel]; @@ -135,32 +133,23 @@ } - (void) setJavaImage:(NSImage *)theImage { -AWT_ASSERT_NOT_APPKIT_THREAD; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [fMenuItem setImage:theImage]; }]; } - (void) setJavaToolTipText:(NSString *)theText { -AWT_ASSERT_NOT_APPKIT_THREAD; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [fMenuItem setToolTip:theText]; }]; } - (void)setJavaEnabled:(BOOL) enabled { -AWT_ASSERT_NOT_APPKIT_THREAD; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ @synchronized(self) { fIsEnabled = enabled; @@ -173,7 +162,6 @@ } - (BOOL)isEnabled { - // AWT_ASSERT_ANY_THREAD; BOOL enabled = NO; @synchronized(self) { @@ -184,11 +172,8 @@ - (void)setJavaState:(BOOL)newState { -AWT_ASSERT_NOT_APPKIT_THREAD; - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ -AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [fMenuItem setState:(newState ? NSOnState : NSOffState)]; }]; } diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CPopupMenu.m --- a/src/macosx/native/sun/awt/CPopupMenu.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CPopupMenu.m Mon Feb 04 17:29:58 2013 -0400 @@ -64,7 +64,7 @@ jobject cPeerObjGlobal = JNFNewGlobalRef(env, peer); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ aCPopupMenu = [[CPopupMenu alloc] initWithPeer:cPeerObjGlobal]; CFRetain(aCPopupMenu); [aCPopupMenu release]; @@ -82,7 +82,7 @@ CPopupMenu* cPopupMenu = (CPopupMenu*)jlong_to_ptr(menuPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSPoint loc = ConvertNSScreenPoint(env, NSMakePoint(x, y)); [[cPopupMenu menu] popUpMenuPositioningItem: nil diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CTrayIcon.m --- a/src/macosx/native/sun/awt/CTrayIcon.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CTrayIcon.m Mon Feb 04 17:29:58 2013 -0400 @@ -303,10 +303,9 @@ __block AWTTrayIcon *trayIcon = nil; JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; jobject thePeer = JNFNewGlobalRef(env, peer); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ trayIcon = [[AWTTrayIcon alloc] initWithPeer:thePeer]; }]; @@ -334,11 +333,10 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CTrayIcon_nativeSetToolTip (JNIEnv *env, jobject self, jlong model, jstring jtooltip) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; AWTTrayIcon *icon = jlong_to_ptr(model); NSString *tooltip = JNFJavaToNSString(env, jtooltip); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [icon setTooltip:tooltip]; }]; @@ -353,10 +351,9 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CTrayIcon_setNativeImage (JNIEnv *env, jobject self, jlong model, jlong imagePtr, jboolean autosize) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; AWTTrayIcon *icon = jlong_to_ptr(model); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [icon setImage:jlong_to_ptr(imagePtr) sizing:autosize]; }]; @@ -369,13 +366,10 @@ jobject jpt = NULL; JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; __block NSPoint pt = NSZeroPoint; AWTTrayIcon *icon = jlong_to_ptr(model); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; - + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSPoint loc = [icon getLocationOnScreen]; pt = ConvertNSScreenPoint(env, loc); }]; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/CWrapper.m --- a/src/macosx/native/sun/awt/CWrapper.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/CWrapper.m Mon Feb 04 17:29:58 2013 -0400 @@ -46,7 +46,7 @@ JNF_COCOA_ENTER(env); id obj = (id)jlong_to_ptr(objectPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ CFRelease(obj); }]; @@ -66,10 +66,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(makeKeyAndOrderFront:) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(makeKeyAndOrderFront:) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -86,10 +86,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(makeKeyWindow) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(makeKeyWindow) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -106,10 +106,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(makeMainWindow) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(makeMainWindow) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -128,7 +128,7 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ canBecomeMainWindow = [window canBecomeMainWindow]; }]; @@ -151,7 +151,7 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ isKeyWindow = [window isKeyWindow]; }]; @@ -172,10 +172,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(orderFront:) - on:window - withObject:window - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(orderFront:) + on:window + withObject:window + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -192,10 +192,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(orderOut:) - on:window - withObject:window - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(orderOut:) + on:window + withObject:window + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -212,10 +212,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(orderFrontRegardless) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(orderFrontRegardless) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -233,7 +233,7 @@ NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); NSWindow *relativeTo = (NSWindow *)jlong_to_ptr(relativeToPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window orderWindow:(NSWindowOrderingMode)order relativeTo:[relativeTo windowNumber]]; }]; @@ -267,7 +267,7 @@ initLevels(); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setLevel: LEVELS[level]]; }]; } else { @@ -290,7 +290,7 @@ NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr); NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [parent addChildWindow:child ordered:order]; }]; @@ -310,10 +310,10 @@ AWTWindow *parent = (AWTWindow *)jlong_to_ptr(parentPtr); AWTWindow *child = (AWTWindow *)jlong_to_ptr(childPtr); - [JNFRunLoop performOnMainThread:@selector(removeChildWindow:) - on:parent - withObject:child - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(removeChildWindow:) + on:parent + withObject:child + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -331,7 +331,7 @@ AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); NSRect frame = NSMakeRect(x, y, w, h); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setFrame:frame display:display]; }]; @@ -350,7 +350,7 @@ JNF_COCOA_ENTER(env); AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setAlphaValue:(CGFloat)alpha]; }]; @@ -369,7 +369,7 @@ JNF_COCOA_ENTER(env); AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setOpaque:(BOOL)opaque]; }]; @@ -389,7 +389,7 @@ AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); NSColor *color = (NSColor *)jlong_to_ptr(colorPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [window setBackgroundColor:color]; }]; @@ -410,7 +410,7 @@ JNF_COCOA_ENTER(env); AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ const NSScreen *screen = [window screen]; CFRetain(screen); // GC screenPtr = ptr_to_jlong(screen); @@ -432,10 +432,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(miniaturize:) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(miniaturize:) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -452,10 +452,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(deminiaturize:) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(deminiaturize:) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -472,10 +472,10 @@ JNF_COCOA_ENTER(env); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); - [JNFRunLoop performOnMainThread:@selector(zoom:) - on:window - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(zoom:) + on:window + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -493,10 +493,10 @@ NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr); NSResponder *responder = (NSResponder *)jlong_to_ptr(responderPtr); - [JNFRunLoop performOnMainThread:@selector(makeFirstResponder:) - on:window - withObject:responder - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(makeFirstResponder:) + on:window + withObject:responder + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -514,7 +514,7 @@ NSView *view = (NSView *)jlong_to_ptr(viewPtr); NSView *subview = (NSView *)jlong_to_ptr(subviewPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [view addSubview:subview]; }]; @@ -533,10 +533,10 @@ JNF_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThread:@selector(removeFromSuperview) - on:view - withObject:nil - waitUntilDone:NO]; + [ThreadUtilities performOnMainThread:@selector(removeFromSuperview) + on:view + withObject:nil + waitUntilDone:NO]; JNF_COCOA_EXIT(env); } @@ -553,7 +553,7 @@ JNF_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [view setFrame:NSMakeRect(x, y, w, h)]; }]; @@ -576,7 +576,7 @@ __block NSRect rect = NSZeroRect; NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ rect = [view frame]; }]; @@ -599,7 +599,7 @@ JNF_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSScreen *screen = [[view window] screen]; NSDictionary *opts = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, nil]; [view enterFullScreenMode:screen withOptions:opts]; @@ -620,7 +620,7 @@ JNF_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [view exitFullScreenModeWithOptions:nil]; }]; @@ -641,7 +641,7 @@ JNF_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ windowPtr = ptr_to_jlong([view window]); }]; @@ -655,14 +655,14 @@ * Method: setHidden * Signature: (JZ)V */ -JNIEXPORT jlong JNICALL +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CWrapper_00024NSView_setHidden (JNIEnv *env, jclass cls, jlong viewPtr, jboolean toHide) { JNF_COCOA_ENTER(env); NSView *view = (NSView *)jlong_to_ptr(viewPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [view setHidden:(BOOL)toHide]; }]; @@ -686,7 +686,7 @@ __block NSRect rect = NSZeroRect; NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ rect = [screen frame]; }]; @@ -713,7 +713,7 @@ __block NSRect rect = NSZeroRect; NSScreen *screen = (NSScreen *)jlong_to_ptr(screenPtr); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ rect = [screen visibleFrame]; }]; @@ -737,7 +737,7 @@ JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ NSArray *screens = [NSScreen screens]; for (NSScreen *screen in screens) { NSDictionary *screenInfo = [screen deviceDescription]; @@ -768,7 +768,7 @@ JNF_COCOA_ENTER(env); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ clearColorPtr = ptr_to_jlong([NSColor clearColor]); }]; diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/JavaComponentAccessibility.m --- a/src/macosx/native/sun/awt/JavaComponentAccessibility.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/JavaComponentAccessibility.m Mon Feb 04 17:29:58 2013 -0400 @@ -1147,7 +1147,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessibility_focusChanged (JNIEnv *env, jobject jthis) { - AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(postFocusChanged:) onObject:[JavaComponentAccessibility class] withObject:nil waitUntilDone:NO awtMode:NO]; @@ -1164,7 +1163,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_valueChanged (JNIEnv *env, jclass jklass, jlong element) { - AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(postValueChanged) onObject:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO awtMode:NO]; JNF_COCOA_EXIT(env); @@ -1178,7 +1176,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectionChanged (JNIEnv *env, jclass jklass, jlong element) { - AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(postSelectionChanged) onObject:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO awtMode:NO]; JNF_COCOA_EXIT(env); @@ -1193,7 +1190,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem (JNIEnv *env, jclass jklass, jlong element) { - AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) onObject:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO awtMode:NO]; JNF_COCOA_EXIT(env); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/LWCToolkit.m --- a/src/macosx/native/sun/awt/LWCToolkit.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/LWCToolkit.m Mon Feb 04 17:29:58 2013 -0400 @@ -415,13 +415,9 @@ JNF_COCOA_ENTER(env); - if ([NSThread isMainThread]) { + [ThreadUtilities performOnMainThreadWaiting:YES block:^() { active = (jboolean)[NSRunningApplication currentApplication].active; - } else { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^() { - active = (jboolean)[NSRunningApplication currentApplication].active; - }]; - } + }]; JNF_COCOA_EXIT(env); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/awt/awt.m --- a/src/macosx/native/sun/awt/awt.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/awt/awt.m Mon Feb 04 17:29:58 2013 -0400 @@ -42,6 +42,15 @@ // The symbol is defined in libosxapp.dylib (ThreadUtilities.m) extern JavaVM *jvm; +// Indicates if AWT is running embedded (in SWT, FX, elsewhere) +static BOOL isEmbedded = NO; + +// Indicates that the app has been started with -XstartOnFirstThread +// (directly or via WebStart settings), and AWT should not run its +// own event loop in this mode. Even if a loop isn't running yet, +// we expect an embedder (e.g. SWT) to start it some time later. +static BOOL forceEmbeddedMode = NO; + static bool ShouldPrintVerboseDebugging() { static int debug = -1; if (debug == -1) { @@ -63,31 +72,29 @@ static CFRunLoopObserverRef busyObserver = NULL; static CFRunLoopObserverRef notBusyObserver = NULL; -static void setUpAWTAppKit(BOOL swt_mode, BOOL headless) { -AWT_ASSERT_APPKIT_THREAD; +static void setUpAWTAppKit() +{ BOOL verbose = ShouldPrintVerboseDebugging(); if (verbose) AWT_DEBUG_LOG(@"setting up busy observers"); - JNIEnv *env = [ThreadUtilities getJNIEnv]; - // Add CFRunLoopObservers to call into AWT so that AWT knows that the // AWT thread (which is the AppKit main thread) is alive. This way AWT // will not automatically shutdown. busyObserver = CFRunLoopObserverCreate( - NULL, // CFAllocator - kCFRunLoopAfterWaiting, // CFOptionFlags - true, // repeats - NSIntegerMax, // order - &BusyObserver, // CFRunLoopObserverCallBack - NULL); // CFRunLoopObserverContext + NULL, // CFAllocator + kCFRunLoopAfterWaiting, // CFOptionFlags + true, // repeats + NSIntegerMax, // order + &BusyObserver, // CFRunLoopObserverCallBack + NULL); // CFRunLoopObserverContext notBusyObserver = CFRunLoopObserverCreate( - NULL, // CFAllocator - kCFRunLoopBeforeWaiting, // CFOptionFlags - true, // repeats - NSIntegerMin, // order - &NotBusyObserver, // CFRunLoopObserverCallBack - NULL); // CFRunLoopObserverContext + NULL, // CFAllocator + kCFRunLoopBeforeWaiting, // CFOptionFlags + true, // repeats + NSIntegerMin, // order + &NotBusyObserver, // CFRunLoopObserverCallBack + NULL); // CFRunLoopObserverContext CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop]; CFRunLoopAddObserver(runLoop, busyObserver, kCFRunLoopDefaultMode); @@ -95,29 +102,33 @@ CFRelease(busyObserver); CFRelease(notBusyObserver); - - if (!headless) setBusy(YES); + + setBusy(YES); +} + +static void setUpAppKitThreadName() +{ + BOOL verbose = ShouldPrintVerboseDebugging(); + JNIEnv *env = [ThreadUtilities getJNIEnv]; // Set the java name of the AppKit main thread appropriately. jclass threadClass = NULL; jstring name = NULL; jobject curThread = NULL; - if (!swt_mode) { - threadClass = (*env)->FindClass(env, "java/lang/Thread"); - if (threadClass == NULL || (*env)->ExceptionCheck(env)) goto cleanup; - jmethodID currentThreadID = (*env)->GetStaticMethodID(env, threadClass, "currentThread", "()Ljava/lang/Thread;"); - if (currentThreadID == NULL || (*env)->ExceptionCheck(env)) goto cleanup; - jmethodID setName = (*env)->GetMethodID(env, threadClass, "setName", "(Ljava/lang/String;)V"); - if (setName == NULL || (*env)->ExceptionCheck(env)) goto cleanup; + threadClass = (*env)->FindClass(env, "java/lang/Thread"); + if (threadClass == NULL || (*env)->ExceptionCheck(env)) goto cleanup; + jmethodID currentThreadID = (*env)->GetStaticMethodID(env, threadClass, "currentThread", "()Ljava/lang/Thread;"); + if (currentThreadID == NULL || (*env)->ExceptionCheck(env)) goto cleanup; + jmethodID setName = (*env)->GetMethodID(env, threadClass, "setName", "(Ljava/lang/String;)V"); + if (setName == NULL || (*env)->ExceptionCheck(env)) goto cleanup; - curThread = (*env)->CallStaticObjectMethod(env, threadClass, currentThreadID); // AWT_THREADING Safe (known object) - if (curThread == NULL || (*env)->ExceptionCheck(env)) goto cleanup; - name = (*env)->NewStringUTF(env, "AWT-AppKit"); - if (name == NULL || (*env)->ExceptionCheck(env)) goto cleanup; - (*env)->CallVoidMethod(env, curThread, setName, name); // AWT_THREADING Safe (known object) - if ((*env)->ExceptionCheck(env)) goto cleanup; - } + curThread = (*env)->CallStaticObjectMethod(env, threadClass, currentThreadID); // AWT_THREADING Safe (known object) + if (curThread == NULL || (*env)->ExceptionCheck(env)) goto cleanup; + name = (*env)->NewStringUTF(env, "AWT-AppKit"); + if (name == NULL || (*env)->ExceptionCheck(env)) goto cleanup; + (*env)->CallVoidMethod(env, curThread, setName, name); // AWT_THREADING Safe (known object) + if ((*env)->ExceptionCheck(env)) goto cleanup; cleanup: if (threadClass != NULL) { @@ -134,14 +145,10 @@ (*env)->ExceptionClear(env); } - // Add the exception handler of last resort - NSSetUncaughtExceptionHandler(AWT_NSUncaughtExceptionHandler); - if (verbose) AWT_DEBUG_LOG(@"finished setting thread name"); } - // Returns true if java believes it is running headless BOOL isHeadless(JNIEnv *env) { // Just access the property directly, instead of using GraphicsEnvironment.isHeadless. @@ -200,7 +207,7 @@ // This is an empty Obj-C object just so that -peformSelectorOnMainThread can be used. @interface AWTStarter : NSObject { } -+ (void)start:(BOOL)headless swtMode:(BOOL)swtMode swtModeForWebStart:(BOOL)swtModeForWebStart; ++ (void)start:(BOOL)headless; - (void)starter:(NSArray*)args; + (void)appKitIsRunning:(id)arg; @end @@ -242,7 +249,7 @@ if (verbose) AWT_DEBUG_LOG(@"finished messaging AppKit started"); } -+ (void)start:(BOOL)headless swtMode:(BOOL)swtMode swtModeForWebStart:(BOOL)swtModeForWebStart ++ (void)start:(BOOL)headless { BOOL verbose = ShouldPrintVerboseDebugging(); @@ -258,7 +265,7 @@ BOOL onMainThread = (pthread_main_np() != 0); if (verbose) { - NSString *msg = [NSString stringWithFormat:@"+[AWTStarter start headless:%d swtMode:%d swtModeForWebStart:%d] { onMainThread:%d }", headless, swtMode, swtModeForWebStart, onMainThread]; + NSString *msg = [NSString stringWithFormat:@"+[AWTStarter start headless:%d] { onMainThread:%d }", headless, onMainThread]; AWT_DEBUG_LOG(msg); } @@ -280,9 +287,7 @@ NSArray * args = [NSArray arrayWithObjects: [NSNumber numberWithBool: onMainThread], - [NSNumber numberWithBool: swtMode], [NSNumber numberWithBool: headless], - [NSNumber numberWithBool: swtModeForWebStart], [NSNumber numberWithBool: verbose], nil]; @@ -310,39 +315,38 @@ // Don't set the delegate until the NSApplication has been created and // its finishLaunching has initialized it. // ApplicationDelegate is the support code for com.apple.eawt. - void (^setDelegateBlock)() = ^(){ + [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]); - }; - if (onMainThread) { - setDelegateBlock(); - } else { - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:setDelegateBlock]; - } + }]; } - (void)starter:(NSArray*)args { NSAutoreleasePool *pool = [NSAutoreleasePool new]; BOOL onMainThread = [[args objectAtIndex:0] boolValue]; - BOOL swtMode = [[args objectAtIndex:1] boolValue]; - BOOL headless = [[args objectAtIndex:2] boolValue]; - BOOL swtModeForWebStart = [[args objectAtIndex:3] boolValue]; - BOOL verbose = [[args objectAtIndex:4] boolValue]; + BOOL headless = [[args objectAtIndex:1] boolValue]; + BOOL verbose = [[args objectAtIndex:2] boolValue]; BOOL wasOnMainThread = onMainThread; - setUpAWTAppKit(swtMode, headless); + // Add the exception handler of last resort + NSSetUncaughtExceptionHandler(AWT_NSUncaughtExceptionHandler); // Headless mode trumps either ordinary AWT or SWT-in-AWT mode. Declare us a daemon and return. if (headless) { - BOOL didBecomeDaemon = [AWTStarter markAppAsDaemon]; + if (!forceEmbeddedMode) { + setUpAppKitThreadName(); + } + [AWTStarter markAppAsDaemon]; return; } - if (swtMode || swtModeForWebStart) { + if (forceEmbeddedMode) { if (verbose) NSLog(@"in SWT or SWT/WebStart mode"); - // The SWT should call NSApplicationLoad, but they don't know a priori that they will be using the AWT, so they don't. + // Init a default NSApplication instance instead of the NSApplicationAWT. + // Note that [NSApp isRunning] will return YES after that, though + // this behavior isn't specified anywhere. We rely on that. NSApplicationLoad(); } @@ -351,6 +355,13 @@ // and -[NSApplication isRunning] returns YES, AWT is embedded inside another // AppKit Application. NSApplication *app = [NSApplicationAWT sharedApplication]; + isEmbedded = ![NSApp isKindOfClass:[NSApplicationAWT class]]; + + if (!isEmbedded) { + // Install run loop observers and set the AppKit Java thread name + setUpAWTAppKit(); + setUpAppKitThreadName(); + } // AWT gets to this point BEFORE NSApplicationDidFinishLaunchingNotification is sent. if (![app isRunning]) { @@ -360,17 +371,11 @@ [NSApplicationAWT runAWTLoopWithApp: app]; } else { // We're either embedded, or showing a splash screen - if (![NSApp isKindOfClass:[NSApplicationAWT class]]) { + if (isEmbedded) { if (verbose) AWT_DEBUG_LOG(@"running embedded"); - // Since we're embedded, no need to be swamping the runloop with the observers. - CFRunLoopRef runLoop = [[NSRunLoop currentRunLoop] getCFRunLoop]; - CFRunLoopRemoveObserver(runLoop, busyObserver, kCFRunLoopDefaultMode); - CFRunLoopRemoveObserver(runLoop, notBusyObserver, kCFRunLoopDefaultMode); // We don't track if the runloop is busy, so set it free to let AWT finish when it needs setBusy(NO); - busyObserver = NULL; - notBusyObserver = NULL; } else { if (verbose) AWT_DEBUG_LOG(@"running after showing a splash screen"); } @@ -408,49 +413,28 @@ return JNI_VERSION_1_4; } - // The following is true when AWT is attempting to connect to the window server - // when it isn't set up properly to do so. - // BOOL AWTLoadFailure = YES; For now we are skipping this check so i'm commenting out this variable as unused JNF_COCOA_ENTER(env); - // If -XstartOnFirstThread was used at invocation time, an environment variable will be set. - // (See java_md.c for the matching setenv call.) When that happens, we assume the SWT will be in use. - BOOL swt_compatible_mode = NO; - + // Launcher sets this env variable if -XstartOnFirstThread is specified char envVar[80]; snprintf(envVar, sizeof(envVar), "JAVA_STARTED_ON_FIRST_THREAD_%d", getpid()); if (getenv(envVar) != NULL) { - swt_compatible_mode = YES; + forceEmbeddedMode = YES; unsetenv(envVar); } - BOOL swt_in_webstart = isSWTInWebStart(env); - BOOL headless = isHeadless(env); + if (isSWTInWebStart(env)) { + forceEmbeddedMode = YES; + } - // Make sure we're on the right thread. If not, we still need the JNIEnv to throw an exception. - if (pthread_main_np() != 0 && !swt_compatible_mode && !headless) { - AWT_DEBUG_LOG(@"Apple AWT Java VM was loaded on first thread -- can't start AWT."); - [JNFException raise:env as:kInternalError reason:"Can't start the AWT because Java was started on the first thread. Make sure StartOnFirstThread is " - "not specified in your application's Info.plist or on the command line"]; - return JNI_VERSION_1_4; - } + BOOL headless = isHeadless(env); // We need to let Foundation know that this is a multithreaded application, if it isn't already. if (![NSThread isMultiThreaded]) { [NSThread detachNewThreadSelector:nil toTarget:nil withObject:nil]; } -// if (swt_compatible_mode || headless || [AWTStarter isConnectedToWindowServer] || [AWTStarter isRemoteSession]) { -// No need in this check - we will try to launch AWTStarter anyways - to be able to run GUI application remotely -// AWTLoadFailure = NO; - - [AWTStarter start:headless swtMode:swt_compatible_mode swtModeForWebStart:swt_in_webstart]; - -// } - -/* if (AWTLoadFailure) { // We will not reach this code anyways - [JNFException raise:env as:kInternalError reason:"Can't connect to window server - not enough permissions."]; - } */ + [AWTStarter start:headless]; JNF_COCOA_EXIT(env); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/osxapp/ThreadUtilities.h --- a/src/macosx/native/sun/osxapp/ThreadUtilities.h Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/osxapp/ThreadUtilities.h Mon Feb 04 17:29:58 2013 -0400 @@ -98,8 +98,6 @@ } \ } while (0) -#define AWT_ASSERT_ANY_THREAD - #endif /* AWT_THREAD_ASSERTS_MESSAGES */ #ifdef AWT_THREAD_ASSERTS_WAIT @@ -114,15 +112,12 @@ while (pthread_main_np() != 0) {} \ } while (0) -#define AWT_ASSERT_ANY_THREAD - #endif /* AWT_THREAD_ASSERTS_WAIT */ #else /* AWT_THREAD_ASSERTS */ #define AWT_ASSERT_APPKIT_THREAD do {} while (0) #define AWT_ASSERT_NOT_APPKIT_THREAD do {} while (0) -#define AWT_ASSERT_ANY_THREAD #endif /* AWT_THREAD_ASSERTS */ // -------------------------------------------------------------------------- @@ -139,7 +134,10 @@ + (JNIEnv*)getJNIEnvUncached; + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT; + +//Wrappers for the corresponding JNFRunLoop methods with a check for main thread + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block; ++ (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait; @end void OSXAPP_SetJavaVM(JavaVM *vm); diff -r a8bbd962f34a -r 41654275896d src/macosx/native/sun/osxapp/ThreadUtilities.m --- a/src/macosx/native/sun/osxapp/ThreadUtilities.m Mon Jan 28 16:29:10 2013 -0400 +++ b/src/macosx/native/sun/osxapp/ThreadUtilities.m Mon Feb 04 17:29:58 2013 -0400 @@ -37,27 +37,13 @@ static NSArray *sPerformModes = nil; static NSArray *sAWTPerformModes = nil; -static BOOL sCocoaComponentCompatibility = NO; -static NSTimeInterval sCocoaComponentCompatibilityTimeout = 0.5; static BOOL sLoggingEnabled = YES; #ifdef AWT_THREAD_ASSERTS_ENV_ASSERT int sAWTThreadAsserts = 0; #endif /* AWT_THREAD_ASSERTS_ENV_ASSERT */ - -// This is for backward compatibility for those people using CocoaComponent -// Since we've flipped the AWT threading model for Tiger (10.4), all the rules -// for CocoaComponent are wrong. -// So for existing CocoaComponent users, we can't be synchronous. -// Making things totally asynchronous breaks a _lot_, so we try to be -// synchronous and time out after a little bit. -#define NOT_READY 0 -#define READY 1 -#define IN_PROGRESS 2 - BOOL sInPerformFromJava = NO; -NSUInteger sPerformCount = 0; // This class is used so that performSelectorOnMainThread can be // controlled a little more easily by us. It has 2 roles. @@ -73,8 +59,6 @@ - (id) initWithTarget:(id)target selector:(SEL)selector arg:(id)arg wait:(BOOL)wait; - (void) perform; -- (void) performCompatible; -- (void) _performCompatible:(NSConditionLock *)resultLock; @end @@ -113,8 +97,6 @@ sInPerformFromJava = YES; } - sPerformCount++; - // Actually do the work (cheat to avoid a method call) @try { objc_msgSend(fTarget, fSelector, fArg); @@ -128,69 +110,6 @@ } } } - -- (void) performCompatible { - // We check if we are on the AppKit thread because frequently, apps - // using CocoaComponent are doing things on the wrong thread! - if (pthread_main_np()) { - [fTarget performSelector:fSelector withObject:fArg]; - } else { - // Setup the lock - NSConditionLock *resultLock = - [[NSConditionLock alloc] initWithCondition:NOT_READY]; - - // Make sure that if we return early, nothing gets released out - // from under us - [resultLock retain]; - [fTarget retain]; - [fArg retain]; - [self retain]; - // Do an asynchronous perform to the main thread. - [self performSelectorOnMainThread:@selector(_performCompatible:) - withObject:resultLock waitUntilDone:NO modes:sAWTPerformModes]; - - // Wait for a little bit for it to finish - [resultLock lockWhenCondition:READY beforeDate:[NSDate dateWithTimeIntervalSinceNow:sCocoaComponentCompatibilityTimeout]]; - - // If the _performCompatible is actually in progress, - // we should let it finish - if ([resultLock condition] == IN_PROGRESS) { - [resultLock lockWhenCondition:READY]; - } - - if ([resultLock condition] == NOT_READY && sLoggingEnabled) { - NSLog(@"[Java CocoaComponent compatibility mode]: Operation timed out due to possible deadlock: selector '%@' on target '%@' with args '%@'", NSStringFromSelector(fSelector), fTarget, fArg); - } - - [resultLock unlock]; - [resultLock autorelease]; - } -} - -- (void) _performCompatible:(NSConditionLock *)resultLock { - // notify that the perform is in progress! - [resultLock lock]; - [resultLock unlockWithCondition:IN_PROGRESS]; - - sPerformCount++; - - // Actually do the work. - @try { - [fTarget performSelector:fSelector withObject:fArg]; - } @catch (NSException *e) { - NSLog(@"*** CPerformer: ignoring exception '%@' raised during performCompatible of selector '%@' on target '%@' with args '%@'", e, NSStringFromSelector(fSelector), fTarget, fArg); - } @finally { - // notify done! - [resultLock lock]; - [resultLock unlockWithCondition:READY]; - - // Clean up after ourselves - [resultLock autorelease]; - [fTarget autorelease]; - [fArg autorelease]; - [self autorelease]; - } -} @end @@ -236,13 +155,8 @@ // java event thread without deadlocking. See CToolkit.invokeAndWait. + (void)performOnMainThread:(SEL)aSelector onObject:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait awtMode:(BOOL)inAWT { CPerformer *performer = [[CPerformer alloc] initWithTarget:target selector:aSelector arg:arg wait:wait]; - if (sCocoaComponentCompatibility && wait && inAWT) { - [performer performCompatible]; - [performer autorelease]; - } else { - [performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:wait modes:((inAWT) ? sAWTPerformModes : sPerformModes)]; // AWT_THREADING Safe (cover method) - [performer release]; - } + [performer performSelectorOnMainThread:@selector(perform) withObject:nil waitUntilDone:wait modes:((inAWT) ? sAWTPerformModes : sPerformModes)]; // AWT_THREADING Safe (cover method) + [performer release]; } + (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block { @@ -253,6 +167,14 @@ } } ++ (void)performOnMainThread:(SEL)aSelector on:(id)target withObject:(id)arg waitUntilDone:(BOOL)wait { + if ([NSThread isMainThread] && wait == YES) { + [target performSelector:aSelector withObject:arg]; + } else { + [JNFRunLoop performOnMainThread:aSelector on:target withObject:arg waitUntilDone:wait]; + } +} + @end diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java --- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Mon Feb 04 17:29:58 2013 -0400 @@ -787,7 +787,6 @@ "List.font", new FontLazyValue(Region.LIST), "List.rendererUseUIBorder", Boolean.FALSE, - "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK}, "Menu.arrowIcon", new GTKStyle.GTKLazyValue( "com.sun.java.swing.plaf.gtk.GTKIconFactory", "getMenuArrowIcon"), diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java --- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java Mon Feb 04 17:29:58 2013 -0400 @@ -630,8 +630,10 @@ "Menu.menuPopupOffsetY", new Integer(0), "Menu.submenuPopupOffsetX", new Integer(-2), "Menu.submenuPopupOffsetY", new Integer(3), - "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK, - KeyEvent.META_MASK}, + "Menu.shortcutKeys", new int[]{ + SwingUtilities2.getSystemMnemonicKeyMask(), + KeyEvent.META_MASK + }, "Menu.cancelMode", "hideMenuTree", "MenuBar.border", menuBarBorder, diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Feb 04 17:29:58 2013 -0400 @@ -2619,13 +2619,15 @@ private static class FocusColorProperty extends DesktopProperty { public FocusColorProperty () { - // Fallback value is never used bacause of the configureValue method doesn't return null + // Fallback value is never used because of the configureValue method doesn't return null super("win.3d.backgroundColor", Color.BLACK); } @Override protected Object configureValue(Object value) { - if (! ((Boolean)Toolkit.getDefaultToolkit().getDesktopProperty("win.highContrast.on")).booleanValue()){ + Object highContrastOn = Toolkit.getDefaultToolkit(). + getDesktopProperty("win.highContrast.on"); + if (highContrastOn == null || !((Boolean) highContrastOn).booleanValue()) { return Color.BLACK; } return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK; diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java Mon Feb 04 17:29:58 2013 -0400 @@ -93,6 +93,11 @@ counter = endRow; } } + + if (testRect == null) { + return; + } + tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1, testRect.y + testRect.height- beginY)); diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/Attribute.java --- a/src/share/classes/com/sun/java/util/jar/pack/Attribute.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/Attribute.java Mon Feb 04 17:29:58 2013 -0400 @@ -1287,19 +1287,24 @@ if (localRef == 0) { globalRef = null; // N.B. global null reference is -1 } else { - globalRef = holder.getCPMap()[localRef]; - if (e.refKind == CONSTANT_Signature + Entry[] cpMap = holder.getCPMap(); + globalRef = (localRef >= 0 && localRef < cpMap.length + ? cpMap[localRef] + : null); + byte tag = e.refKind; + if (globalRef != null && tag == CONSTANT_Signature && globalRef.getTag() == CONSTANT_Utf8) { // Cf. ClassReader.readSignatureRef. String typeName = globalRef.stringValue(); globalRef = ConstantPool.getSignatureEntry(typeName); - } else if (e.refKind == CONSTANT_FieldSpecific) { - assert(globalRef.getTag() >= CONSTANT_Integer); - assert(globalRef.getTag() <= CONSTANT_String || - globalRef.getTag() >= CONSTANT_MethodHandle); - assert(globalRef.getTag() <= CONSTANT_MethodType); - } else if (e.refKind < CONSTANT_GroupFirst) { - assert(e.refKind == globalRef.getTag()); + } + String got = (globalRef == null + ? "invalid CP index" + : "type=" + ConstantPool.tagName(globalRef.tag)); + if (globalRef == null || !globalRef.tagMatches(tag)) { + throw new IllegalArgumentException( + "Bad constant, expected type=" + + ConstantPool.tagName(tag) + " got " + got); } } out.putRef(bandIndex, globalRef); diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/ClassReader.java --- a/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,6 +54,7 @@ Package pkg; Class cls; long inPos; + long constantPoolLimit = -1; DataInputStream in; Map attrDefs; Map attrCommands; @@ -117,15 +118,33 @@ private Entry readRef(byte tag) throws IOException { Entry e = readRef(); - assert(e != null); assert(!(e instanceof UnresolvedEntry)); - assert(e.tagMatches(tag)); + checkTag(e, tag); return e; } + /** Throw a ClassFormatException if the entry does not match the expected tag type. */ + private Entry checkTag(Entry e, byte tag) throws ClassFormatException { + if (e == null || !e.tagMatches(tag)) { + String where = (inPos == constantPoolLimit + ? " in constant pool" + : " at pos: " + inPos); + String got = (e == null + ? "null CP index" + : "type=" + ConstantPool.tagName(e.tag)); + throw new ClassFormatException("Bad constant, expected type=" + + ConstantPool.tagName(tag) + + " got "+ got + ", in File: " + cls.file.nameString + where); + } + return e; + } + private Entry checkTag(Entry e, byte tag, boolean nullOK) throws ClassFormatException { + return nullOK && e == null ? null : checkTag(e, tag); + } + private Entry readRefOrNull(byte tag) throws IOException { Entry e = readRef(); - assert(e == null || e.tagMatches(tag)); + checkTag(e, tag, true); return e; } @@ -143,8 +162,10 @@ private SignatureEntry readSignatureRef() throws IOException { // The class file stores a Utf8, but we want a Signature. - Entry e = readRef(CONSTANT_Utf8); - return ConstantPool.getSignatureEntry(e.stringValue()); + Entry e = readRef(CONSTANT_Signature); + return (e != null && e.getTag() == CONSTANT_Utf8) + ? ConstantPool.getSignatureEntry(e.stringValue()) + : (SignatureEntry) e; } void read() throws IOException { @@ -279,6 +300,7 @@ " at pos: " + inPos); } } + constantPoolLimit = inPos; // Fix up refs, which might be out of order. while (fptr > 0) { @@ -311,25 +333,25 @@ case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: - ClassEntry mclass = (ClassEntry) cpMap[ref]; - DescriptorEntry mdescr = (DescriptorEntry) cpMap[ref2]; + ClassEntry mclass = (ClassEntry) checkTag(cpMap[ref], CONSTANT_Class); + DescriptorEntry mdescr = (DescriptorEntry) checkTag(cpMap[ref2], CONSTANT_NameandType); cpMap[cpi] = ConstantPool.getMemberEntry((byte)tag, mclass, mdescr); break; case CONSTANT_NameandType: - Utf8Entry mname = (Utf8Entry) cpMap[ref]; - Utf8Entry mtype = (Utf8Entry) cpMap[ref2]; + Utf8Entry mname = (Utf8Entry) checkTag(cpMap[ref], CONSTANT_Utf8); + Utf8Entry mtype = (Utf8Entry) checkTag(cpMap[ref2], CONSTANT_Signature); cpMap[cpi] = ConstantPool.getDescriptorEntry(mname, mtype); break; case CONSTANT_MethodType: - cpMap[cpi] = ConstantPool.getMethodTypeEntry((Utf8Entry) cpMap[ref]); + cpMap[cpi] = ConstantPool.getMethodTypeEntry((Utf8Entry) checkTag(cpMap[ref], CONSTANT_Signature)); break; case CONSTANT_MethodHandle: byte refKind = (byte)(-1 ^ ref); - MemberEntry memRef = (MemberEntry) cpMap[ref2]; + MemberEntry memRef = (MemberEntry) checkTag(cpMap[ref2], CONSTANT_AnyMember); cpMap[cpi] = ConstantPool.getMethodHandleEntry(refKind, memRef); break; case CONSTANT_InvokeDynamic: - DescriptorEntry idescr = (DescriptorEntry) cpMap[ref2]; + DescriptorEntry idescr = (DescriptorEntry) checkTag(cpMap[ref2], CONSTANT_NameandType); cpMap[cpi] = new UnresolvedEntry((byte)tag, (-1 ^ ref), idescr); // Note that ref must be resolved later, using the BootstrapMethods attribute. break; @@ -541,7 +563,8 @@ code.max_locals = readUnsignedShort(); code.bytes = new byte[readInt()]; in.readFully(code.bytes); - Instruction.opcodeChecker(code.bytes); + Entry[] cpMap = cls.getCPMap(); + Instruction.opcodeChecker(code.bytes, cpMap); int nh = readUnsignedShort(); code.setHandlerCount(nh); for (int i = 0; i < nh; i++) { @@ -559,7 +582,7 @@ MethodHandleEntry bsmRef = (MethodHandleEntry) readRef(CONSTANT_MethodHandle); Entry[] argRefs = new Entry[readUnsignedShort()]; for (int j = 0; j < argRefs.length; j++) { - argRefs[j] = readRef(); + argRefs[j] = readRef(CONSTANT_LoadableValue); } bsms[i] = ConstantPool.getBootstrapMethodEntry(bsmRef, argRefs); } diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java --- a/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -243,8 +243,32 @@ return tag == CONSTANT_Double || tag == CONSTANT_Long; } - public final boolean tagMatches(int tag) { - return (this.tag == tag); + public final boolean tagMatches(int matchTag) { + if (tag == matchTag) + return true; + byte[] allowedTags; + switch (matchTag) { + case CONSTANT_All: + return true; + case CONSTANT_Signature: + return tag == CONSTANT_Utf8; // format check also? + case CONSTANT_LoadableValue: + allowedTags = LOADABLE_VALUE_TAGS; + break; + case CONSTANT_AnyMember: + allowedTags = ANY_MEMBER_TAGS; + break; + case CONSTANT_FieldSpecific: + allowedTags = FIELD_SPECIFIC_TAGS; + break; + default: + return false; + } + for (byte b : allowedTags) { + if (b == tag) + return true; + } + return false; } public String toString() { diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/Instruction.java --- a/src/share/classes/com/sun/java/util/jar/pack/Instruction.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/Instruction.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -647,7 +647,7 @@ } } - public static void opcodeChecker(byte[] code) throws FormatException { + public static void opcodeChecker(byte[] code, ConstantPool.Entry[] cpMap) throws FormatException { Instruction i = at(code, 0); while (i != null) { int opcode = i.getBC(); @@ -655,6 +655,16 @@ String message = "illegal opcode: " + opcode + " " + i; throw new FormatException(message); } + ConstantPool.Entry e = i.getCPRef(cpMap); + if (e != null) { + byte tag = i.getCPTag(); + if (!e.tagMatches(tag)) { + String message = "illegal reference, expected type=" + + ConstantPool.tagName(tag) + ": " + + i.toString(cpMap); + throw new FormatException(message); + } + } i = i.next(); } } diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java --- a/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java Mon Feb 04 17:29:58 2013 -0400 @@ -1618,6 +1618,16 @@ bc_which = null; assert(false); } + if (ref != null && bc_which.index != null && !bc_which.index.contains(ref)) { + // Crash and burn with a complaint if there are funny + // references for this bytecode instruction. + // Example: invokestatic of a CONSTANT_InterfaceMethodref. + String complaint = code.getMethod() + + " contains a bytecode " + i + + " with an unsupported constant reference; please use the pass-file option on this class."; + Utils.log.warning(complaint); + throw new IOException(complaint); + } bc_codes.putByte(vbc); bc_which.putRef(ref); // handle trailing junk diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java --- a/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,6 +180,15 @@ } unknownAttrCommand = uaMode.intern(); } + final String classFormatCommand; + { + String fmtMode = props.getProperty(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS); + if (!(Pack200.Packer.PASS.equals(fmtMode) || + Pack200.Packer.ERROR.equals(fmtMode))) { + throw new RuntimeException("Bad option: " + Utils.CLASS_FORMAT_ERROR + " = " + fmtMode); + } + classFormatCommand = fmtMode.intern(); + } final Map attrDefs; final Map attrCommands; @@ -505,8 +514,7 @@ } } else if (ioe instanceof ClassReader.ClassFormatException) { ClassReader.ClassFormatException ce = (ClassReader.ClassFormatException) ioe; - // %% TODO: Do we invent a new property for this or reuse %% - if (unknownAttrCommand.equals(Pack200.Packer.PASS)) { + if (classFormatCommand.equals(Pack200.Packer.PASS)) { Utils.log.info(ce.toString()); Utils.log.warning(message + " unknown class format: " + fname); diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/PropMap.java --- a/src/share/classes/com/sun/java/util/jar/pack/PropMap.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/PropMap.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -112,6 +112,11 @@ // Pass through files with unrecognized attributes by default. props.put(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.PASS); + // Pass through files with unrecognized format by default, also + // allow system property to be set + props.put(Utils.CLASS_FORMAT_ERROR, + System.getProperty(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS)); + // Default effort is 5, midway between 1 and 9. props.put(Pack200.Packer.EFFORT, "5"); diff -r a8bbd962f34a -r 41654275896d src/share/classes/com/sun/java/util/jar/pack/Utils.java --- a/src/share/classes/com/sun/java/util/jar/pack/Utils.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/com/sun/java/util/jar/pack/Utils.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,6 +122,12 @@ */ static final String PACK_ZIP_ARCHIVE_MARKER_COMMENT = "PACK200"; + /* + * behaviour when we hit a class format error, but not necessarily + * an unknown attribute, by default it is allowed to PASS. + */ + static final String CLASS_FORMAT_ERROR = COM_PREFIX+"class.format.error"; + // Keep a TLS point to the global data and environment. // This makes it simpler to supply environmental options // to the engine code, especially the native code. diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Button.java --- a/src/share/classes/java/awt/Button.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Button.java Mon Feb 04 17:29:58 2013 -0400 @@ -300,7 +300,7 @@ * @since 1.4 */ public synchronized ActionListener[] getActionListeners() { - return (ActionListener[]) (getListeners(ActionListener.class)); + return getListeners(ActionListener.class); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Checkbox.java --- a/src/share/classes/java/awt/Checkbox.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Checkbox.java Mon Feb 04 17:29:58 2013 -0400 @@ -470,7 +470,7 @@ * @since 1.4 */ public synchronized ItemListener[] getItemListeners() { - return (ItemListener[]) (getListeners(ItemListener.class)); + return getListeners(ItemListener.class); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Choice.java --- a/src/share/classes/java/awt/Choice.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Choice.java Mon Feb 04 17:29:58 2013 -0400 @@ -85,7 +85,7 @@ * @see #insert(String, int) * @see #remove(String) */ - Vector pItems; + Vector pItems; /** * The index of the current choice for this Choice @@ -129,7 +129,7 @@ */ public Choice() throws HeadlessException { GraphicsEnvironment.checkHeadless(); - pItems = new Vector(); + pItems = new Vector<>(); } /** @@ -191,7 +191,7 @@ * be called on the toolkit thread. */ final String getItemImpl(int index) { - return (String)pItems.elementAt(index); + return pItems.elementAt(index); } /** @@ -524,7 +524,7 @@ * @since 1.4 */ public synchronized ItemListener[] getItemListeners() { - return (ItemListener[])(getListeners(ItemListener.class)); + return getListeners(ItemListener.class); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Component.java --- a/src/share/classes/java/awt/Component.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Component.java Mon Feb 04 17:29:58 2013 -0400 @@ -7287,6 +7287,7 @@ } final Set getFocusTraversalKeys_NoIDCheck(int id) { // Okay to return Set directly because it is an unmodifiable view + @SuppressWarnings("unchecked") Set keystrokes = (focusTraversalKeys != null) ? focusTraversalKeys[id] : null; diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Container.java --- a/src/share/classes/java/awt/Container.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Container.java Mon Feb 04 17:29:58 2013 -0400 @@ -161,7 +161,7 @@ private boolean focusTraversalPolicyProvider; // keeps track of the threads that are printing this component - private transient Set printingThreads; + private transient Set printingThreads; // True if there is at least one thread that's printing this component private transient boolean printing = false; @@ -275,7 +275,7 @@ */ public Container() { } - + @SuppressWarnings({"unchecked","rawtypes"}) void initializeFocusTraversalKeys() { focusTraversalKeys = new Set[4]; } @@ -2006,7 +2006,7 @@ try { synchronized (getObjectLock()) { if (printingThreads == null) { - printingThreads = new HashSet(); + printingThreads = new HashSet<>(); } printingThreads.add(t); printing = true; @@ -2148,7 +2148,7 @@ * @since 1.4 */ public synchronized ContainerListener[] getContainerListeners() { - return (ContainerListener[]) (getListeners(ContainerListener.class)); + return getListeners(ContainerListener.class); } /** @@ -2599,9 +2599,9 @@ if (GraphicsEnvironment.isHeadless()) { throw new HeadlessException(); } - PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { + PointerInfo pi = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PointerInfo run() { return MouseInfo.getPointerInfo(); } } @@ -2682,7 +2682,7 @@ y - comp.y, ignoreEnabled); } else { - comp = comp.locate(x - comp.x, y - comp.y); + comp = comp.getComponentAt(x - comp.x, y - comp.y); } if (comp != null && comp.visible && (ignoreEnabled || comp.enabled)) @@ -2700,7 +2700,7 @@ y - comp.y, ignoreEnabled); } else { - comp = comp.locate(x - comp.x, y - comp.y); + comp = comp.getComponentAt(x - comp.x, y - comp.y); } if (comp != null && comp.visible && (ignoreEnabled || comp.enabled)) @@ -4637,7 +4637,7 @@ private void startListeningForOtherDrags() { //System.out.println("Adding AWTEventListener"); java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { + new java.security.PrivilegedAction() { public Object run() { nativeContainer.getToolkit().addAWTEventListener( LightweightDispatcher.this, @@ -4652,7 +4652,7 @@ private void stopListeningForOtherDrags() { //System.out.println("Removing AWTEventListener"); java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { + new java.security.PrivilegedAction() { public Object run() { nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this); return null; diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Dialog.java --- a/src/share/classes/java/awt/Dialog.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Dialog.java Mon Feb 04 17:29:58 2013 -0400 @@ -1047,9 +1047,9 @@ // if this dialog is toolkit-modal, the filter should be added // to all EDTs (for all AppContexts) if (modalityType == ModalityType.TOOLKIT_MODAL) { - Iterator it = AppContext.getAppContexts().iterator(); + Iterator it = AppContext.getAppContexts().iterator(); while (it.hasNext()) { - AppContext appContext = (AppContext)it.next(); + AppContext appContext = it.next(); if (appContext == showAppContext) { continue; } @@ -1084,9 +1084,9 @@ // if this dialog is toolkit-modal, its filter must be removed // from all EDTs (for all AppContexts) if (modalityType == ModalityType.TOOLKIT_MODAL) { - Iterator it = AppContext.getAppContexts().iterator(); + Iterator it = AppContext.getAppContexts().iterator(); while (it.hasNext()) { - AppContext appContext = (AppContext)it.next(); + AppContext appContext = it.next(); if (appContext == showAppContext) { continue; } @@ -1396,7 +1396,7 @@ if (d.shouldBlock(this)) { Window w = d; while ((w != null) && (w != this)) { - w = (Window)(w.getOwner_NoClientCode()); + w = w.getOwner_NoClientCode(); } if ((w == this) || !shouldBlock(d) || (modalityType.compareTo(d.getModalityType()) < 0)) { blockers.add(d); @@ -1611,7 +1611,7 @@ setModal(modal); } - blockedWindows = new IdentityArrayList(); + blockedWindows = new IdentityArrayList<>(); } /* diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Frame.java --- a/src/share/classes/java/awt/Frame.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Frame.java Mon Feb 04 17:29:58 2013 -0400 @@ -353,7 +353,7 @@ * @serial * @see java.awt.Window#ownedWindowList */ - Vector ownedWindows; + Vector ownedWindows; private static final String base = "frame"; private static int nameCounter = 0; @@ -1242,7 +1242,7 @@ // if (ownedWindows != null) { for (int i = 0; i < ownedWindows.size(); i++) { - connectOwnedWindow((Window) ownedWindows.elementAt(i)); + connectOwnedWindow(ownedWindows.elementAt(i)); } ownedWindows = null; } diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/KeyboardFocusManager.java --- a/src/share/classes/java/awt/KeyboardFocusManager.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/KeyboardFocusManager.java Mon Feb 04 17:29:58 2013 -0400 @@ -416,7 +416,7 @@ } } - static Set initFocusTraversalKeysSet(String value, Set targetSet) { + static Set initFocusTraversalKeysSet(String value, Set targetSet) { StringTokenizer tokens = new StringTokenizer(value, ","); while (tokens.hasMoreTokens()) { targetSet.add(AWTKeyStroke.getAWTKeyStroke(tokens.nextToken())); diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Scrollbar.java --- a/src/share/classes/java/awt/Scrollbar.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Scrollbar.java Mon Feb 04 17:29:58 2013 -0400 @@ -1012,7 +1012,7 @@ * @since 1.4 */ public synchronized AdjustmentListener[] getAdjustmentListeners() { - return (AdjustmentListener[])(getListeners(AdjustmentListener.class)); + return getListeners(AdjustmentListener.class); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/TextArea.java --- a/src/share/classes/java/awt/TextArea.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/TextArea.java Mon Feb 04 17:29:58 2013 -0400 @@ -123,7 +123,7 @@ * Cache the Sets of forward and backward traversal keys so we need not * look them up each time. */ - private static Set forwardTraversalKeys, backwardTraversalKeys; + private static Set forwardTraversalKeys, backwardTraversalKeys; /* * JDK 1.1 serialVersionUID @@ -143,10 +143,10 @@ } forwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet( "ctrl TAB", - new HashSet()); + new HashSet()); backwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet( "ctrl shift TAB", - new HashSet()); + new HashSet()); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/TextComponent.java --- a/src/share/classes/java/awt/TextComponent.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/TextComponent.java Mon Feb 04 17:29:58 2013 -0400 @@ -606,7 +606,7 @@ * @since 1.4 */ public synchronized TextListener[] getTextListeners() { - return (TextListener[])(getListeners(TextListener.class)); + return getListeners(TextListener.class); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/TextField.java --- a/src/share/classes/java/awt/TextField.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/TextField.java Mon Feb 04 17:29:58 2013 -0400 @@ -507,7 +507,7 @@ * @since 1.4 */ public synchronized ActionListener[] getActionListeners() { - return (ActionListener[])(getListeners(ActionListener.class)); + return getListeners(ActionListener.class); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Toolkit.java --- a/src/share/classes/java/awt/Toolkit.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Toolkit.java Mon Feb 04 17:29:58 2013 -0400 @@ -863,7 +863,7 @@ new java.security.PrivilegedAction() { public Void run() { String nm = null; - Class cls = null; + Class cls = null; try { nm = System.getProperty("awt.toolkit"); try { diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/awt/Window.java --- a/src/share/classes/java/awt/Window.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/awt/Window.java Mon Feb 04 17:29:58 2013 -0400 @@ -441,7 +441,7 @@ transient Object anchor = new Object(); static class WindowDisposerRecord implements sun.java2d.DisposerRecord { final WeakReference owner; - final WeakReference weakThis; + final WeakReference weakThis; final WeakReference context; WindowDisposerRecord(AppContext context, Window victim) { owner = new WeakReference(victim.getOwner()); @@ -1542,6 +1542,7 @@ private static Window[] getWindows(AppContext appContext) { synchronized (Window.class) { Window realCopy[]; + @SuppressWarnings("unchecked") Vector> windowList = (Vector>)appContext.get(Window.class); if (windowList != null) { @@ -1866,7 +1867,7 @@ * @since 1.4 */ public synchronized WindowListener[] getWindowListeners() { - return (WindowListener[])(getListeners(WindowListener.class)); + return getListeners(WindowListener.class); } /** @@ -1882,7 +1883,7 @@ * @since 1.4 */ public synchronized WindowFocusListener[] getWindowFocusListeners() { - return (WindowFocusListener[])(getListeners(WindowFocusListener.class)); + return getListeners(WindowFocusListener.class); } /** @@ -1898,7 +1899,7 @@ * @since 1.4 */ public synchronized WindowStateListener[] getWindowStateListeners() { - return (WindowStateListener[])(getListeners(WindowStateListener.class)); + return getListeners(WindowStateListener.class); } @@ -2014,7 +2015,6 @@ break; case WindowEvent.WINDOW_STATE_CHANGED: processWindowStateEvent((WindowEvent)e); - default: break; } return; @@ -2382,12 +2382,14 @@ * KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS * @since 1.4 */ + @SuppressWarnings("unchecked") public Set getFocusTraversalKeys(int id) { if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) { throw new IllegalArgumentException("invalid focus traversal key identifier"); } // Okay to return Set directly because it is an unmodifiable view + @SuppressWarnings("rawtypes") Set keystrokes = (focusTraversalKeys != null) ? focusTraversalKeys[id] : null; @@ -2765,7 +2767,7 @@ /* * Support for tracking all windows owned by this window */ - void addOwnedWindow(WeakReference weakWindow) { + void addOwnedWindow(WeakReference weakWindow) { if (weakWindow != null) { synchronized(ownedWindowList) { // this if statement should really be an assert, but we don't @@ -2777,7 +2779,7 @@ } } - void removeOwnedWindow(WeakReference weakWindow) { + void removeOwnedWindow(WeakReference weakWindow) { if (weakWindow != null) { // synchronized block not required since removeElement is // already synchronized @@ -2792,6 +2794,7 @@ private void addToWindowList() { synchronized (Window.class) { + @SuppressWarnings("unchecked") Vector> windowList = (Vector>)appContext.get(Window.class); if (windowList == null) { windowList = new Vector>(); @@ -2801,8 +2804,9 @@ } } - private static void removeFromWindowList(AppContext context, WeakReference weakThis) { + private static void removeFromWindowList(AppContext context, WeakReference weakThis) { synchronized (Window.class) { + @SuppressWarnings("unchecked") Vector> windowList = (Vector>)context.get(Window.class); if (windowList != null) { windowList.remove(weakThis); @@ -2945,7 +2949,7 @@ // Deserialized Windows are not yet visible. visible = false; - weakThis = new WeakReference(this); + weakThis = new WeakReference<>(this); anchor = new Object(); sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this)); @@ -2956,7 +2960,7 @@ private void deserializeResources(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException { - ownedWindowList = new Vector(); + ownedWindowList = new Vector<>(); if (windowSerializedDataVersion < 2) { // Translate old-style focus tracking to new model. For 1.4 and diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/Class.java --- a/src/share/classes/java/lang/Class.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/Class.java Mon Feb 04 17:29:58 2013 -0400 @@ -29,12 +29,14 @@ import java.lang.reflect.GenericArrayType; import java.lang.reflect.Member; import java.lang.reflect.Field; +import java.lang.reflect.Executable; import java.lang.reflect.Method; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.AnnotatedType; import java.lang.ref.SoftReference; import java.io.InputStream; import java.io.ObjectStreamField; @@ -2325,6 +2327,11 @@ // Annotations handling private native byte[] getRawAnnotations(); + // Since 1.8 + native byte[] getRawTypeAnnotations(); + static byte[] getExecutableTypeAnnotationBytes(Executable ex) { + return getReflectionFactory().getExecutableTypeAnnotationBytes(ex); + } native ConstantPool getConstantPool(); @@ -3068,11 +3075,12 @@ * @throws NullPointerException {@inheritDoc} * @since 1.5 */ + @SuppressWarnings("unchecked") public A getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); initAnnotationsIfNecessary(); - return AnnotationSupport.getOneAnnotation(annotations, annotationClass); + return (A) annotations.get(annotationClass); } /** @@ -3101,18 +3109,19 @@ */ public Annotation[] getAnnotations() { initAnnotationsIfNecessary(); - return AnnotationSupport.unpackToArray(annotations); + return AnnotationParser.toArray(annotations); } /** * @throws NullPointerException {@inheritDoc} * @since 1.8 */ + @SuppressWarnings("unchecked") public A getDeclaredAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); initAnnotationsIfNecessary(); - return AnnotationSupport.getOneAnnotation(declaredAnnotations, annotationClass); + return (A) declaredAnnotations.get(annotationClass); } /** @@ -3131,17 +3140,7 @@ */ public Annotation[] getDeclaredAnnotations() { initAnnotationsIfNecessary(); - return AnnotationSupport.unpackToArray(declaredAnnotations); - } - - /** Returns one "directly" present annotation or null */ - A getDirectDeclaredAnnotation(Class annotationClass) { - Objects.requireNonNull(annotationClass); - - initAnnotationsIfNecessary(); - @SuppressWarnings("unchecked") // TODO check safe - A ret = (A)declaredAnnotations.get(annotationClass); - return ret; + return AnnotationParser.toArray(declaredAnnotations); } // Annotations cache @@ -3196,4 +3195,53 @@ * Maintained by the ClassValue class. */ transient ClassValue.ClassValueMap classValueMap; + + /** + * Returns an AnnotatedType object that represents the use of a type to specify + * the superclass of the entity represented by this Class. (The use of type + * Foo to specify the superclass in '... extends Foo' is distinct from the + * declaration of type Foo.) + * + * If this Class represents a class type whose declaration does not explicitly + * indicate an annotated superclass, the return value is null. + * + * If this Class represents either the Object class, an interface type, an + * array type, a primitive type, or void, the return value is null. + * + * @since 1.8 + */ + public AnnotatedType getAnnotatedSuperclass() { + return TypeAnnotationParser.buildAnnotatedSuperclass(getRawTypeAnnotations(), getConstantPool(), this); } + + /** + * Returns an array of AnnotatedType objects that represent the use of types to + * specify superinterfaces of the entity represented by this Class. (The use + * of type Foo to specify a superinterface in '... implements Foo' is + * distinct from the declaration of type Foo.) + * + * If this Class represents a class, the return value is an array + * containing objects representing the uses of interface types to specify + * interfaces implemented by the class. The order of the objects in the + * array corresponds to the order of the interface types used in the + * 'implements' clause of the declaration of this Class. + * + * If this Class represents an interface, the return value is an array + * containing objects representing the uses of interface types to specify + * interfaces directly extended by the interface. The order of the objects in + * the array corresponds to the order of the interface types used in the + * 'extends' clause of the declaration of this Class. + * + * If this Class represents a class or interface whose declaration does not + * explicitly indicate any annotated superinterfaces, the return value is an + * array of length 0. + * + * If this Class represents either the Object class, an array type, a + * primitive type, or void, the return value is an array of length 0. + * + * @since 1.8 + */ + public AnnotatedType[] getAnnotatedInterfaces() { + return TypeAnnotationParser.buildAnnotatedInterfaces(getRawTypeAnnotations(), getConstantPool(), this); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/Double.java --- a/src/share/classes/java/lang/Double.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/Double.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -289,7 +289,7 @@ return Double.toString(d); else { // Initialized to maximum size of output. - StringBuffer answer = new StringBuffer(24); + StringBuilder answer = new StringBuilder(24); if (Math.copySign(1.0, d) == -1.0) // value is negative, answer.append("-"); // so append sign info @@ -300,8 +300,7 @@ if(d == 0.0) { answer.append("0.0p0"); - } - else { + } else { boolean subnormal = (d < DoubleConsts.MIN_NORMAL); // Isolate significand bits and OR in a high-order bit @@ -324,13 +323,14 @@ "0": signif.replaceFirst("0{1,12}$", "")); + answer.append('p'); // If the value is subnormal, use the E_min exponent // value for double; otherwise, extract and report d's // exponent (the representation of a subnormal uses // E_min -1). - answer.append("p" + (subnormal ? - DoubleConsts.MIN_EXPONENT: - Math.getExponent(d) )); + answer.append(subnormal ? + DoubleConsts.MIN_EXPONENT: + Math.getExponent(d)); } return answer.toString(); } diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/System.java --- a/src/share/classes/java/lang/System.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/System.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package java.lang; import java.io.*; -import java.lang.annotation.Annotation; +import java.lang.reflect.Executable; import java.util.Properties; import java.util.PropertyPermission; import java.util.StringTokenizer; @@ -1196,8 +1196,11 @@ public AnnotationType getAnnotationType(Class klass) { return klass.getAnnotationType(); } - public A getDirectDeclaredAnnotation(Class klass, Class anno) { - return klass.getDirectDeclaredAnnotation(anno); + public byte[] getRawClassTypeAnnotations(Class klass) { + return klass.getRawTypeAnnotations(); + } + public byte[] getRawExecutableTypeAnnotations(Executable executable) { + return Class.getExecutableTypeAnnotationBytes(executable); } public > E[] getEnumConstantsShared(Class klass) { diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/annotation/ContainedBy.java --- a/src/share/classes/java/lang/annotation/ContainedBy.java Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.lang.annotation; - -/** - * The annotation type {@code java.lang.annotation.ContainedBy} is - * used to indicate that the annotation type whose declaration it - * (meta-)annotates is repeatable. The value of - * {@code @ContainedBy} indicates the containing annotation - * type for the repeatable annotation type. - * - *

The pair of annotation types {@code @ContainedBy} and - * {@link java.lang.annotation.ContainerFor @ContainerFor} are used to - * indicate that annotation types are repeatable. Specifically: - * - *

    - *
  • The annotation type {@code @ContainedBy} is used on the - * declaration of a repeatable annotation type (JLS 9.6) to indicate - * its containing annotation type. - * - *
  • The annotation type {@code @ContainerFor} is used on the - * declaration of a containing annotation type (JLS 9.6) to indicate - * the repeatable annotation type for which it serves as the - * containing annotation type. - *
- * - *

- * An inconsistent pair of {@code @ContainedBy} and - * {@code @ContainerFor} annotations on a repeatable annotation type - * and its containing annotation type (JLS 9.6) will lead to - * compile-time errors and runtime exceptions when using reflection to - * read annotations of a repeatable type. - * - * @see java.lang.annotation.ContainerFor - * @since 1.8 - * @jls 9.6 Annotation Types - * @jls 9.7 Annotations - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface ContainedBy { - /** - * Indicates the containing annotation type for the - * repeatable annotation type. - */ - Class value(); -} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/annotation/ContainerFor.java --- a/src/share/classes/java/lang/annotation/ContainerFor.java Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java.lang.annotation; - -/** - * The annotation type {@code java.lang.annotation.ContainerFor} is - * used to indicate that the annotation type whose declaration it - * (meta-)annotates is a containing annotation type. The - * value of {@code @ContainerFor} indicates the repeatable - * annotation type for the containing annotation type. - * - *

The pair of annotation types {@link - * java.lang.annotation.ContainedBy @ContainedBy} and - * {@code @ContainerFor} are used to indicate that annotation types - * are repeatable. Specifically: - * - *

    - *
  • The annotation type {@code @ContainedBy} is used on the - * declaration of a repeatable annotation type (JLS 9.6) to indicate - * its containing annotation type. - * - *
  • The annotation type {@code @ContainerFor} is used on the - * declaration of a containing annotation type (JLS 9.6) to indicate - * the repeatable annotation type for which it serves as the - * containing annotation type. - *
- * - *

- * An inconsistent pair of {@code @ContainedBy} and - * {@code @ContainerFor} annotations on a repeatable annotation type - * and its containing annotation type (JLS 9.6) will lead to - * compile-time errors and runtime exceptions when using reflection to - * read annotations of a repeatable type. - * - * @see java.lang.annotation.ContainedBy - * @since 1.8 - * @jls 9.6 Annotation Types - * @jls 9.7 Annotations - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.ANNOTATION_TYPE) -public @interface ContainerFor { - - /** - * Indicates the repeatable annotation type for the containing - * annotation type. - */ - Class value(); -} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java --- a/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/annotation/InvalidContainerAnnotationError.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * 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,10 +27,9 @@ import java.util.Objects; /** - * Thrown to indicate that an annotation type whose declaration is - * (meta-)annotated with a {@link ContainerFor} annotation is not, in - * fact, the containing annotation type of the type named by {@link - * ContainerFor}. + * Thrown to indicate that an annotation type expected to act as a + * container for another annotation type by virture of an @Repeatable + * annotation, does not act as a container. * * @see java.lang.reflect.AnnotatedElement * @since 1.8 diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/AnnotatedArrayType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/lang/reflect/AnnotatedArrayType.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.reflect; + + +/** + * AnnotatedArrayType represents the use of an array type, whose component + * type may itself represent the annotated use of a type. + * + * @since 1.8 + */ +public interface AnnotatedArrayType extends AnnotatedType { + + /** + * Returns the annotated generic component type of this array type. + * + * @return the annotated generic component type of this array type + */ + AnnotatedType getAnnotatedGenericComponentType(); +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/AnnotatedElement.java --- a/src/share/classes/java/lang/reflect/AnnotatedElement.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/AnnotatedElement.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,24 @@ * arrays returned by accessors for array-valued enum members; it will * have no affect on the arrays returned to other callers. * + *

An annotation A is directly present on an element E if the + * RuntimeVisibleAnnotations or RuntimeVisibleParameterAnnotations attribute + * associated with E either: + *

    + *
  • contains A; or + *
  • for invocations of get[Declared]Annotations(Class), + * contains A or exactly one annotation C whose type is the containing + * annotation type of A's type (JLS 9.6) and whose value element contains A + *
+ * + *

An annotation A is present on an element E if either: + *

    + *
  • A is directly present on E; or + *
  • There are no annotations of A's type which are directly present + * on E, and E is a class, and A's type is inheritable (JLS 9.6.3.3), and A is + * present on the superclass of E + *
+ * *

If an annotation returned by a method in this interface contains * (directly or indirectly) a {@link Class}-valued member referring to * a class that is not accessible in this VM, attempting to read the class @@ -50,7 +68,7 @@ * containing annotation type of T will result in an * InvalidContainerAnnotationError. * - *

Finally, Attempting to read a member whose definition has evolved + *

Finally, attempting to read a member whose definition has evolved * incompatibly will result in a {@link * java.lang.annotation.AnnotationTypeMismatchException} or an * {@link java.lang.annotation.IncompleteAnnotationException}. @@ -70,6 +88,9 @@ * is present on this element, else false. This method * is designed primarily for convenient access to marker annotations. * + *

The truth value returned by this method is equivalent to: + * {@code getAnnotation(annotationClass) != null} + * * @param annotationClass the Class object corresponding to the * annotation type * @return true if an annotation for the specified annotation @@ -110,12 +131,15 @@ T[] getAnnotations(Class annotationClass); /** - * Returns all annotations present on this element. (Returns an array - * of length zero if this element has no annotations.) The caller of - * this method is free to modify the returned array; it will have no - * effect on the arrays returned to other callers. + * Returns annotations that are present on this element. + * + * If there are no annotations present on this element, the return + * value is an array of length 0. * - * @return all annotations present on this element + * The caller of this method is free to modify the returned array; it will + * have no effect on the arrays returned to other callers. + * + * @return annotations present on this element * @since 1.5 */ Annotation[] getAnnotations(); @@ -157,14 +181,16 @@ T[] getDeclaredAnnotations(Class annotationClass); /** - * Returns all annotations that are directly present on this - * element. This method ignores inherited annotations. (Returns - * an array of length zero if no annotations are directly present - * on this element.) The caller of this method is free to modify - * the returned array; it will have no effect on the arrays - * returned to other callers. + * Returns annotations that are directly present on this element. + * This method ignores inherited annotations. * - * @return All annotations directly present on this element + * If there are no annotations directly present on this element, + * the return value is an array of length 0. + * + * The caller of this method is free to modify the returned array; it will + * have no effect on the arrays returned to other callers. + * + * @return annotations directly present on this element * @since 1.5 */ Annotation[] getDeclaredAnnotations(); diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/AnnotatedParameterizedType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/lang/reflect/AnnotatedParameterizedType.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.reflect; + +/** + * AnnotatedParameterizedType represents the use of a parameterized type, + * whose type arguments may themselves represent annotated uses of types. + * + * @since 1.8 + */ +public interface AnnotatedParameterizedType extends AnnotatedType { + + /** + * Returns the annotated actual type arguments of this parameterized type. + * + * @return the annotated actual type arguments of this parameterized type + */ + AnnotatedType[] getAnnotatedActualTypeArguments(); +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/AnnotatedType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/lang/reflect/AnnotatedType.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.reflect; + +/** + * AnnotatedType represents the annotated use of a type in the program + * currently running in this VM. The use may be of any type in the Java + * programming language, including an array type, a parameterized type, a type + * variable, or a wildcard type. + * + * @since 1.8 + */ +public interface AnnotatedType extends AnnotatedElement { + + /** + * Returns the underlying type that this annotated type represents. + * + * @return the type this annotated type represents + */ + public Type getType(); +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/AnnotatedTypeVariable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/lang/reflect/AnnotatedTypeVariable.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.reflect; + +/** + * AnnotatedTypeVariable represents the use of a type variable, whose + * declaration may have bounds which themselves represent annotated uses of + * types. + * + * @since 1.8 + */ +public interface AnnotatedTypeVariable extends AnnotatedType { + + /** + * Returns the annotated bounds of this type variable. + * + * @return the annotated bounds of this type variable + */ + AnnotatedType[] getAnnotatedBounds(); +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/AnnotatedWildcardType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/java/lang/reflect/AnnotatedWildcardType.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package java.lang.reflect; + +/** + * AnnotatedWildcardType represents the use of a wildcard type argument, whose + * upper or lower bounds may themselves represent annotated uses of types. + * + * @since 1.8 + */ +public interface AnnotatedWildcardType extends AnnotatedType { + + /** + * Returns the annotated lower bounds of this wildcard type. + * + * @return the annotated lower bounds of this wildcard type + */ + AnnotatedType[] getAnnotatedLowerBounds(); + + /** + * Returns the annotated upper bounds of this wildcard type. + * + * @return the annotated upper bounds of this wildcard type + */ + AnnotatedType[] getAnnotatedUpperBounds(); +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/Constructor.java --- a/src/share/classes/java/lang/reflect/Constructor.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/Constructor.java Mon Feb 04 17:29:58 2013 -0400 @@ -154,6 +154,10 @@ byte[] getAnnotationBytes() { return annotations; } + @Override + byte[] getTypeAnnotationBytes() { + return typeAnnotations; + } /** * {@inheritDoc} @@ -523,4 +527,12 @@ } } } + + /** + * {@inheritDoc} + * @since 1.8 + */ + public AnnotatedType getAnnotatedReturnType() { + return getAnnotatedReturnType0(getDeclaringClass()); + } } diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/Executable.java --- a/src/share/classes/java/lang/reflect/Executable.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/Executable.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,12 @@ package java.lang.reflect; import java.lang.annotation.*; -import java.util.Collections; import java.util.Map; import java.util.Objects; import sun.reflect.annotation.AnnotationParser; import sun.reflect.annotation.AnnotationSupport; +import sun.reflect.annotation.TypeAnnotationParser; +import sun.reflect.annotation.TypeAnnotation; import sun.reflect.generics.repository.ConstructorRepository; /** @@ -50,6 +51,7 @@ * Accessor method to allow code sharing */ abstract byte[] getAnnotationBytes(); + abstract byte[] getTypeAnnotationBytes(); /** * Does the Executable have generic information. @@ -435,8 +437,7 @@ */ public T getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); - - return AnnotationSupport.getOneAnnotation(declaredAnnotations(), annotationClass); + return annotationClass.cast(declaredAnnotations().get(annotationClass)); } /** @@ -454,7 +455,7 @@ * {@inheritDoc} */ public Annotation[] getDeclaredAnnotations() { - return AnnotationSupport.unpackToArray(declaredAnnotations()); + return AnnotationParser.toArray(declaredAnnotations()); } private transient Map, Annotation> declaredAnnotations; @@ -470,4 +471,86 @@ return declaredAnnotations; } + + /* Helper for subclasses of Executable. + * + * Returns an AnnotatedType object that represents the use of a type to + * specify the return type of the method/constructor represented by this + * Executable. + * + * @since 1.8 + */ + AnnotatedType getAnnotatedReturnType0(Type returnType) { + return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(), + sun.misc.SharedSecrets.getJavaLangAccess(). + getConstantPool(getDeclaringClass()), + this, + getDeclaringClass(), + returnType, + TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN_TYPE); + } + + /** + * Returns an AnnotatedType object that represents the use of a type to + * specify the receiver type of the method/constructor represented by this + * Executable. The receiver type of a method/constructor is available only + * if the method/constructor declares a formal parameter called 'this'. + * + * Returns null if this Executable represents a constructor or instance + * method that either declares no formal parameter called 'this', or + * declares a formal parameter called 'this' with no annotations on its + * type. + * + * Returns null if this Executable represents a static method. + * + * @since 1.8 + */ + public AnnotatedType getAnnotatedReceiverType() { + return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(), + sun.misc.SharedSecrets.getJavaLangAccess(). + getConstantPool(getDeclaringClass()), + this, + getDeclaringClass(), + getDeclaringClass(), + TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER_TYPE); + } + + /** + * Returns an array of AnnotatedType objects that represent the use of + * types to specify formal parameter types of the method/constructor + * represented by this Executable. The order of the objects in the array + * corresponds to the order of the formal parameter types in the + * declaration of the method/constructor. + * + * Returns an array of length 0 if the method/constructor declares no + * parameters. + * + * @since 1.8 + */ + public AnnotatedType[] getAnnotatedParameterTypes() { + throw new UnsupportedOperationException("Not yet"); + } + + /** + * Returns an array of AnnotatedType objects that represent the use of + * types to specify the declared exceptions of the method/constructor + * represented by this Executable. The order of the objects in the array + * corresponds to the order of the exception types in the declaration of + * the method/constructor. + * + * Returns an array of length 0 if the method/constructor declares no + * exceptions. + * + * @since 1.8 + */ + public AnnotatedType[] getAnnotatedExceptionTypes() { + return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(), + sun.misc.SharedSecrets.getJavaLangAccess(). + getConstantPool(getDeclaringClass()), + this, + getDeclaringClass(), + getGenericExceptionTypes(), + TypeAnnotation.TypeAnnotationTarget.THROWS); + } + } diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/Field.java --- a/src/share/classes/java/lang/reflect/Field.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/Field.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,8 @@ import java.util.Objects; import sun.reflect.annotation.AnnotationParser; import sun.reflect.annotation.AnnotationSupport; - +import sun.reflect.annotation.TypeAnnotation; +import sun.reflect.annotation.TypeAnnotationParser; /** * A {@code Field} provides information about, and dynamic access to, a @@ -1020,8 +1021,7 @@ */ public T getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); - - return AnnotationSupport.getOneAnnotation(declaredAnnotations(), annotationClass); + return annotationClass.cast(declaredAnnotations().get(annotationClass)); } /** @@ -1039,7 +1039,7 @@ * {@inheritDoc} */ public Annotation[] getDeclaredAnnotations() { - return AnnotationSupport.unpackToArray(declaredAnnotations()); + return AnnotationParser.toArray(declaredAnnotations()); } private transient Map, Annotation> declaredAnnotations; @@ -1053,4 +1053,20 @@ } return declaredAnnotations; } + + /** + * Returns an AnnotatedType object that represents the use of a type to specify + * the declared type of the field represented by this Field. + * + * @since 1.8 + */ + public AnnotatedType getAnnotatedType() { + return TypeAnnotationParser.buildAnnotatedType(typeAnnotations, + sun.misc.SharedSecrets.getJavaLangAccess(). + getConstantPool(getDeclaringClass()), + this, + getDeclaringClass(), + getGenericType(), + TypeAnnotation.TypeAnnotationTarget.FIELD_TYPE); } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/Method.java --- a/src/share/classes/java/lang/reflect/Method.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/Method.java Mon Feb 04 17:29:58 2013 -0400 @@ -165,6 +165,10 @@ byte[] getAnnotationBytes() { return annotations; } + @Override + byte[] getTypeAnnotationBytes() { + return typeAnnotations; + } /** * {@inheritDoc} @@ -621,6 +625,14 @@ return sharedGetParameterAnnotations(parameterTypes, parameterAnnotations); } + /** + * {@inheritDoc} + * @since 1.8 + */ + public AnnotatedType getAnnotatedReturnType() { + return getAnnotatedReturnType0(getGenericReturnType()); + } + @Override void handleParameterNumberMismatch(int resultLength, int numParameters) { throw new AnnotationFormatError("Parameter annotations don't match number of parameters"); diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/Parameter.java --- a/src/share/classes/java/lang/reflect/Parameter.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/Parameter.java Mon Feb 04 17:29:58 2013 -0400 @@ -233,8 +233,7 @@ */ public T getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); - - return AnnotationSupport.getOneAnnotation(declaredAnnotations(), annotationClass); + return annotationClass.cast(declaredAnnotations().get(annotationClass)); } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/ReflectAccess.java --- a/src/share/classes/java/lang/reflect/ReflectAccess.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/ReflectAccess.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -128,6 +128,10 @@ return c.getRawParameterAnnotations(); } + public byte[] getExecutableTypeAnnotationBytes(Executable ex) { + return ex.getTypeAnnotationBytes(); + } + // // Copying routines, needed to quickly fabricate new Field, // Method, and Constructor objects from templates diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/lang/reflect/TypeVariable.java --- a/src/share/classes/java/lang/reflect/TypeVariable.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/lang/reflect/TypeVariable.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,4 +86,16 @@ * @return the name of this type variable, as it appears in the source code */ String getName(); + + /** + * Returns an array of AnnotatedType objects that represent the use of + * types to denote the upper bounds of the type parameter represented by + * this TypeVariable. The order of the objects in the array corresponds to + * the order of the bounds in the declaration of the type parameter. + * + * Returns an array of length 0 if the type parameter declares no bounds. + * + * @since 1.8 + */ + AnnotatedType[] getAnnotatedBounds(); } diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/math/BigDecimal.java --- a/src/share/classes/java/math/BigDecimal.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/math/BigDecimal.java Mon Feb 04 17:29:58 2013 -0400 @@ -3537,13 +3537,25 @@ else return expandBigIntegerTenPowers(n); } - // BigInteger.pow is slow, so make 10**n by constructing a - // BigInteger from a character string (still not very fast) - char tenpow[] = new char[n + 1]; - tenpow[0] = '1'; - for (int i = 1; i <= n; i++) - tenpow[i] = '0'; - return new BigInteger(tenpow,1, tenpow.length); + + if (n < 1024*524288) { + // BigInteger.pow is slow, so make 10**n by constructing a + // BigInteger from a character string (still not very fast) + // which occupies no more than 1GB (!) of memory. + char tenpow[] = new char[n + 1]; + tenpow[0] = '1'; + for (int i = 1; i <= n; i++) { + tenpow[i] = '0'; + } + return new BigInteger(tenpow, 1, tenpow.length); + } + + if ((n & 0x1) == 0x1) { + return BigInteger.TEN.multiply(bigTenToThe(n - 1)); + } else { + BigInteger tmp = bigTenToThe(n/2); + return tmp.multiply(tmp); + } } /** diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/util/Base64.java --- a/src/share/classes/java/util/Base64.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/util/Base64.java Mon Feb 04 17:29:58 2013 -0400 @@ -64,7 +64,8 @@ * RFC 2045 for encoding and decoding operation. The encoded output * must be represented in lines of no more than 76 characters each * and uses a carriage return {@code '\r'} followed immediately by - * a linefeed {@code '\n'} as the line separator. All line separators + * a linefeed {@code '\n'} as the line separator. No line separator + * is added to the end of the encoded output. All line separators * or other characters not found in the base64 alphabet table are * ignored in decoding operation.

* @@ -413,6 +414,7 @@ * specified Base64 encoded format */ public OutputStream wrap(OutputStream os) { + Objects.requireNonNull(os); return new EncOutputStream(os, isURL ? toBase64URL : toBase64, newline, linemax); } @@ -613,6 +615,13 @@ * This class implements a decoder for decoding byte data using the * Base64 encoding scheme as specified in RFC 4648 and RFC 2045. * + *

The Base64 padding character {@code '='} is accepted and + * interpreted as the end of the encoded byte data, but is not + * required. So if the final unit of the encoded byte data only has + * two or three Base64 characters (without the corresponding padding + * character(s) padded), they are decoded as if followed by padding + * character(s). + * *

Instances of {@link Decoder} class are safe for use by * multiple concurrent threads. * @@ -695,7 +704,7 @@ * using the {@link Base64} encoding scheme. * *

An invocation of this method has exactly the same effect as invoking - * {@code return decode(src.getBytes(StandardCharsets.ISO_8859_1))} + * {@code decode(src.getBytes(StandardCharsets.ISO_8859_1))} * * @param src * the string to decode @@ -856,6 +865,9 @@ /** * Returns an input stream for decoding {@link Base64} encoded byte stream. * + *

The {@code read} methods of the returned {@code InputStream} will + * throw {@code IOException} when reading bytes that cannot be decoded. + * *

Closing the returned input stream will close the underlying * input stream. * @@ -866,6 +878,7 @@ * byte stream */ public InputStream wrap(InputStream is) { + Objects.requireNonNull(is); return new DecInputStream(is, isURL ? fromBase64URL : fromBase64, isMIME); } @@ -881,13 +894,16 @@ int dl = dst.arrayOffset() + dst.limit(); int dp0 = dp; int mark = sp; - boolean padding = false; try { while (sp < sl) { int b = sa[sp++] & 0xff; if ((b = base64[b]) < 0) { if (b == -2) { // padding byte - padding = true; + if (shiftto == 6 && (sp == sl || sa[sp++] != '=') || + shiftto == 18) { + throw new IllegalArgumentException( + "Input byte array has wrong 4-byte ending unit"); + } break; } if (isMIME) // skip if for rfc2045 @@ -913,24 +929,23 @@ if (shiftto == 6) { if (dl - dp < 1) return dp - dp0; - if (padding && (sp + 1 != sl || sa[sp++] != '=')) - throw new IllegalArgumentException( - "Input buffer has wrong 4-byte ending unit"); da[dp++] = (byte)(bits >> 16); - mark = sp; } else if (shiftto == 0) { if (dl - dp < 2) return dp - dp0; - if (padding && sp != sl) - throw new IllegalArgumentException( - "Input buffer has wrong 4-byte ending unit"); da[dp++] = (byte)(bits >> 16); da[dp++] = (byte)(bits >> 8); - mark = sp; - } else if (padding || shiftto != 18) { + } else if (shiftto == 12) { throw new IllegalArgumentException( "Last unit does not have enough valid bits"); } + while (sp < sl) { + if (isMIME && base64[sa[sp++]] < 0) + continue; + throw new IllegalArgumentException( + "Input byte array has incorrect ending byte at " + sp); + } + mark = sp; return dp - dp0; } finally { src.position(mark); @@ -948,14 +963,16 @@ int dl = dst.limit(); int dp0 = dp; int mark = sp; - boolean padding = false; - try { while (sp < sl) { int b = src.get(sp++) & 0xff; if ((b = base64[b]) < 0) { if (b == -2) { // padding byte - padding = true; + if (shiftto == 6 && (sp == sl || src.get(sp++) != '=') || + shiftto == 18) { + throw new IllegalArgumentException( + "Input byte array has wrong 4-byte ending unit"); + } break; } if (isMIME) // skip if for rfc2045 @@ -981,24 +998,23 @@ if (shiftto == 6) { if (dl - dp < 1) return dp - dp0; - if (padding && (sp + 1 != sl || src.get(sp++) != '=')) - throw new IllegalArgumentException( - "Input buffer has wrong 4-byte ending unit"); dst.put(dp++, (byte)(bits >> 16)); - mark = sp; } else if (shiftto == 0) { if (dl - dp < 2) return dp - dp0; - if (padding && sp != sl) - throw new IllegalArgumentException( - "Input buffer has wrong 4-byte ending unit"); dst.put(dp++, (byte)(bits >> 16)); dst.put(dp++, (byte)(bits >> 8)); - mark = sp; - } else if (padding || shiftto != 18) { + } else if (shiftto == 12) { throw new IllegalArgumentException( "Last unit does not have enough valid bits"); } + while (sp < sl) { + if (isMIME && base64[src.get(sp++)] < 0) + continue; + throw new IllegalArgumentException( + "Input byte array has incorrect ending byte at " + sp); + } + mark = sp; return dp - dp0; } finally { src.position(mark); @@ -1012,9 +1028,12 @@ int len = sl - sp; if (len == 0) return 0; - if (len < 2) + if (len < 2) { + if (isMIME && base64[0] == -1) + return 0; throw new IllegalArgumentException( "Input byte[] should at least have 2 bytes for base64 bytes"); + } if (src[sl - 1] == '=') { paddings++; if (src[sl - 2] == '=') @@ -1043,12 +1062,20 @@ int dp = 0; int bits = 0; int shiftto = 18; // pos of first byte of 4-byte atom - boolean padding = false; while (sp < sl) { int b = src[sp++] & 0xff; if ((b = base64[b]) < 0) { - if (b == -2) { // padding byte - padding = true; + if (b == -2) { // padding byte '=' + // xx= shiftto==6&&sp==sl missing last = + // xx=y shiftto==6 last is not = + // = shiftto==18 unnecessary padding + // x= shiftto==12 be taken care later + // together with single x, invalid anyway + if (shiftto == 6 && (sp == sl || src[sp++] != '=') || + shiftto == 18) { + throw new IllegalArgumentException( + "Input byte array has wrong 4-byte ending unit"); + } break; } if (isMIME) // skip if for rfc2045 @@ -1068,22 +1095,23 @@ bits = 0; } } - // reach end of byte arry or hit padding '=' characters. - // if '=' presents, they must be the last one or two. - if (shiftto == 6) { // xx== - if (padding && (sp + 1 != sl || src[sp] != '=')) - throw new IllegalArgumentException( - "Input byte array has wrong 4-byte ending unit"); + // reached end of byte array or hit padding '=' characters. + if (shiftto == 6) { dst[dp++] = (byte)(bits >> 16); - } else if (shiftto == 0) { // xxx= - if (padding && sp != sl) - throw new IllegalArgumentException( - "Input byte array has wrong 4-byte ending unit"); + } else if (shiftto == 0) { dst[dp++] = (byte)(bits >> 16); dst[dp++] = (byte)(bits >> 8); - } else if (padding || shiftto != 18) { - throw new IllegalArgumentException( - "last unit does not have enough bytes"); + } else if (shiftto == 12) { + throw new IllegalArgumentException( + "Last unit does not have enough valid bits"); + } + // anything left is invalid, if is not MIME. + // if MIME, ignore all non-base64 character + while (sp < sl) { + if (isMIME && base64[src[sp++]] < 0) + continue; + throw new IllegalArgumentException( + "Input byte array has incorrect ending byte at " + sp); } return dp; } @@ -1247,8 +1275,22 @@ int v = is.read(); if (v == -1) { eof = true; - if (nextin != 18) - throw new IOException("Base64 stream has un-decoded dangling byte(s)."); + if (nextin != 18) { + if (nextin == 12) + throw new IOException("Base64 stream has one un-decoded dangling byte."); + // treat ending xx/xxx without padding character legal. + // same logic as v == 'v' below + b[off++] = (byte)(bits >> (16)); + len--; + if (nextin == 0) { // only one padding byte + if (len == 0) { // no enough output space + bits >>= 8; // shift to lowest byte + nextout = 0; + } else { + b[off++] = (byte) (bits >> 8); + } + } + } if (off == oldOff) return -1; else diff -r a8bbd962f34a -r 41654275896d src/share/classes/java/util/Formatter.java --- a/src/share/classes/java/util/Formatter.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/java/util/Formatter.java Mon Feb 04 17:29:58 2013 -0400 @@ -351,7 +351,9 @@ * {@code 'a'}, {@code 'A'} * floating point * The result is formatted as a hexadecimal floating-point number with - * a significand and an exponent + * a significand and an exponent. This conversion is not supported + * for the {@code BigDecimal} type despite the latter's being in the + * floating point argument category. * * {@code 't'}, {@code 'T'} * date/time diff -r a8bbd962f34a -r 41654275896d src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java --- a/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java Mon Feb 04 17:29:58 2013 -0400 @@ -1153,7 +1153,9 @@ "Menu.menuPopupOffsetY", new Integer(0), "Menu.submenuPopupOffsetX", new Integer(0), "Menu.submenuPopupOffsetY", new Integer(0), - "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK}, + "Menu.shortcutKeys", new int[]{ + SwingUtilities2.getSystemMnemonicKeyMask() + }, "Menu.crossMenuMnemonic", Boolean.TRUE, // Menu.cancelMode affects the cancel menu action behaviour; // currently supports: diff -r a8bbd962f34a -r 41654275896d src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java --- a/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java Mon Feb 04 17:29:58 2013 -0400 @@ -1879,6 +1879,20 @@ visRect.x -= i.left; visRect.y -= i.top; } + // we should consider a non-visible area above + Component component = SwingUtilities.getUnwrappedParent(tree); + if (component instanceof JViewport) { + component = component.getParent(); + if (component instanceof JScrollPane) { + JScrollPane pane = (JScrollPane) component; + JScrollBar bar = pane.getHorizontalScrollBar(); + if ((bar != null) && bar.isVisible()) { + int height = bar.getHeight(); + visRect.y -= height; + visRect.height += height; + } + } + } preferredSize.width = treeState.getPreferredWidth(visRect); } else { @@ -4504,7 +4518,7 @@ } } - private void home(JTree tree, BasicTreeUI ui, int direction, + private void home(JTree tree, final BasicTreeUI ui, int direction, boolean addToSelection, boolean changeSelection) { // disable moving of lead unless in discontiguous mode @@ -4514,7 +4528,7 @@ changeSelection = true; } - int rowCount = ui.getRowCount(tree); + final int rowCount = ui.getRowCount(tree); if (rowCount > 0) { if(direction == -1) { @@ -4566,6 +4580,13 @@ ui.setLeadSelectionPath(ui.getPathForRow(tree, rowCount - 1), true); } + if (ui.isLargeModel()){ + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ui.ensureRowsAreVisible(rowCount - 1, rowCount - 1); + } + }); + } } } } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/awt/image/SurfaceManager.java --- a/src/share/classes/sun/awt/image/SurfaceManager.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/awt/image/SurfaceManager.java Mon Feb 04 17:29:58 2013 -0400 @@ -88,7 +88,7 @@ imgaccessor.setSurfaceManager(img, mgr); } - private ConcurrentHashMap cacheMap; + private ConcurrentHashMap cacheMap; /** * Return an arbitrary cached object for an arbitrary cache key. @@ -123,7 +123,7 @@ if (cacheMap == null) { synchronized (this) { if (cacheMap == null) { - cacheMap = new ConcurrentHashMap(2); + cacheMap = new ConcurrentHashMap<>(2); } } } @@ -245,7 +245,7 @@ synchronized void flush(boolean deaccelerate) { if (cacheMap != null) { - Iterator i = cacheMap.values().iterator(); + Iterator i = cacheMap.values().iterator(); while (i.hasNext()) { Object o = i.next(); if (o instanceof FlushableCacheData) { diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/Agent.java --- a/src/share/classes/sun/management/Agent.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/management/Agent.java Mon Feb 04 17:29:58 2013 -0400 @@ -22,7 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package sun.management; import java.io.BufferedInputStream; @@ -31,49 +30,55 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; - +import java.lang.management.ManagementFactory; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.management.ManagementFactory; - +import java.net.InetAddress; +import java.net.Socket; +import java.net.UnknownHostException; import java.text.MessageFormat; - import java.util.MissingResourceException; import java.util.Properties; import java.util.ResourceBundle; import javax.management.remote.JMXConnectorServer; +import javax.management.remote.JMXServiceURL; import static sun.management.AgentConfigurationError.*; import sun.management.jmxremote.ConnectorBootstrap; +import sun.management.jdp.JdpController; +import sun.management.jdp.JdpException; import sun.misc.VMSupport; /** - * This Agent is started by the VM when -Dcom.sun.management.snmp - * or -Dcom.sun.management.jmxremote is set. This class will be - * loaded by the system class loader. Also jmx framework could - * be started by jcmd + * This Agent is started by the VM when -Dcom.sun.management.snmp or + * -Dcom.sun.management.jmxremote is set. This class will be loaded by the + * system class loader. Also jmx framework could be started by jcmd */ public class Agent { // management properties + private static Properties mgmtProps; private static ResourceBundle messageRB; - private static final String CONFIG_FILE = - "com.sun.management.config.file"; + "com.sun.management.config.file"; private static final String SNMP_PORT = - "com.sun.management.snmp.port"; + "com.sun.management.snmp.port"; private static final String JMXREMOTE = - "com.sun.management.jmxremote"; + "com.sun.management.jmxremote"; private static final String JMXREMOTE_PORT = - "com.sun.management.jmxremote.port"; + "com.sun.management.jmxremote.port"; + private static final String RMI_PORT = + "com.sun.management.jmxremote.rmi.port"; private static final String ENABLE_THREAD_CONTENTION_MONITORING = - "com.sun.management.enableThreadContentionMonitoring"; + "com.sun.management.enableThreadContentionMonitoring"; private static final String LOCAL_CONNECTOR_ADDRESS_PROP = - "com.sun.management.jmxremote.localConnectorAddress"; + "com.sun.management.jmxremote.localConnectorAddress"; + private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME = + "sun.management.snmp.AdaptorBootstrap"; - private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME = - "sun.management.snmp.AdaptorBootstrap"; + private static final String JDP_DEFAULT_ADDRESS = "239.255.255.225"; + private static final int JDP_DEFAULT_PORT = 7095; // The only active agent allowed private static JMXConnectorServer jmxServer = null; @@ -81,26 +86,25 @@ // Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy // and return property set if args is null or empty // return empty property set - private static Properties parseString(String args){ + private static Properties parseString(String args) { Properties argProps = new Properties(); if (args != null) { - for (String option : args.split(",")) { - String s[] = option.split("=", 2); - String name = s[0].trim(); - String value = (s.length > 1) ? s[1].trim() : ""; + for (String option : args.split(",")) { + String s[] = option.split("=", 2); + String name = s[0].trim(); + String value = (s.length > 1) ? s[1].trim() : ""; - if (!name.startsWith("com.sun.management.")) { - error(INVALID_OPTION, name); - } + if (!name.startsWith("com.sun.management.")) { + error(INVALID_OPTION, name); + } - argProps.setProperty(name, value); - } + argProps.setProperty(name, value); + } } return argProps; } - // invoked by -javaagent or -Dcom.sun.management.agent.class public static void premain(String args) throws Exception { agentmain(args); @@ -115,18 +119,18 @@ Properties arg_props = parseString(args); // Read properties from the config file - Properties config_props = new Properties(); - String fname = arg_props.getProperty(CONFIG_FILE); - readConfiguration(fname, config_props); + Properties config_props = new Properties(); + String fname = arg_props.getProperty(CONFIG_FILE); + readConfiguration(fname, config_props); - // Arguments override config file - config_props.putAll(arg_props); - startAgent(config_props); + // Arguments override config file + config_props.putAll(arg_props); + startAgent(config_props); } // jcmd ManagementAgent.start_local entry point // Also called due to command-line via startAgent() - private static synchronized void startLocalManagementAgent(){ + private static synchronized void startLocalManagementAgent() { Properties agentProps = VMSupport.getAgentProperties(); // start local connector if not started @@ -156,7 +160,7 @@ throw new RuntimeException(getText(INVALID_STATE, "Agent already started")); } - Properties argProps = parseString(args); + Properties argProps = parseString(args); Properties configProps = new Properties(); // Load the management properties from the config file @@ -169,7 +173,7 @@ // management properties can be overridden by system properties // which take precedence Properties sysProps = System.getProperties(); - synchronized(sysProps){ + synchronized (sysProps) { configProps.putAll(sysProps); } @@ -190,21 +194,26 @@ // can specify this property inside config file, so enable optional // monitoring functionality if this property is set final String enableThreadContentionMonitoring = - configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING); + configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING); if (enableThreadContentionMonitoring != null) { ManagementFactory.getThreadMXBean(). - setThreadContentionMonitoringEnabled(true); + setThreadContentionMonitoringEnabled(true); } String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT); if (jmxremotePort != null) { jmxServer = ConnectorBootstrap. - startRemoteConnectorServer(jmxremotePort, configProps); + startRemoteConnectorServer(jmxremotePort, configProps); + + startDiscoveryService(configProps); } } private static synchronized void stopRemoteManagementAgent() throws Exception { + + JdpController.stopDiscoveryService(); + if (jmxServer != null) { ConnectorBootstrap.unexportRegistry(); @@ -222,15 +231,15 @@ // Enable optional monitoring functionality if requested final String enableThreadContentionMonitoring = - props.getProperty(ENABLE_THREAD_CONTENTION_MONITORING); + props.getProperty(ENABLE_THREAD_CONTENTION_MONITORING); if (enableThreadContentionMonitoring != null) { ManagementFactory.getThreadMXBean(). - setThreadContentionMonitoringEnabled(true); + setThreadContentionMonitoringEnabled(true); } try { if (snmpPort != null) { - loadSnmpAgent(snmpPort, props); + loadSnmpAgent(snmpPort, props); } /* @@ -242,13 +251,14 @@ * of this "local" server is exported as a counter to the jstat * instrumentation buffer. */ - if (jmxremote != null || jmxremotePort != null) { + if (jmxremote != null || jmxremotePort != null) { if (jmxremotePort != null) { - jmxServer = ConnectorBootstrap. - startRemoteConnectorServer(jmxremotePort, props); + jmxServer = ConnectorBootstrap. + startRemoteConnectorServer(jmxremotePort, props); + startDiscoveryService(props); } startLocalManagementAgent(); - } + } } catch (AgentConfigurationError e) { error(e.getError(), e.getParams()); @@ -257,6 +267,73 @@ } } + private static void startDiscoveryService(Properties props) + throws IOException { + // Start discovery service if requested + String discoveryPort = props.getProperty("com.sun.management.jdp.port"); + String discoveryAddress = props.getProperty("com.sun.management.jdp.address"); + String discoveryShouldStart = props.getProperty("com.sun.management.jmxremote.autodiscovery"); + + // Decide whether we should start autodicovery service. + // To start autodiscovery following conditions should be met: + // autodiscovery==true OR (autodicovery==null AND jdp.port != NULL) + + boolean shouldStart = false; + if (discoveryShouldStart == null){ + shouldStart = (discoveryPort != null); + } + else{ + try{ + shouldStart = Boolean.parseBoolean(discoveryShouldStart); + } catch (NumberFormatException e) { + throw new AgentConfigurationError("Couldn't parse autodiscovery argument"); + } + } + + if (shouldStart) { + // port and address are required arguments and have no default values + InetAddress address; + try { + address = (discoveryAddress == null) ? + InetAddress.getByName(JDP_DEFAULT_ADDRESS) : InetAddress.getByName(discoveryAddress); + } catch (UnknownHostException e) { + throw new AgentConfigurationError("Unable to broadcast to requested address", e); + } + + int port = JDP_DEFAULT_PORT; + if (discoveryPort != null) { + try { + port = Integer.parseInt(discoveryPort); + } catch (NumberFormatException e) { + throw new AgentConfigurationError("Couldn't parse JDP port argument"); + } + } + + // Rebuilding service URL to broadcast it + String jmxremotePort = props.getProperty(JMXREMOTE_PORT); + String rmiPort = props.getProperty(RMI_PORT); + + JMXServiceURL url = jmxServer.getAddress(); + String hostname = url.getHost(); + + String jmxUrlStr = (rmiPort != null) + ? String.format( + "service:jmx:rmi://%s:%s/jndi/rmi://%s:%s/jmxrmi", + hostname, rmiPort, hostname, jmxremotePort) + : String.format( + "service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi", hostname, jmxremotePort); + + String instanceName = System.getProperty("com.sun.management.jdp.name"); + + try{ + JdpController.startDiscoveryService(address, port, instanceName, jmxUrlStr); + } + catch(JdpException e){ + throw new AgentConfigurationError("Couldn't start JDP service", e); + } + } + } + public static Properties loadManagementProperties() { Properties props = new Properties(); @@ -268,22 +345,22 @@ // management properties can be overridden by system properties // which take precedence Properties sysProps = System.getProperties(); - synchronized(sysProps){ + synchronized (sysProps) { props.putAll(sysProps); } return props; - } + } - public static synchronized Properties getManagementProperties() { + public static synchronized Properties getManagementProperties() { if (mgmtProps == null) { String configFile = System.getProperty(CONFIG_FILE); String snmpPort = System.getProperty(SNMP_PORT); String jmxremote = System.getProperty(JMXREMOTE); String jmxremotePort = System.getProperty(JMXREMOTE_PORT); - if (configFile == null && snmpPort == null && - jmxremote == null && jmxremotePort == null) { + if (configFile == null && snmpPort == null + && jmxremote == null && jmxremotePort == null) { // return if out-of-the-management option is not specified return null; } @@ -297,22 +374,23 @@ // invoke the following through reflection: // AdaptorBootstrap.initialize(snmpPort, props); final Class adaptorClass = - Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME,true,null); + Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME, true, null); final Method initializeMethod = adaptorClass.getMethod("initialize", - String.class, Properties.class); - initializeMethod.invoke(null,snmpPort,props); + String.class, Properties.class); + initializeMethod.invoke(null, snmpPort, props); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException x) { // snmp runtime doesn't exist - initialization fails - throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x); + throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, x); } catch (InvocationTargetException x) { final Throwable cause = x.getCause(); - if (cause instanceof RuntimeException) + if (cause instanceof RuntimeException) { throw (RuntimeException) cause; - else if (cause instanceof Error) + } else if (cause instanceof Error) { throw (Error) cause; + } // should not happen... - throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause); + throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT, cause); } } @@ -353,8 +431,8 @@ } catch (IOException e) { error(CONFIG_FILE_CLOSE_FAILED, fname); } - } - } + } + } } public static void startAgent() throws Exception { @@ -389,9 +467,9 @@ // invoke the premain(String args) method Class clz = ClassLoader.getSystemClassLoader().loadClass(cname); Method premain = clz.getMethod("premain", - new Class[] { String.class }); + new Class[]{String.class}); premain.invoke(null, /* static */ - new Object[] { args }); + new Object[]{args}); } catch (ClassNotFoundException ex) { error(AGENT_CLASS_NOT_FOUND, "\"" + cname + "\""); } catch (NoSuchMethodException ex) { @@ -400,8 +478,8 @@ error(AGENT_CLASS_ACCESS_DENIED); } catch (Exception ex) { String msg = (ex.getCause() == null - ? ex.getMessage() - : ex.getCause().getMessage()); + ? ex.getMessage() + : ex.getCause().getMessage()); error(AGENT_CLASS_FAILED, msg); } } @@ -425,7 +503,6 @@ } } - public static void error(String key, String message) { String keyText = getText(key); System.err.print(getText("agent.err.error") + ": " + keyText); @@ -447,7 +524,7 @@ private static void initResource() { try { messageRB = - ResourceBundle.getBundle("sun.management.resources.agent"); + ResourceBundle.getBundle("sun.management.resources.agent"); } catch (MissingResourceException e) { throw new Error("Fatal: Resource for management agent is missing"); } @@ -470,10 +547,9 @@ } String format = messageRB.getString(key); if (format == null) { - format = "missing resource key: key = \"" + key + "\", " + - "arguments = \"{0}\", \"{1}\", \"{2}\""; + format = "missing resource key: key = \"" + key + "\", " + + "arguments = \"{0}\", \"{1}\", \"{2}\""; } return MessageFormat.format(format, (Object[]) args); } - } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpBroadcaster.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpBroadcaster.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +import java.io.IOException; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.NetworkInterface; +import java.net.ProtocolFamily; +import java.net.StandardProtocolFamily; +import java.net.StandardSocketOptions; +import java.nio.ByteBuffer; +import java.nio.channels.DatagramChannel; +import java.nio.channels.UnsupportedAddressTypeException; + +/** + * JdpBroadcaster is responsible for sending pre-built JDP packet across a Net + * + *

Multicast group address, port number and ttl have to be chosen on upper + * level and passed to broadcaster constructor. Also it's possible to specify + * source address to broadcast from.

+ * + *

JdpBradcaster doesn't perform any validation on a supplied {@code port} and {@code ttl} because + * the allowed values depend on an operating system setup

+ * + */ +public final class JdpBroadcaster { + + private final InetAddress addr; + private final int port; + private final DatagramChannel channel; + + /** + * Create a new broadcaster + * + * @param address - multicast group address + * @param srcAddress - address of interface we should use to broadcast. + * @param port - udp port to use + * @param ttl - packet ttl + * @throws IOException + */ + public JdpBroadcaster(InetAddress address, InetAddress srcAddress, int port, int ttl) + throws IOException, JdpException { + this.addr = address; + this.port = port; + + ProtocolFamily family = (address instanceof Inet6Address) + ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; + + channel = DatagramChannel.open(family); + channel.setOption(StandardSocketOptions.SO_REUSEADDR, true); + channel.setOption(StandardSocketOptions.IP_MULTICAST_TTL, ttl); + + // with srcAddress equal to null, this constructor do exactly the same as + // if srcAddress is not passed + if (srcAddress != null) { + // User requests particular interface to bind to + NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress); + try { + channel.bind(new InetSocketAddress(srcAddress, 0)); + } catch (UnsupportedAddressTypeException ex) { + throw new JdpException("Unable to bind to source address"); + } + channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf); + } + } + + /** + * Create a new broadcaster + * + * @param address - multicast group address + * @param port - udp port to use + * @param ttl - packet ttl + * @throws IOException + */ + public JdpBroadcaster(InetAddress address, int port, int ttl) + throws IOException, JdpException { + this(address, null, port, ttl); + } + + /** + * Broadcast pre-built packet + * + * @param packet - instance of JdpPacket + * @throws IOException + */ + public void sendPacket(JdpPacket packet) + throws IOException { + byte[] data = packet.getPacketData(); + // Unlike allocate/put wrap don't need a flip afterward + ByteBuffer b = ByteBuffer.wrap(data); + channel.send(b, new InetSocketAddress(addr, port)); + } + + /** + * Shutdown broadcaster and close underlying socket channel + * + * @throws IOException + */ + public void shutdown() throws IOException { + channel.close(); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpController.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpController.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.UUID; + +/** + * JdpController is responsible to create and manage a broadcast loop + * + *

Other part of code has no access to broadcast loop and have to use + * provided static methods + * {@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} + * and {@link #stopDiscoveryService() stopDiscoveryService}

+ *

{@link #startDiscoveryService(InetAddress,int,String,String) startDiscoveryService} could be called multiple + * times as it stops the running service if it is necessary. Call to {@link #stopDiscoveryService() stopDiscoveryService} + * ignored if service isn't run

+ * + * + *

+ * + *

System properties below could be used to control broadcast loop behavior. + * Property below have to be set explicitly in command line. It's not possible to + * set it in management.config file. Careless changes of these properties could + * lead to security or network issues. + *

    + *
  • com.sun.management.jdp.ttl - set ttl for broadcast packet
  • + *
  • com.sun.management.jdp.pause - set broadcast interval in seconds
  • + *
  • com.sun.management.jdp.source_addr - an address of interface to use for broadcast
  • + *
+

+ *

null parameters values are filtered out on {@link JdpPacketWriter} level and + * corresponding keys are not placed to packet.

+ */ +public final class JdpController { + + private static class JDPControllerRunner implements Runnable { + + private final JdpJmxPacket packet; + private final JdpBroadcaster bcast; + private final int pause; + private volatile boolean shutdown = false; + + private JDPControllerRunner(JdpBroadcaster bcast, JdpJmxPacket packet, int pause) { + this.bcast = bcast; + this.packet = packet; + this.pause = pause; + } + + @Override + public void run() { + try { + while (!shutdown) { + bcast.sendPacket(packet); + try { + Thread.sleep(this.pause); + } catch (InterruptedException e) { + // pass + } + } + + } catch (IOException e) { + // pass; + } + + // It's not possible to re-use controller, + // nevertheless reset shutdown variable + try { + stop(); + bcast.shutdown(); + } catch (IOException ex) { + // pass - ignore IOException during shutdown + } + } + + public void stop() { + shutdown = true; + } + } + private static JDPControllerRunner controller = null; + + private JdpController(){ + // Don't allow to instantiate this class. + } + + // Utility to handle optional system properties + // Parse an integer from string or return default if provided string is null + private static int getInteger(String val, int dflt, String msg) throws JdpException { + try { + return (val == null) ? dflt : Integer.parseInt(val); + } catch (NumberFormatException ex) { + throw new JdpException(msg); + } + } + + // Parse an inet address from string or return default if provided string is null + private static InetAddress getInetAddress(String val, InetAddress dflt, String msg) throws JdpException { + try { + return (val == null) ? dflt : InetAddress.getByName(val); + } catch (UnknownHostException ex) { + throw new JdpException(msg); + } + } + + /** + * Starts discovery service + * + * @param address - multicast group address + * @param port - udp port to use + * @param instanceName - name of running JVM instance + * @param url - JMX service url + * @throws IOException + */ + public static synchronized void startDiscoveryService(InetAddress address, int port, String instanceName, String url) + throws IOException, JdpException { + + // Limit packet to local subnet by default + int ttl = getInteger( + System.getProperty("com.sun.management.jdp.ttl"), 1, + "Invalid jdp packet ttl"); + + // Broadcast once a 5 seconds by default + int pause = getInteger( + System.getProperty("com.sun.management.jdp.pause"), 5, + "Invalid jdp pause"); + + // Converting seconds to milliseconds + pause = pause * 1000; + + // Allow OS to choose broadcast source + InetAddress sourceAddress = getInetAddress( + System.getProperty("com.sun.management.jdp.source_addr"), null, + "Invalid source address provided"); + + // Generate session id + UUID id = UUID.randomUUID(); + + JdpJmxPacket packet = new JdpJmxPacket(id, url); + + // Don't broadcast whole command line for security reason. + // Strip everything after first space + String javaCommand = System.getProperty("sun.java.command"); + if (javaCommand != null) { + String[] arr = javaCommand.split(" ", 2); + packet.setMainClass(arr[0]); + } + + // Put optional explicit java instance name to packet, if user doesn't specify + // it the key is skipped. PacketWriter is responsible to skip keys having null value. + packet.setInstanceName(instanceName); + + JdpBroadcaster bcast = new JdpBroadcaster(address, sourceAddress, port, ttl); + + // Stop discovery service if it's already running + stopDiscoveryService(); + + controller = new JDPControllerRunner(bcast, packet, pause); + + Thread t = new Thread(controller, "JDP broadcaster"); + t.setDaemon(true); + t.start(); + } + + /** + * Stop running discovery service, + * it's safe to attempt to stop not started service + */ + public static synchronized void stopDiscoveryService() { + if ( controller != null ){ + controller.stop(); + controller = null; + } + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpException.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +/** + * An Exception thrown if a JDP implementation encounters a problem. + */ +public final class JdpException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Construct a new JDP exception with a meaningful message + * + * @param msg - message + */ + public JdpException(String msg) { + super(msg); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpGenericPacket.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpGenericPacket.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +/** + * JdpGenericPacket responsible to provide fields + * common for all Jdp packets + */ +public abstract class JdpGenericPacket implements JdpPacket { + + /** + * JDP protocol magic. Magic allows a reader to quickly select + * JDP packets from a bunch of broadcast packets addressed to the same port + * and broadcast group. Any packet intended to be parsed by JDP client + * has to start from this magic. + */ + private static final int MAGIC = 0xC0FFEE42; + + /** + * Current version of protocol. Any implementation of this protocol has to + * conform with the packet structure and the flow described in JEP-168 + */ + private static final short PROTOCOL_VERSION = 1; + + /** + * Default do-nothing constructor + */ + protected JdpGenericPacket(){ + // do nothing + } + + + /** + * Validate protocol header magic field + * + * @param magic - value to validate + * @throws JdpException + */ + public static void checkMagic(int magic) + throws JdpException { + if (magic != MAGIC) { + throw new JdpException("Invalid JDP magic header: " + magic); + } + } + + /** + * Validate protocol header version field + * + * @param version - value to validate + * @throws JdpException + */ + public static void checkVersion(short version) + throws JdpException { + + if (version > PROTOCOL_VERSION) { + throw new JdpException("Unsupported protocol version: " + version); + } + } + + /** + * + * @return protocol magic + */ + public static int getMagic() { + return MAGIC; + } + + /** + * + * @return current protocol version + */ + public static short getVersion() { + return PROTOCOL_VERSION; + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpJmxPacket.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpJmxPacket.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** + * A packet to broadcasts JMX URL + * + * Fields: + * + *
    + *
  • UUID - broadcast session ID, changed every time when we start/stop + * discovery service
  • + *
  • JMX_URL - URL to connect to JMX service
  • + *
  • MAIN_CLASS - optional name of main class, filled from sun.java.command stripped for + * security reason to first space
  • + *
  • INSTANCE_NAME - optional custom name of particular instance as provided by customer
  • + *
+ */ +public final class JdpJmxPacket + extends JdpGenericPacket + implements JdpPacket { + + /** + * Session ID + */ + public final static String UUID_KEY = "DISCOVERABLE_SESSION_UUID"; + /** + * Name of main class + */ + public final static String MAIN_CLASS_KEY = "MAIN_CLASS"; + /** + * JMX service URL + */ + public final static String JMX_SERVICE_URL_KEY = "JMX_SERVICE_URL"; + /** + * Name of Java instance + */ + public final static String INSTANCE_NAME_KEY = "INSTANCE_NAME"; + + private UUID id; + private String mainClass; + private String jmxServiceUrl; + private String instanceName; + + /** + * Create new instance from user provided data. Set mandatory fields + * + * @param id - java instance id + * @param jmxServiceUrl - JMX service url + */ + public JdpJmxPacket(UUID id, String jmxServiceUrl) { + this.id = id; + this.jmxServiceUrl = jmxServiceUrl; + } + + /** + * Create new instance from network data Parse packet and set fields. + * + * @param data - raw packet data as it came from a Net + * @throws JdpException + */ + public JdpJmxPacket(byte[] data) + throws JdpException { + JdpPacketReader reader; + + reader = new JdpPacketReader(data); + Map p = reader.getDiscoveryDataAsMap(); + + String sId = p.get(UUID_KEY); + this.id = (sId == null) ? null : UUID.fromString(sId); + this.jmxServiceUrl = p.get(JMX_SERVICE_URL_KEY); + this.mainClass = p.get(MAIN_CLASS_KEY); + this.instanceName = p.get(INSTANCE_NAME_KEY); + } + + /** + * Set main class field + * + * @param mainClass - main class of running app + */ + public void setMainClass(String mainClass) { + this.mainClass = mainClass; + } + + /** + * Set instance name field + * + * @param instanceName - name of instance as provided by customer + */ + public void setInstanceName(String instanceName) { + this.instanceName = instanceName; + } + + /** + * @return id of discovery session + */ + public UUID getId() { + return id; + } + + /** + * + * @return main class field + */ + public String getMainClass() { + return mainClass; + } + + /** + * + * @return JMX service URL + */ + public String getJmxServiceUrl() { + return jmxServiceUrl; + } + + /** + * + * @return instance name + */ + public String getInstanceName() { + return instanceName; + } + + /** + * + * @return assembled packet ready to be sent across a Net + * @throws IOException + */ + @Override + public byte[] getPacketData() throws IOException { + // Assemble packet from fields to byte array + JdpPacketWriter writer; + writer = new JdpPacketWriter(); + writer.addEntry(UUID_KEY, (id == null) ? null : id.toString()); + writer.addEntry(MAIN_CLASS_KEY, mainClass); + writer.addEntry(JMX_SERVICE_URL_KEY, jmxServiceUrl); + writer.addEntry(INSTANCE_NAME_KEY, instanceName); + return writer.getPacketBytes(); + } + + /** + * + * @return packet hash code + */ + @Override + public int hashCode() { + int hash = 1; + hash = hash * 31 + id.hashCode(); + hash = hash * 31 + jmxServiceUrl.hashCode(); + return hash; + } + + /** + * Compare two packets + * + * @param o - packet to compare + * @return either packet equals or not + */ + @Override + public boolean equals(Object o) { + + if (o == null || ! (o instanceof JdpJmxPacket) ){ + return false; + } + + JdpJmxPacket p = (JdpJmxPacket) o; + return Objects.equals(id, p.getId()) && Objects.equals(jmxServiceUrl, p.getJmxServiceUrl()); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpPacket.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpPacket.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.management.jdp; + +import java.io.IOException; + +/** + * Packet to broadcast + * + *

Each packet have to contain MAGIC and PROTOCOL_VERSION in order to be + * recognized as a valid JDP packet.

+ * + *

Default implementation build packet as a set of UTF-8 encoded Key/Value pairs + * are stored as an ordered list of values, and are sent to the server + * in that order.

+ * + *

+ * Packet structure: + * + * 4 bytes JDP magic (0xC0FFE42) + * 2 bytes JDP protocol version (01) + * + * 2 bytes size of key + * x bytes key (UTF-8 encoded) + * 2 bytes size of value + * x bytes value (UTF-8 encoded) + * + * repeat as many times as necessary ... + *

+ */ +public interface JdpPacket { + + /** + * This method responsible to assemble packet and return a byte array + * ready to be sent across a Net. + * + * @return assembled packet as an array of bytes + * @throws IOException + */ + public byte[] getPacketData() throws IOException; + +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpPacketReader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpPacketReader.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * JdpPacketReader responsible for reading a packet

This class gets a byte + * array as it came from a Net, validates it and breaks a part

+ */ +public final class JdpPacketReader { + + private final DataInputStream pkt; + private Map pmap = null; + + /** + * Create packet reader, extract and check magic and version + * + * @param packet - packet received from a Net + * @throws JdpException + */ + public JdpPacketReader(byte[] packet) + throws JdpException { + ByteArrayInputStream bais = new ByteArrayInputStream(packet); + pkt = new DataInputStream(bais); + + try { + int magic = pkt.readInt(); + JdpGenericPacket.checkMagic(magic); + } catch (IOException e) { + throw new JdpException("Invalid JDP packet received, bad magic"); + } + + try { + short version = pkt.readShort(); + JdpGenericPacket.checkVersion(version); + } catch (IOException e) { + throw new JdpException("Invalid JDP packet received, bad protocol version"); + } + } + + /** + * Get next entry from packet + * + * @return the entry + * @throws EOFException + * @throws JdpException + */ + public String getEntry() + throws EOFException, JdpException { + + try { + short len = pkt.readShort(); + // Artificial setting the "len" field to Short.MAX_VALUE may cause a reader to allocate + // to much memory. Prevent this possible DOS attack. + if (len < 1 && len > pkt.available()) { + throw new JdpException("Broken JDP packet. Invalid entry length field."); + } + + byte[] b = new byte[len]; + if (pkt.read(b) != len) { + throw new JdpException("Broken JDP packet. Unable to read entry."); + } + return new String(b, "UTF-8"); + + } catch (EOFException e) { + throw e; + } catch (UnsupportedEncodingException ex) { + throw new JdpException("Broken JDP packet. Unable to decode entry."); + } catch (IOException e) { + throw new JdpException("Broken JDP packet. Unable to read entry."); + } + + + } + + /** + * return packet content as a key/value map + * + * @return map containing packet entries pair of entries treated as + * key,value + * @throws IOException + * @throws JdpException + */ + public Map getDiscoveryDataAsMap() + throws JdpException { + // return cached map if possible + if (pmap != null) { + return pmap; + } + + String key = null, value = null; + + final Map tmpMap = new HashMap<>(); + try { + while (true) { + key = getEntry(); + value = getEntry(); + tmpMap.put(key, value); + } + } catch (EOFException e) { + // EOF reached on reading value, report broken packet + // otherwise ignore it. + if (value == null) { + throw new JdpException("Broken JDP packet. Key without value." + key); + } + } + + pmap = Collections.unmodifiableMap(tmpMap); + return pmap; + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/JdpPacketWriter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/JdpPacketWriter.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.management.jdp; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +/** + * JdpPacketWriter responsible for writing a packet + *

This class assembles a set of key/value pairs to valid JDP packet, + * ready to be sent across a Net

+ */ +public final class JdpPacketWriter { + + private final ByteArrayOutputStream baos; + private final DataOutputStream pkt; + + /** + * Create a JDP packet, add mandatory magic and version headers + * + * @throws IOException + */ + public JdpPacketWriter() + throws IOException { + baos = new ByteArrayOutputStream(); + pkt = new DataOutputStream(baos); + + pkt.writeInt(JdpGenericPacket.getMagic()); + pkt.writeShort(JdpGenericPacket.getVersion()); + } + + /** + * Put string entry to packet + * + * @param entry - string to put (utf-8 encoded) + * @throws IOException + */ + public void addEntry(String entry) + throws IOException { + pkt.writeShort(entry.length()); + byte[] b = entry.getBytes("UTF-8"); + pkt.write(b); + } + + /** + * Put key/value pair to packet + * + * @param key - key to put (utf-8 encoded) + * @param val - value to put (utf-8 encoded) + * @throws IOException + */ + public void addEntry(String key, String val) + throws IOException { + /* Silently skip key if value is null. + * We don't need to distinguish between key missing + * and key has no value cases + */ + if (val != null) { + addEntry(key); + addEntry(val); + } + } + + /** + * Return assembled packet as a byte array + * + * @return packet bytes + */ + public byte[] getPacketBytes() { + return baos.toByteArray(); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/management/jdp/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/management/jdp/package-info.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,55 @@ +/** + * Summary + * ------- + * + * Define a lightweight network protocol for discovering running and + * manageable Java processes within a network subnet. + * + * + * Description + * ----------- + * + * The protocol is lightweight multicast based, and works like a beacon, + * broadcasting the JMXService URL needed to connect to the external JMX + * agent if an application is started with appropriate parameters. + * + * The payload is structured like this: + * + * 4 bytes JDP magic (0xC0FFEE42) + * 2 bytes JDP protocol version (1) + * 2 bytes size of the next entry + * x bytes next entry (UTF-8 encoded) + * 2 bytes size of next entry + * ... Rinse and repeat... + * + * The payload will be parsed as even entries being keys, odd entries being + * values. + * + * The standard JDP packet contains four entries: + * + * - `DISCOVERABLE_SESSION_UUID` -- Unique id of the instance; this id changes every time + * the discovery protocol starts and stops + * + * - `MAIN_CLASS` -- The value of the `sun.java.command` property + * + * - `JMX_SERVICE_URL` -- The URL to connect to the JMX agent + * + * - `INSTANCE_NAME` -- The user-provided name of the running instance + * + * The protocol sends packets to 239.255.255.225:7095 by default. + * + * The protocol uses system properties to control it's behaviour: + * - `com.sun.management.jdp.port` -- override default port + * + * - `com.sun.management.jdp.address` -- override default address + * + * - `com.sun.management.jmxremote.autodiscovery` -- whether we should start autodiscovery or + * not. Autodiscovery starts if and only if following conditions are met: (autodiscovery is + * true OR (autodiscovery is not set AND jdp.port is set)) + * + * - `com.sun.management.jdp.ttl` -- set ttl for broadcast packet, default is 1 + * - `com.sun.management.jdp.pause` -- set broadcast interval in seconds default is 5 + * - `com.sun.management.jdp.source_addr` -- an address of interface to use for broadcast + */ + +package sun.management.jdp; diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/misc/Contended.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/misc/Contended.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.misc; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * This annotation marks classes and fields as considered to be contended. + * @since 1.8 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.TYPE}) +public @interface Contended { + + /** + Defines the contention group tag. + */ + String value() default ""; +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/misc/JavaLangAccess.java --- a/src/share/classes/sun/misc/JavaLangAccess.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/misc/JavaLangAccess.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ package sun.misc; import java.lang.annotation.Annotation; +import java.lang.reflect.Executable; import sun.reflect.ConstantPool; import sun.reflect.annotation.AnnotationType; import sun.nio.ch.Interruptible; @@ -47,6 +48,18 @@ AnnotationType getAnnotationType(Class klass); /** + * Get the array of bytes that is the class-file representation + * of this Class' type annotations. + */ + byte[] getRawClassTypeAnnotations(Class klass); + + /** + * Get the array of bytes that is the class-file representation + * of this Executable's type annotations. + */ + byte[] getRawExecutableTypeAnnotations(Executable executable); + + /** * Returns the elements of an enum class or null if the * Class object does not represent an enum type; * the result is uncloned, cached, and shared by all callers. @@ -84,9 +97,4 @@ * Returns the ith StackTraceElement for the given throwable. */ StackTraceElement getStackTraceElement(Throwable t, int i); - - /** - * Returns a directly present annotation. - */ - public A getDirectDeclaredAnnotation(Class klass, Class anno); } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/nio/cs/ISO_8859_1.java --- a/src/share/classes/sun/nio/cs/ISO_8859_1.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/nio/cs/ISO_8859_1.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,37 +147,53 @@ private final Surrogate.Parser sgp = new Surrogate.Parser(); + // JVM may replace this method with intrinsic code. + private static int encodeISOArray(char[] sa, int sp, + byte[] da, int dp, int len) + { + int i = 0; + for (; i < len; i++) { + char c = sa[sp++]; + if (c > '\u00FF') + break; + da[dp++] = (byte)c; + } + return i; + } + private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) { char[] sa = src.array(); - int sp = src.arrayOffset() + src.position(); - int sl = src.arrayOffset() + src.limit(); + int soff = src.arrayOffset(); + int sp = soff + src.position(); + int sl = soff + src.limit(); assert (sp <= sl); sp = (sp <= sl ? sp : sl); byte[] da = dst.array(); - int dp = dst.arrayOffset() + dst.position(); - int dl = dst.arrayOffset() + dst.limit(); + int doff = dst.arrayOffset(); + int dp = doff + dst.position(); + int dl = doff + dst.limit(); assert (dp <= dl); dp = (dp <= dl ? dp : dl); + int dlen = dl - dp; + int slen = sl - sp; + int len = (dlen < slen) ? dlen : slen; try { - while (sp < sl) { - char c = sa[sp]; - if (c <= '\u00FF') { - if (dp >= dl) - return CoderResult.OVERFLOW; - da[dp++] = (byte)c; - sp++; - continue; - } - if (sgp.parse(c, sa, sp, sl) < 0) + int ret = encodeISOArray(sa, sp, da, dp, len); + sp = sp + ret; + dp = dp + ret; + if (ret != len) { + if (sgp.parse(sa[sp], sa, sp, sl) < 0) return sgp.error(); return sgp.unmappableResult(); } + if (len < slen) + return CoderResult.OVERFLOW; return CoderResult.UNDERFLOW; } finally { - src.position(sp - src.arrayOffset()); - dst.position(dp - dst.arrayOffset()); + src.position(sp - soff); + dst.position(dp - doff); } } @@ -221,22 +237,25 @@ public int encode(char[] src, int sp, int len, byte[] dst) { int dp = 0; - int sl = sp + Math.min(len, dst.length); + int slen = Math.min(len, dst.length); + int sl = sp + slen; while (sp < sl) { - char c = src[sp++]; - if (c <= '\u00FF') { - dst[dp++] = (byte)c; - continue; + int ret = encodeISOArray(src, sp, dst, dp, slen); + sp = sp + ret; + dp = dp + ret; + if (ret != slen) { + char c = src[sp++]; + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(src[sp])) { + if (len > dst.length) { + sl++; + len--; + } + sp++; + } + dst[dp++] = repl; + slen = Math.min((sl - sp), (dst.length - dp)); } - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - if (len > dst.length) { - sl++; - len--; - } - sp++; - } - dst[dp++] = repl; } return dp; } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/LangReflectAccess.java --- a/src/share/classes/sun/reflect/LangReflectAccess.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/reflect/LangReflectAccess.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,6 +81,9 @@ public void setConstructorAccessor(Constructor c, ConstructorAccessor accessor); + /** Gets the byte[] that encodes TypeAnnotations on an Executable. */ + public byte[] getExecutableTypeAnnotationBytes(Executable ex); + /** Gets the "slot" field from a Constructor (used for serialization) */ public int getConstructorSlot(Constructor c); diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/ReflectionFactory.java --- a/src/share/classes/sun/reflect/ReflectionFactory.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/reflect/ReflectionFactory.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * 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,7 @@ package sun.reflect; import java.lang.reflect.Field; +import java.lang.reflect.Executable; import java.lang.reflect.Method; import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; @@ -314,6 +315,12 @@ return langReflectAccess().copyConstructor(arg); } + /** Gets the byte[] that encodes TypeAnnotations on an executable. + */ + public byte[] getExecutableTypeAnnotationBytes(Executable ex) { + return langReflectAccess().getExecutableTypeAnnotationBytes(ex); + } + //-------------------------------------------------------------------------- // // Routines used by serialization diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.reflect.annotation; + +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static sun.reflect.annotation.TypeAnnotation.*; + +public class AnnotatedTypeFactory { + /** + * Create an AnnotatedType. + * + * @param type the type this AnnotatedType corresponds to + * @param currentLoc the location this AnnotatedType corresponds to + * @param actualTypeAnnos the type annotations this AnnotatedType has + * @param allOnSameTarget all type annotation on the same TypeAnnotationTarget + * as the AnnotatedType being built + * @param decl the declaration having the type use this AnnotatedType + * corresponds to + */ + public static AnnotatedType buildAnnotatedType(Type type, + LocationInfo currentLoc, + TypeAnnotation[] actualTypeAnnos, + TypeAnnotation[] allOnSameTarget, + AnnotatedElement decl) { + if (type == null) { + return EMPTY_ANNOTATED_TYPE; + } + if (isArray(type)) + return new AnnotatedArrayTypeImpl(type, + currentLoc, + actualTypeAnnos, + allOnSameTarget, + decl); + if (type instanceof Class) { + return new AnnotatedTypeBaseImpl(type, + addNesting(type, currentLoc), + actualTypeAnnos, + allOnSameTarget, + decl); + } else if (type instanceof TypeVariable) { + return new AnnotatedTypeVariableImpl((TypeVariable)type, + currentLoc, + actualTypeAnnos, + allOnSameTarget, + decl); + } else if (type instanceof ParameterizedType) { + return new AnnotatedParameterizedTypeImpl((ParameterizedType)type, + addNesting(type, currentLoc), + actualTypeAnnos, + allOnSameTarget, + decl); + } else if (type instanceof WildcardType) { + return new AnnotatedWildcardTypeImpl((WildcardType) type, + currentLoc, + actualTypeAnnos, + allOnSameTarget, + decl); + } + throw new AssertionError("Unknown instance of Type: " + type + "\nThis should not happen."); + } + + private static LocationInfo addNesting(Type type, LocationInfo addTo) { + if (isArray(type)) + return addTo; + if (type instanceof Class) { + Class clz = (Class)type; + if (clz.getEnclosingClass() == null) + return addTo; + return addNesting(clz.getEnclosingClass(), addTo.pushInner()); + } else if (type instanceof ParameterizedType) { + ParameterizedType t = (ParameterizedType)type; + if (t.getOwnerType() == null) + return addTo; + return addNesting(t.getOwnerType(), addTo.pushInner()); + } + return addTo; + } + + private static boolean isArray(Type t) { + if (t instanceof Class) { + Class c = (Class)t; + if (c.isArray()) + return true; + } else if (t instanceof GenericArrayType) { + return true; + } + return false; + } + + static final AnnotatedType EMPTY_ANNOTATED_TYPE = new AnnotatedTypeBaseImpl(null, LocationInfo.BASE_LOCATION, + new TypeAnnotation[0], new TypeAnnotation[0], null); + + private static class AnnotatedTypeBaseImpl implements AnnotatedType { + private final Type type; + private final AnnotatedElement decl; + private final LocationInfo location; + private final TypeAnnotation[] allOnSameTargetTypeAnnotations; + private final Map, Annotation> annotations; + + AnnotatedTypeBaseImpl(Type type, LocationInfo location, + TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, + AnnotatedElement decl) { + this.type = type; + this.decl = decl; + this.location = location; + this.allOnSameTargetTypeAnnotations = allOnSameTargetTypeAnnotations; + this.annotations = TypeAnnotationParser.mapTypeAnnotations(location.filter(actualTypeAnnotations)); + } + + // AnnotatedElement + @Override + public final boolean isAnnotationPresent(Class annotation) { + return annotations.get(annotation) != null; + } + + @Override + public final Annotation[] getAnnotations() { + return getDeclaredAnnotations(); + } + + @Override + public final T getAnnotation(Class annotation) { + return getDeclaredAnnotation(annotation); + } + + @Override + public final T[] getAnnotations(Class annotation) { + return getDeclaredAnnotations(annotation); + } + + @Override + public Annotation[] getDeclaredAnnotations() { + return annotations.values().toArray(new Annotation[0]); + } + + @Override + @SuppressWarnings("unchecked") + public T getDeclaredAnnotation(Class annotation) { + return (T)annotations.get(annotation); + } + + @Override + public T[] getDeclaredAnnotations(Class annotation) { + return AnnotationSupport.getMultipleAnnotations(annotations, annotation); + } + + // AnnotatedType + @Override + public Type getType() { + return type; + } + + // Implementation details + LocationInfo getLocation() { + return location; + } + TypeAnnotation[] getTypeAnnotations() { + return allOnSameTargetTypeAnnotations; + } + AnnotatedElement getDecl() { + return decl; + } + } + + private static class AnnotatedArrayTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedArrayType { + AnnotatedArrayTypeImpl(Type type, LocationInfo location, + TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, + AnnotatedElement decl) { + super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl); + } + + @Override + public AnnotatedType getAnnotatedGenericComponentType() { + return AnnotatedTypeFactory.buildAnnotatedType(getComponentType(), + getLocation().pushArray(), + getTypeAnnotations(), + getTypeAnnotations(), + getDecl()); + } + + private Type getComponentType() { + Type t = getType(); + if (t instanceof Class) { + Class c = (Class)t; + return c.getComponentType(); + } + return ((GenericArrayType)t).getGenericComponentType(); + } + } + + private static class AnnotatedTypeVariableImpl extends AnnotatedTypeBaseImpl implements AnnotatedTypeVariable { + AnnotatedTypeVariableImpl(TypeVariable type, LocationInfo location, + TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, + AnnotatedElement decl) { + super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl); + } + + @Override + public AnnotatedType[] getAnnotatedBounds() { + return getTypeVariable().getAnnotatedBounds(); + } + + private TypeVariable getTypeVariable() { + return (TypeVariable)getType(); + } + } + + private static class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedParameterizedType { + AnnotatedParameterizedTypeImpl(ParameterizedType type, LocationInfo location, + TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, + AnnotatedElement decl) { + super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl); + } + + @Override + public AnnotatedType[] getAnnotatedActualTypeArguments() { + Type[] arguments = getParameterizedType().getActualTypeArguments(); + AnnotatedType[] res = new AnnotatedType[arguments.length]; + Arrays.fill(res, EMPTY_ANNOTATED_TYPE); + int initialCapacity = getTypeAnnotations().length; + for (int i = 0; i < res.length; i++) { + List l = new ArrayList<>(initialCapacity); + LocationInfo newLoc = getLocation().pushTypeArg((byte)i); + for (TypeAnnotation t : getTypeAnnotations()) + if (t.getLocationInfo().isSameLocationInfo(newLoc)) + l.add(t); + res[i] = buildAnnotatedType(arguments[i], + newLoc, + l.toArray(new TypeAnnotation[0]), + getTypeAnnotations(), + getDecl()); + } + return res; + } + + private ParameterizedType getParameterizedType() { + return (ParameterizedType)getType(); + } + } + + private static class AnnotatedWildcardTypeImpl extends AnnotatedTypeBaseImpl implements AnnotatedWildcardType { + private final boolean hasUpperBounds; + AnnotatedWildcardTypeImpl(WildcardType type, LocationInfo location, + TypeAnnotation[] actualTypeAnnotations, TypeAnnotation[] allOnSameTargetTypeAnnotations, + AnnotatedElement decl) { + super(type, location, actualTypeAnnotations, allOnSameTargetTypeAnnotations, decl); + hasUpperBounds = (type.getLowerBounds().length == 0); + } + + @Override + public AnnotatedType[] getAnnotatedUpperBounds() { + if (!hasUpperBounds()) + return new AnnotatedType[0]; + return getAnnotatedBounds(getWildcardType().getUpperBounds()); + } + + @Override + public AnnotatedType[] getAnnotatedLowerBounds() { + if (hasUpperBounds) + return new AnnotatedType[0]; + return getAnnotatedBounds(getWildcardType().getLowerBounds()); + } + + private AnnotatedType[] getAnnotatedBounds(Type[] bounds) { + AnnotatedType[] res = new AnnotatedType[bounds.length]; + Arrays.fill(res, EMPTY_ANNOTATED_TYPE); + LocationInfo newLoc = getLocation().pushWildcard(); + int initialCapacity = getTypeAnnotations().length; + for (int i = 0; i < res.length; i++) { + List l = new ArrayList<>(initialCapacity); + for (TypeAnnotation t : getTypeAnnotations()) + if (t.getLocationInfo().isSameLocationInfo(newLoc)) + l.add(t); + res[i] = buildAnnotatedType(bounds[i], + newLoc, + l.toArray(new TypeAnnotation[0]), + getTypeAnnotations(), + getDecl()); + } + return res; + } + + private WildcardType getWildcardType() { + return (WildcardType)getType(); + } + + private boolean hasUpperBounds() { + return hasUpperBounds; + } + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/annotation/AnnotationParser.java --- a/src/share/classes/sun/reflect/annotation/AnnotationParser.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/reflect/annotation/AnnotationParser.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -188,7 +188,7 @@ * available at runtime */ @SuppressWarnings("unchecked") - private static Annotation parseAnnotation(ByteBuffer buf, + static Annotation parseAnnotation(ByteBuffer buf, ConstantPool constPool, Class container, boolean exceptionOnMissingAnnotationClass) { diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/annotation/AnnotationSupport.java --- a/src/share/classes/sun/reflect/annotation/AnnotationSupport.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/reflect/annotation/AnnotationSupport.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * 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,63 +27,29 @@ import java.lang.annotation.*; import java.lang.reflect.*; -import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Objects; -import sun.reflect.Reflection; -import sun.misc.JavaLangAccess; public final class AnnotationSupport { - private static final JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess(); - - /** - * Finds and returns _one_ annotation of the type indicated by - * {@code annotationClass} from the {@code Map} {@code - * annotationMap}. Looks into containers of the {@code - * annotationClass} (as specified by an the {@code - * annotationClass} type being meta-annotated with an {@code - * ContainedBy} annotation). - * - * @param annotationMap the {@code Map} used to store annotations and indexed by their type - * @param annotationClass the type of annotation to search for - * - * @return in instance of {@code annotationClass} or {@code null} if none were found - */ - public static A getOneAnnotation(final Map, Annotation> annotationMap, - final Class annotationClass) { - @SuppressWarnings("unchecked") - final A candidate = (A)annotationMap.get(annotationClass); - if (candidate != null) { - return candidate; - } - - final Class containerClass = getContainer(annotationClass); - if (containerClass != null) { - return unpackOne(annotationMap.get(containerClass), annotationClass); - } - - return null; // found none - } - /** * Finds and returns all annotation of the type indicated by * {@code annotationClass} from the {@code Map} {@code * annotationMap}. Looks into containers of the {@code * annotationClass} (as specified by an the {@code * annotationClass} type being meta-annotated with an {@code - * ContainedBy} annotation). + * Repeatable} annotation). * * @param annotationMap the {@code Map} used to store annotations indexed by their type * @param annotationClass the type of annotation to search for * * @return an array of instances of {@code annotationClass} or an empty array if none were found */ - public static A[] getMultipleAnnotations(final Map, Annotation> annotationMap, - final Class annotationClass) { - final ArrayList res = new ArrayList(); + public static A[] getMultipleAnnotations( + final Map, Annotation> annotationMap, + final Class annotationClass) { + final List res = new ArrayList(); @SuppressWarnings("unchecked") final A candidate = (A)annotationMap.get(annotationClass); @@ -101,49 +67,10 @@ return res.isEmpty() ? emptyTemplateArray : res.toArray(emptyTemplateArray); } - /** - * Unpacks the {@code annotationMap} parameter into an array of - * {@code Annotation}s. This method will unpack all repeating - * annotations containers (once). An annotation type is marked as a - * container by meta-annotating it the with the {@code - * ContainerFor} annotation. - * - * @param annotationMap the {@code Map} from where the annotations are unpacked - * - * @return an array of Annotation - */ - public static Annotation[] unpackToArray(Map, Annotation> annotationMap) { - List res = new ArrayList<>(); - for (Map.Entry, Annotation> e : annotationMap.entrySet()) { - Class annotationClass = e.getKey(); - Annotation annotationInstance = e.getValue(); - Class containee = getContainee(e.getKey()); - boolean isContainer = javaLangAccess.getDirectDeclaredAnnotation(annotationClass, ContainerFor.class) != null; - - if (isContainer) { - res.addAll(unpackAll(annotationInstance, containee)); - } else { - res.add(annotationInstance); - } - } - - return res.isEmpty() - ? AnnotationParser.getEmptyAnnotationArray() - : res.toArray(AnnotationParser.getEmptyAnnotationArray()); - } - /** Helper to get the container, or null if none, of an annotation. */ private static Class getContainer(Class annotationClass) { - ContainedBy containerAnnotation = - javaLangAccess.getDirectDeclaredAnnotation(annotationClass, ContainedBy.class); - return (containerAnnotation == null) ? null : containerAnnotation.value(); - } - - /** Helper to get the containee, or null if this isn't a container, of a possible container annotation. */ - private static Class getContainee(Class annotationClass) { - ContainerFor containerAnnotation = - javaLangAccess.getDirectDeclaredAnnotation(annotationClass, ContainerFor.class); - return (containerAnnotation == null) ? null : containerAnnotation.value(); + Repeatable containingAnnotation = annotationClass.getDeclaredAnnotation(Repeatable.class); + return (containingAnnotation == null) ? null : containingAnnotation.value(); } /** Reflectively look up and get the returned array from the the @@ -156,14 +83,15 @@ // value element. Get the AnnotationType, get the "value" element // and invoke it to get the contents. - Class containerClass = containerInstance.annotationType(); - AnnotationType annoType = javaLangAccess.getAnnotationType(containerClass); + Class containerClass = containerInstance.annotationType(); + AnnotationType annoType = AnnotationType.getInstance(containerClass); if (annoType == null) throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations"); Method m = annoType.members().get("value"); if (m == null) - throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations"); + throw new InvalidContainerAnnotationError(containerInstance + + " is an invalid container for repeating annotations"); m.setAccessible(true); @SuppressWarnings("unchecked") // not provably safe, but we catch the ClassCastException @@ -175,32 +103,11 @@ IllegalArgumentException | // parameters doesn't match InvocationTargetException | // the value method threw an exception ClassCastException e) { // well, a cast failed ... - throw new InvalidContainerAnnotationError(containerInstance + " is an invalid container for repeating annotations", - e, - containerInstance, - null); - } - } - - /* Sanity check type of and return the first annotation instance - * of type {@code annotationClass} from {@code - * containerInstance}. - */ - private static A unpackOne(Annotation containerInstance, Class annotationClass) { - if (containerInstance == null) { - return null; - } - - try { - return annotationClass.cast(getValueArray(containerInstance)[0]); - } catch (ArrayIndexOutOfBoundsException | // empty array - ClassCastException | // well, a cast failed ... - NullPointerException e) { // can this NP? for good meassure - throw new InvalidContainerAnnotationError(String.format("%s is an invalid container for repeating annotations of type: %s", - containerInstance, annotationClass), - e, - containerInstance, - annotationClass); + throw new InvalidContainerAnnotationError( + containerInstance + " is an invalid container for repeating annotations", + e, + containerInstance, + null); } } @@ -208,24 +115,26 @@ * instances of type {@code annotationClass} from {@code * containerInstance}. */ - private static List unpackAll(Annotation containerInstance, Class annotationClass) { + private static List unpackAll(Annotation containerInstance, + Class annotationClass) { if (containerInstance == null) { return Collections.emptyList(); // container not present } try { A[] a = getValueArray(containerInstance); - ArrayList l = new ArrayList<>(a.length); + List l = new ArrayList<>(a.length); for (int i = 0; i < a.length; i++) l.add(annotationClass.cast(a[i])); return l; } catch (ClassCastException | NullPointerException e) { - throw new InvalidContainerAnnotationError(String.format("%s is an invalid container for repeating annotations of type: %s", - containerInstance, annotationClass), - e, - containerInstance, - annotationClass); + throw new InvalidContainerAnnotationError( + String.format("%s is an invalid container for repeating annotations of type: %s", + containerInstance, annotationClass), + e, + containerInstance, + annotationClass); } } } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/annotation/TypeAnnotation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/reflect/annotation/TypeAnnotation.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.reflect.annotation; + +import java.lang.annotation.Annotation; +import java.lang.annotation.AnnotationFormatError; +import java.lang.reflect.AnnotatedElement; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; + +/** + * A TypeAnnotation contains all the information needed to transform type + * annotations on declarations in the class file to actual Annotations in + * AnnotatedType instances. + * + * TypeAnnotaions contain a base Annotation, location info (which lets you + * distinguish between '@A Inner.@B Outer' in for example nested types), + * target info and the declaration the TypeAnnotaiton was parsed from. + */ +public class TypeAnnotation { + private final TypeAnnotationTargetInfo targetInfo; + private final LocationInfo loc; + private final Annotation annotation; + private final AnnotatedElement baseDeclaration; + + public TypeAnnotation(TypeAnnotationTargetInfo targetInfo, + LocationInfo loc, + Annotation annotation, + AnnotatedElement baseDeclaration) { + this.targetInfo = targetInfo; + this.loc = loc; + this.annotation = annotation; + this.baseDeclaration = baseDeclaration; + } + + public TypeAnnotationTargetInfo getTargetInfo() { + return targetInfo; + } + public Annotation getAnnotation() { + return annotation; + } + public AnnotatedElement getBaseDeclaration() { + return baseDeclaration; + } + public LocationInfo getLocationInfo() { + return loc; + } + + public static List filter(TypeAnnotation[] typeAnnotations, + TypeAnnotationTarget predicate) { + ArrayList typeAnnos = new ArrayList<>(typeAnnotations.length); + for (TypeAnnotation t : typeAnnotations) + if (t.getTargetInfo().getTarget() == predicate) + typeAnnos.add(t); + typeAnnos.trimToSize(); + return typeAnnos; + } + + public static enum TypeAnnotationTarget { + CLASS_TYPE_PARAMETER, + METHOD_TYPE_PARAMETER, + CLASS_EXTENDS, + CLASS_IMPLEMENTS, + CLASS_PARAMETER_BOUND, + METHOD_PARAMETER_BOUND, + METHOD_RETURN_TYPE, + METHOD_RECEIVER_TYPE, + FIELD_TYPE, + THROWS; + } + public static class TypeAnnotationTargetInfo { + private final TypeAnnotationTarget target; + private final int count; + private final int secondaryIndex; + private static final int UNUSED_INDEX = -2; // this is not a valid index in the 308 spec + + public TypeAnnotationTargetInfo(TypeAnnotationTarget target) { + this(target, UNUSED_INDEX, UNUSED_INDEX); + } + + public TypeAnnotationTargetInfo(TypeAnnotationTarget target, + int count) { + this(target, count, UNUSED_INDEX); + } + + public TypeAnnotationTargetInfo(TypeAnnotationTarget target, + int count, + int secondaryIndex) { + this.target = target; + this.count = count; + this.secondaryIndex = secondaryIndex; + } + + public TypeAnnotationTarget getTarget() { + return target; + } + public int getCount() { + return count; + } + public int getSecondaryIndex() { + return secondaryIndex; + } + + @Override + public String toString() { + return "" + target + ": " + count + ", " + secondaryIndex; + } + } + + public static class LocationInfo { + private final int depth; + private final Location[] locations; + + private LocationInfo() { + this(0, new Location[0]); + } + private LocationInfo(int depth, Location[] locations) { + this.depth = depth; + this.locations = locations; + } + + public static final LocationInfo BASE_LOCATION = new LocationInfo(); + + public static LocationInfo parseLocationInfo(ByteBuffer buf) { + int depth = buf.get(); + if (depth == 0) + return BASE_LOCATION; + Location[] locations = new Location[depth]; + for (int i = 0; i < depth; i++) { + byte tag = buf.get(); + byte index = buf.get(); + if (!(tag == 0 || tag == 1 | tag == 2 || tag == 3)) + throw new AnnotationFormatError("Bad Location encoding in Type Annotation"); + if (tag != 3 && index != 0) + throw new AnnotationFormatError("Bad Location encoding in Type Annotation"); + locations[i] = new Location(tag, index); + } + return new LocationInfo(depth, locations); + } + + public LocationInfo pushArray() { + return pushLocation((byte)0, (byte)0); + } + + public LocationInfo pushInner() { + return pushLocation((byte)1, (byte)0); + } + + public LocationInfo pushWildcard() { + return pushLocation((byte) 2, (byte) 0); + } + + public LocationInfo pushTypeArg(byte index) { + return pushLocation((byte) 3, index); + } + + public LocationInfo pushLocation(byte tag, byte index) { + int newDepth = this.depth + 1; + Location[] res = new Location[newDepth]; + System.arraycopy(this.locations, 0, res, 0, depth); + res[newDepth - 1] = new Location(tag, index); + return new LocationInfo(newDepth, res); + } + + public TypeAnnotation[] filter(TypeAnnotation[] ta) { + ArrayList l = new ArrayList<>(ta.length); + for (TypeAnnotation t : ta) { + if (isSameLocationInfo(t.getLocationInfo())) + l.add(t); + } + return l.toArray(new TypeAnnotation[0]); + } + + boolean isSameLocationInfo(LocationInfo other) { + if (depth != other.depth) + return false; + for (int i = 0; i < depth; i++) + if (!locations[i].isSameLocation(other.locations[i])) + return false; + return true; + } + + public static class Location { + public final byte tag; + public final byte index; + + boolean isSameLocation(Location other) { + return tag == other.tag && index == other.index; + } + + public Location(byte tag, byte index) { + this.tag = tag; + this.index = index; + } + } + } + + @Override + public String toString() { + return annotation.toString() + " with Targetnfo: " + + targetInfo.toString() + " on base declaration: " + + baseDeclaration.toString(); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/reflect/annotation/TypeAnnotationParser.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,491 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.reflect.annotation; + +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.nio.ByteBuffer; +import java.nio.BufferUnderflowException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import sun.misc.JavaLangAccess; +import sun.reflect.ConstantPool; +import static sun.reflect.annotation.TypeAnnotation.*; + +/** + * TypeAnnotationParser implements the logic needed to parse + * TypeAnnotations from an array of bytes. + */ +public class TypeAnnotationParser { + private static final TypeAnnotation[] EMPTY_TYPE_ANNOTATION_ARRAY = new TypeAnnotation[0]; + + /** + * Build an AnnotatedType from the parameters supplied. + * + * This method and {@code buildAnnotatedTypes} are probably + * the entry points you are looking for. + * + * @param rawAnnotations the byte[] encoding of all type annotations on this declaration + * @param cp the ConstantPool needed to parse the embedded Annotation + * @param decl the dclaration this type annotation is on + * @param container the Class this type annotation is on (may be the same as decl) + * @param type the type the AnnotatedType corresponds to + * @param filter the type annotation targets included in this AnnotatedType + */ + public static AnnotatedType buildAnnotatedType(byte[] rawAnnotations, + ConstantPool cp, + AnnotatedElement decl, + Class container, + Type type, + TypeAnnotationTarget filter) { + TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations, + cp, + decl, + container); + List l = new ArrayList<>(tas.length); + for (TypeAnnotation t : tas) { + TypeAnnotationTargetInfo ti = t.getTargetInfo(); + if (ti.getTarget() == filter) + l.add(t); + } + TypeAnnotation[] typeAnnotations = l.toArray(new TypeAnnotation[0]); + return AnnotatedTypeFactory.buildAnnotatedType(type, + LocationInfo.BASE_LOCATION, + typeAnnotations, + typeAnnotations, + decl); + } + + /** + * Build an array of AnnotatedTypes from the parameters supplied. + * + * This method and {@code buildAnnotatedType} are probably + * the entry points you are looking for. + * + * @param rawAnnotations the byte[] encoding of all type annotations on this declaration + * @param cp the ConstantPool needed to parse the embedded Annotation + * @param decl the declaration this type annotation is on + * @param container the Class this type annotation is on (may be the same as decl) + * @param types the Types the AnnotatedTypes corresponds to + * @param filter the type annotation targets that included in this AnnotatedType + */ + public static AnnotatedType[] buildAnnotatedTypes(byte[] rawAnnotations, + ConstantPool cp, + AnnotatedElement decl, + Class container, + Type[] types, + TypeAnnotationTarget filter) { + int size = types.length; + AnnotatedType[] result = new AnnotatedType[size]; + Arrays.fill(result, AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE); + @SuppressWarnings("rawtypes") + ArrayList[] l = new ArrayList[size]; // array of ArrayList + + TypeAnnotation[] tas = parseTypeAnnotations(rawAnnotations, + cp, + decl, + container); + for (TypeAnnotation t : tas) { + TypeAnnotationTargetInfo ti = t.getTargetInfo(); + if (ti.getTarget() == filter) { + int pos = ti.getCount(); + if (l[pos] == null) { + ArrayList tmp = new ArrayList<>(tas.length); + l[pos] = tmp; + } + @SuppressWarnings("unchecked") + ArrayList tmp = l[pos]; + tmp.add(t); + } + } + for (int i = 0; i < size; i++) { + @SuppressWarnings("unchecked") + ArrayList list = l[i]; + if (list != null) { + TypeAnnotation[] typeAnnotations = list.toArray(new TypeAnnotation[0]); + result[i] = AnnotatedTypeFactory.buildAnnotatedType(types[i], + LocationInfo.BASE_LOCATION, + typeAnnotations, + typeAnnotations, + decl); + } + } + return result; + } + + // Class helpers + + /** + * Build an AnnotatedType for the class decl's supertype. + * + * @param rawAnnotations the byte[] encoding of all type annotations on this declaration + * @param cp the ConstantPool needed to parse the embedded Annotation + * @param decl the Class which annotated supertype is being built + */ + public static AnnotatedType buildAnnotatedSuperclass(byte[] rawAnnotations, + ConstantPool cp, + Class decl) { + Type supertype = decl.getGenericSuperclass(); + if (supertype == null) + return AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE; + return buildAnnotatedType(rawAnnotations, + cp, + decl, + decl, + supertype, + TypeAnnotationTarget.CLASS_EXTENDS); + } + + /** + * Build an array of AnnotatedTypes for the class decl's implemented + * interfaces. + * + * @param rawAnnotations the byte[] encoding of all type annotations on this declaration + * @param cp the ConstantPool needed to parse the embedded Annotation + * @param decl the Class whose annotated implemented interfaces is being built + */ + public static AnnotatedType[] buildAnnotatedInterfaces(byte[] rawAnnotations, + ConstantPool cp, + Class decl) { + return buildAnnotatedTypes(rawAnnotations, + cp, + decl, + decl, + decl.getGenericInterfaces(), + TypeAnnotationTarget.CLASS_IMPLEMENTS); + } + + // TypeVariable helpers + + /** + * Parse regular annotations on a TypeVariable declared on genericDecl. + * + * Regular Annotations on TypeVariables are stored in the type + * annotation byte[] in the class file. + * + * @param genericsDecl the declaration declaring the type variable + * @param typeVarIndex the 0-based index of this type variable in the declaration + */ + public static Annotation[] parseTypeVariableAnnotations(D genericDecl, + int typeVarIndex) { + AnnotatedElement decl; + TypeAnnotationTarget predicate; + if (genericDecl instanceof Class) { + decl = (Class)genericDecl; + predicate = TypeAnnotationTarget.CLASS_TYPE_PARAMETER; + } else if (genericDecl instanceof Executable) { + decl = (Executable)genericDecl; + predicate = TypeAnnotationTarget.METHOD_TYPE_PARAMETER; + } else { + throw new AssertionError("Unknown GenericDeclaration " + genericDecl + "\nthis should not happen."); + } + List typeVarAnnos = TypeAnnotation.filter(parseAllTypeAnnotations(decl), + predicate); + List res = new ArrayList<>(typeVarAnnos.size()); + for (TypeAnnotation t : typeVarAnnos) + if (t.getTargetInfo().getCount() == typeVarIndex) + res.add(t.getAnnotation()); + return res.toArray(new Annotation[0]); + } + + /** + * Build an array of AnnotatedTypes for the declaration decl's bounds. + * + * @param bounds the bounds corresponding to the annotated bounds + * @param decl the declaration whose annotated bounds is being built + * @param typeVarIndex the index of this type variable on the decl + */ + public static AnnotatedType[] parseAnnotatedBounds(Type[] bounds, + D decl, + int typeVarIndex) { + return parseAnnotatedBounds(bounds, decl, typeVarIndex, LocationInfo.BASE_LOCATION); + } + //helper for above + static AnnotatedType[] parseAnnotatedBounds(Type[] bounds, + D decl, + int typeVarIndex, + LocationInfo loc) { + List candidates = fetchBounds(decl); + if (bounds != null) { + int startIndex = 0; + AnnotatedType[] res = new AnnotatedType[bounds.length]; + Arrays.fill(res, AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE); + + // Adjust bounds index + // + // Figure out if the type annotations for this bound starts with 0 + // or 1. The spec says within a bound the 0:th type annotation will + // always be on an bound of a Class type (not Interface type). So + // if the programmer starts with an Interface type for the first + // (and following) bound(s) the implicit Object bound is considered + // the first (that is 0:th) bound and type annotations start on + // index 1. + if (bounds.length > 0) { + Type b0 = bounds[0]; + if (!(b0 instanceof Class)) { + startIndex = 1; + } else { + Class c = (Class)b0; + if (c.isInterface()) { + startIndex = 1; + } + } + } + + for (int i = 0; i < bounds.length; i++) { + List l = new ArrayList<>(candidates.size()); + for (TypeAnnotation t : candidates) { + TypeAnnotationTargetInfo tInfo = t.getTargetInfo(); + if (tInfo.getSecondaryIndex() == i + startIndex && + tInfo.getCount() == typeVarIndex) { + l.add(t); + } + res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i], + loc, + l.toArray(new TypeAnnotation[0]), + candidates.toArray(new TypeAnnotation[0]), + (AnnotatedElement)decl); + } + } + return res; + } + return new AnnotatedType[0]; + } + private static List fetchBounds(D decl) { + AnnotatedElement boundsDecl; + TypeAnnotationTarget target; + if (decl instanceof Class) { + target = TypeAnnotationTarget.CLASS_PARAMETER_BOUND; + boundsDecl = (Class)decl; + } else { + target = TypeAnnotationTarget.METHOD_PARAMETER_BOUND; + boundsDecl = (Executable)decl; + } + return TypeAnnotation.filter(TypeAnnotationParser.parseAllTypeAnnotations(boundsDecl), target); + } + + /* + * Parse all type annotations on the declaration supplied. This is needed + * when you go from for example an annotated return type on a method that + * is a type variable declared on the class. In this case you need to + * 'jump' to the decl of the class and parse all type annotations there to + * find the ones that are applicable to the type variable. + */ + static TypeAnnotation[] parseAllTypeAnnotations(AnnotatedElement decl) { + Class container; + byte[] rawBytes; + JavaLangAccess javaLangAccess = sun.misc.SharedSecrets.getJavaLangAccess(); + if (decl instanceof Class) { + container = (Class)decl; + rawBytes = javaLangAccess.getRawClassTypeAnnotations(container); + } else if (decl instanceof Executable) { + container = ((Executable)decl).getDeclaringClass(); + rawBytes = javaLangAccess.getRawExecutableTypeAnnotations((Executable)decl); + } else { + // Should not reach here. Assert? + return EMPTY_TYPE_ANNOTATION_ARRAY; + } + return parseTypeAnnotations(rawBytes, javaLangAccess.getConstantPool(container), + decl, container); + } + + /* Parse type annotations encoded as an array of bytes */ + private static TypeAnnotation[] parseTypeAnnotations(byte[] rawAnnotations, + ConstantPool cp, + AnnotatedElement baseDecl, + Class container) { + if (rawAnnotations == null) + return EMPTY_TYPE_ANNOTATION_ARRAY; + + ByteBuffer buf = ByteBuffer.wrap(rawAnnotations); + int annotationCount = buf.getShort() & 0xFFFF; + List typeAnnotations = new ArrayList<>(annotationCount); + + // Parse each TypeAnnotation + for (int i = 0; i < annotationCount; i++) { + TypeAnnotation ta = parseTypeAnnotation(buf, cp, baseDecl, container); + if (ta != null) + typeAnnotations.add(ta); + } + + return typeAnnotations.toArray(EMPTY_TYPE_ANNOTATION_ARRAY); + } + + + // Helper + static Map, Annotation> mapTypeAnnotations(TypeAnnotation[] typeAnnos) { + Map, Annotation> result = + new LinkedHashMap<>(); + for (TypeAnnotation t : typeAnnos) { + Annotation a = t.getAnnotation(); + Class klass = a.annotationType(); + AnnotationType type = AnnotationType.getInstance(klass); + if (type.retention() == RetentionPolicy.RUNTIME) + if (result.put(klass, a) != null) + throw new AnnotationFormatError("Duplicate annotation for class: "+klass+": " + a); + } + return result; + } + + // Position codes + // Regular type parameter annotations + private static final byte CLASS_TYPE_PARAMETER = 0x00; + private static final byte METHOD_TYPE_PARAMETER = 0x01; + // Type Annotations outside method bodies + private static final byte CLASS_EXTENDS = 0x10; + private static final byte CLASS_TYPE_PARAMETER_BOUND = 0x11; + private static final byte METHOD_TYPE_PARAMETER_BOUND = 0x12; + private static final byte FIELD = 0x13; + private static final byte METHOD_RETURN = 0x14; + private static final byte METHOD_RECEIVER = 0x15; + private static final byte METHOD_FORMAL_PARAMETER = 0x16; + private static final byte THROWS = 0x17; + // Type Annotations inside method bodies + private static final byte LOCAL_VARIABLE = (byte)0x40; + private static final byte RESOURCE_VARIABLE = (byte)0x41; + private static final byte EXCEPTION_PARAMETER = (byte)0x42; + private static final byte CAST = (byte)0x43; + private static final byte INSTANCEOF = (byte)0x44; + private static final byte NEW = (byte)0x45; + private static final byte CONSTRUCTOR_REFERENCE_RECEIVER = (byte)0x46; + private static final byte METHOD_REFERENCE_RECEIVER = (byte)0x47; + private static final byte LAMBDA_FORMAL_PARAMETER = (byte)0x48; + private static final byte METHOD_REFERENCE = (byte)0x49; + private static final byte METHOD_REFERENCE_TYPE_ARGUMENT = (byte)0x50; + + private static TypeAnnotation parseTypeAnnotation(ByteBuffer buf, + ConstantPool cp, + AnnotatedElement baseDecl, + Class container) { + TypeAnnotationTargetInfo ti = parseTargetInfo(buf); + LocationInfo locationInfo = LocationInfo.parseLocationInfo(buf); + Annotation a = AnnotationParser.parseAnnotation(buf, cp, container, false); + if (ti == null) // Inside a method for example + return null; + return new TypeAnnotation(ti, locationInfo, a, baseDecl); + } + + private static TypeAnnotationTargetInfo parseTargetInfo(ByteBuffer buf) { + byte posCode = buf.get(); + switch(posCode) { + case CLASS_TYPE_PARAMETER: + case METHOD_TYPE_PARAMETER: { + byte index = buf.get(); + TypeAnnotationTargetInfo res; + if (posCode == CLASS_TYPE_PARAMETER) + res = new TypeAnnotationTargetInfo(TypeAnnotationTarget.CLASS_TYPE_PARAMETER, + index); + else + res = new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_TYPE_PARAMETER, + index); + return res; + } // unreachable break; + case CLASS_EXTENDS: { + short index = buf.getShort(); + if (index == -1) { + return new TypeAnnotationTargetInfo(TypeAnnotationTarget.CLASS_EXTENDS); + } else if (index >= 0) { + TypeAnnotationTargetInfo res = new TypeAnnotationTargetInfo(TypeAnnotationTarget.CLASS_IMPLEMENTS, + index); + return res; + }} break; + case CLASS_TYPE_PARAMETER_BOUND: + return parse2ByteTarget(TypeAnnotationTarget.CLASS_PARAMETER_BOUND, buf); + case METHOD_TYPE_PARAMETER_BOUND: + return parse2ByteTarget(TypeAnnotationTarget.METHOD_PARAMETER_BOUND, buf); + case FIELD: + return new TypeAnnotationTargetInfo(TypeAnnotationTarget.FIELD_TYPE); + case METHOD_RETURN: + return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RETURN_TYPE); + case METHOD_RECEIVER: + return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RECEIVER_TYPE); + case METHOD_FORMAL_PARAMETER: { + // Todo + byte index = buf.get(); + } break; + case THROWS: + return parseShortTarget(TypeAnnotationTarget.THROWS, buf); + + /* + * The ones below are inside method bodies, we don't care about them for core reflection + * other than adjusting for them in the byte stream. + */ + case LOCAL_VARIABLE: + case RESOURCE_VARIABLE: + short length = buf.getShort(); + for (int i = 0; i < length; ++i) { + short offset = buf.getShort(); + short varLength = buf.getShort(); + short index = buf.getShort(); + } + break; + case EXCEPTION_PARAMETER: { + byte index = buf.get(); + } break; + case CAST: + case INSTANCEOF: + case NEW: { + short offset = buf.getShort(); + } break; + case CONSTRUCTOR_REFERENCE_RECEIVER: + case METHOD_REFERENCE_RECEIVER: { + short offset = buf.getShort(); + byte index = buf.get(); + } break; + case LAMBDA_FORMAL_PARAMETER: { + byte index = buf.get(); + } break; + case METHOD_REFERENCE: + // This one isn't in the spec yet + break; + case METHOD_REFERENCE_TYPE_ARGUMENT: { + short offset = buf.getShort(); + byte index = buf.get(); + } break; + + default: + // will throw error below + break; + } + throw new AnnotationFormatError("Could not parse bytes for type annotations"); + } + + private static TypeAnnotationTargetInfo parseShortTarget(TypeAnnotationTarget target, ByteBuffer buf) { + short index = buf.getShort(); + return new TypeAnnotationTargetInfo(target, index); + } + private static TypeAnnotationTargetInfo parse2ByteTarget(TypeAnnotationTarget target, ByteBuffer buf) { + byte count = buf.get(); + byte secondaryIndex = buf.get(); + return new TypeAnnotationTargetInfo(target, + count, + secondaryIndex); + } +} diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java --- a/src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,13 +25,18 @@ package sun.reflect.generics.reflectiveObjects; -import java.lang.annotation.Annotation; +import java.lang.annotation.*; +import java.lang.reflect.AnnotatedType; import java.lang.reflect.Array; import java.lang.reflect.GenericDeclaration; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Objects; - +import sun.reflect.annotation.AnnotationSupport; +import sun.reflect.annotation.TypeAnnotationParser; +import sun.reflect.annotation.AnnotationType; import sun.reflect.generics.factory.GenericsFactory; import sun.reflect.generics.tree.FieldTypeSignature; import sun.reflect.generics.visitor.Reifier; @@ -182,45 +187,75 @@ return genericDeclaration.hashCode() ^ name.hashCode(); } - // Currently vacuous implementations of AnnotatedElement methods. + // Implementations of AnnotatedElement methods. public boolean isAnnotationPresent(Class annotationClass) { Objects.requireNonNull(annotationClass); return false; } + @SuppressWarnings("unchecked") public T getAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); - return null; + // T is an Annotation type, the return value of get will be an annotation + return (T)mapAnnotations(getAnnotations()).get(annotationClass); } public T getDeclaredAnnotation(Class annotationClass) { Objects.requireNonNull(annotationClass); - return null; + return getAnnotation(annotationClass); } - @SuppressWarnings("unchecked") public T[] getAnnotations(Class annotationClass) { Objects.requireNonNull(annotationClass); - // safe because annotationClass is the class for T - return (T[])Array.newInstance(annotationClass, 0); + return AnnotationSupport.getMultipleAnnotations(mapAnnotations(getAnnotations()), annotationClass); } - @SuppressWarnings("unchecked") public T[] getDeclaredAnnotations(Class annotationClass) { Objects.requireNonNull(annotationClass); - // safe because annotationClass is the class for T - return (T[])Array.newInstance(annotationClass, 0); + return getAnnotations(annotationClass); } public Annotation[] getAnnotations() { - // Since zero-length, don't need defensive clone - return EMPTY_ANNOTATION_ARRAY; + int myIndex = typeVarIndex(); + if (myIndex < 0) + throw new AssertionError("Index must be non-negative."); + return TypeAnnotationParser.parseTypeVariableAnnotations(getGenericDeclaration(), myIndex); } public Annotation[] getDeclaredAnnotations() { - // Since zero-length, don't need defensive clone - return EMPTY_ANNOTATION_ARRAY; + return getAnnotations(); + } + + public AnnotatedType[] getAnnotatedBounds() { + return TypeAnnotationParser.parseAnnotatedBounds(getBounds(), + getGenericDeclaration(), + typeVarIndex()); } private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0]; + + // Helpers for annotation methods + private int typeVarIndex() { + TypeVariable[] tVars = getGenericDeclaration().getTypeParameters(); + int i = -1; + for (TypeVariable v : tVars) { + i++; + if (equals(v)) + return i; + } + return -1; + } + + private static Map, Annotation> mapAnnotations(Annotation[] annos) { + Map, Annotation> result = + new LinkedHashMap<>(); + for (Annotation a : annos) { + Class klass = a.annotationType(); + AnnotationType type = AnnotationType.getInstance(klass); + if (type.retention() == RetentionPolicy.RUNTIME) + if (result.put(klass, a) != null) + throw new AnnotationFormatError("Duplicate annotation for class: "+klass+": " + a); + } + return result; + } } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/swing/SwingUtilities2.java --- a/src/share/classes/sun/swing/SwingUtilities2.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/swing/SwingUtilities2.java Mon Feb 04 17:29:58 2013 -0400 @@ -1879,4 +1879,12 @@ } return -1; } + + public static int getSystemMnemonicKeyMask() { + Toolkit toolkit = Toolkit.getDefaultToolkit(); + if (toolkit instanceof SunToolkit) { + return ((SunToolkit) toolkit).getFocusAcceleratorKeyMask(); + } + return InputEvent.ALT_MASK; + } } diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/swing/WindowsPlacesBar.java --- a/src/share/classes/sun/swing/WindowsPlacesBar.java Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/swing/WindowsPlacesBar.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,9 +116,6 @@ icon = fsv.getSystemIcon(files[i]); } buttons[i] = new JToggleButton(folderName, icon); - if (isXPPlatform) { - buttons[i].setText("
"+folderName+"
"); - } if (isXPStyle) { buttons[i].putClientProperty("XPStyle.subAppName", "placesbar"); } else { diff -r a8bbd962f34a -r 41654275896d src/share/classes/sun/util/resources/sq/LocaleNames_sq.properties --- a/src/share/classes/sun/util/resources/sq/LocaleNames_sq.properties Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/classes/sun/util/resources/sq/LocaleNames_sq.properties Mon Feb 04 17:29:58 2013 -0400 @@ -1,4 +1,4 @@ -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ # language names # key is ISO 639 language code -sq=shqipe +sq=shqip # country names # key is ISO 3166 country code diff -r a8bbd962f34a -r 41654275896d src/share/javavm/export/jvm.h --- a/src/share/javavm/export/jvm.h Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/javavm/export/jvm.h Mon Feb 04 17:29:58 2013 -0400 @@ -465,6 +465,12 @@ JNIEXPORT jbyteArray JNICALL JVM_GetClassAnnotations(JNIEnv *env, jclass cls); +/* Type use annotations support (JDK 1.8) */ + +JNIEXPORT jbyteArray JNICALL +JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls); + + /* * New (JDK 1.4) reflection implementation */ diff -r a8bbd962f34a -r 41654275896d src/share/native/java/lang/Class.c --- a/src/share/native/java/lang/Class.c Mon Jan 28 16:29:10 2013 -0400 +++ b/src/share/native/java/lang/Class.c Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,8 @@ {"getRawAnnotations", "()" BA, (void *)&JVM_GetClassAnnotations}, {"getConstantPool", "()" CPL, (void *)&JVM_GetClassConstantPool}, {"desiredAssertionStatus0","("CLS")Z",(void *)&JVM_DesiredAssertionStatus}, - {"getEnclosingMethod0", "()[" OBJ, (void *)&JVM_GetEnclosingMethodInfo} + {"getEnclosingMethod0", "()[" OBJ, (void *)&JVM_GetEnclosingMethodInfo}, + {"getRawTypeAnnotations", "()" BA, (void *)&JVM_GetClassTypeAnnotations}, }; #undef OBJ diff -r a8bbd962f34a -r 41654275896d src/solaris/classes/sun/awt/X11/generator/sizes.32 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/classes/sun/awt/X11/generator/sizes.32 Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,1016 @@ +long 4 +int 4 +short 2 +ptr 4 +Bool 4 +Atom 4 +Window 4 +XExtData.number 0 +XExtData.next 4 +XExtData.free_private 8 +XExtData.private_data 12 +XExtData 16 +XIMStringConversionCallbackStruct.position 0 +XIMStringConversionCallbackStruct.direction 4 +XIMStringConversionCallbackStruct.operation 8 +XIMStringConversionCallbackStruct.factor 10 +XIMStringConversionCallbackStruct.text 12 +XIMStringConversionCallbackStruct 16 +XkbNewKeyboardNotifyEvent.type 0 +XkbNewKeyboardNotifyEvent.serial 4 +XkbNewKeyboardNotifyEvent.send_event 8 +XkbNewKeyboardNotifyEvent.display 12 +XkbNewKeyboardNotifyEvent.time 16 +XkbNewKeyboardNotifyEvent.xkb_type 20 +XkbNewKeyboardNotifyEvent.device 24 +XkbNewKeyboardNotifyEvent.old_device 28 +XkbNewKeyboardNotifyEvent.min_key_code 32 +XkbNewKeyboardNotifyEvent.max_key_code 36 +XkbNewKeyboardNotifyEvent.old_min_key_code 40 +XkbNewKeyboardNotifyEvent.old_max_key_code 44 +XkbNewKeyboardNotifyEvent.changed 48 +XkbNewKeyboardNotifyEvent.req_major 52 +XkbNewKeyboardNotifyEvent.req_minor 53 +XkbNewKeyboardNotifyEvent 56 +XTimeCoord.time 0 +XTimeCoord.x 4 +XTimeCoord.y 6 +XTimeCoord 8 +XkbCompatMapNotifyEvent.type 0 +XkbCompatMapNotifyEvent.serial 4 +XkbCompatMapNotifyEvent.send_event 8 +XkbCompatMapNotifyEvent.display 12 +XkbCompatMapNotifyEvent.time 16 +XkbCompatMapNotifyEvent.xkb_type 20 +XkbCompatMapNotifyEvent.device 24 +XkbCompatMapNotifyEvent.changed_groups 28 +XkbCompatMapNotifyEvent.first_si 32 +XkbCompatMapNotifyEvent.num_si 36 +XkbCompatMapNotifyEvent.num_total_si 40 +XkbCompatMapNotifyEvent 44 +XIMStatusDrawCallbackStruct.type 0 +XIMStatusDrawCallbackStruct.data 4 +XIMStatusDrawCallbackStruct 8 +XKeyboardControl.key_click_percent 0 +XKeyboardControl.bell_percent 4 +XKeyboardControl.bell_pitch 8 +XKeyboardControl.bell_duration 12 +XKeyboardControl.led 16 +XKeyboardControl.led_mode 20 +XKeyboardControl.key 24 +XKeyboardControl.auto_repeat_mode 28 +XKeyboardControl 32 +XSelectionClearEvent.type 0 +XSelectionClearEvent.serial 4 +XSelectionClearEvent.send_event 8 +XSelectionClearEvent.display 12 +XSelectionClearEvent.window 16 +XSelectionClearEvent.selection 20 +XSelectionClearEvent.time 24 +XSelectionClearEvent 28 +XWindowChanges.x 0 +XWindowChanges.y 4 +XWindowChanges.width 8 +XWindowChanges.height 12 +XWindowChanges.border_width 16 +XWindowChanges.sibling 20 +XWindowChanges.stack_mode 24 +XWindowChanges 28 +XIMPreeditCaretCallbackStruct.position 0 +XIMPreeditCaretCallbackStruct.direction 4 +XIMPreeditCaretCallbackStruct.style 8 +XIMPreeditCaretCallbackStruct 12 +XOMCharSetList.charset_count 0 +XOMCharSetList.charset_list 4 +XOMCharSetList 8 +XOMFontInfo.num_font 0 +XOMFontInfo.font_struct_list 4 +XOMFontInfo.font_name_list 8 +XOMFontInfo 12 +AwtScreenData.numConfigs 0 +AwtScreenData.root 4 +AwtScreenData.whitepixel 8 +AwtScreenData.blackpixel 12 +AwtScreenData.defaultConfig 16 +AwtScreenData.configs 20 +AwtScreenData 24 +XIMHotKeyTrigger.keysym 0 +XIMHotKeyTrigger.modifier 4 +XIMHotKeyTrigger.modifier_mask 8 +XIMHotKeyTrigger 12 +XCirculateEvent.type 0 +XCirculateEvent.serial 4 +XCirculateEvent.send_event 8 +XCirculateEvent.display 12 +XCirculateEvent.event 16 +XCirculateEvent.window 20 +XCirculateEvent.place 24 +XCirculateEvent 28 +Screen.ext_data 0 +Screen.display 4 +Screen.root 8 +Screen.width 12 +Screen.height 16 +Screen.mwidth 20 +Screen.mheight 24 +Screen.ndepths 28 +Screen.depths 32 +Screen.root_depth 36 +Screen.root_visual 40 +Screen.default_gc 44 +Screen.cmap 48 +Screen.white_pixel 52 +Screen.black_pixel 56 +Screen.max_maps 60 +Screen.min_maps 64 +Screen.backing_store 68 +Screen.save_unders 72 +Screen.root_input_mask 76 +Screen 80 +XMapRequestEvent.type 0 +XMapRequestEvent.serial 4 +XMapRequestEvent.send_event 8 +XMapRequestEvent.display 12 +XMapRequestEvent.parent 16 +XMapRequestEvent.window 20 +XMapRequestEvent 24 +XIMText.length 0 +XIMText.feedback 4 +XIMText.encoding_is_wchar 8 +XIMText.string 12 +XIMText 16 +XGraphicsExposeEvent.type 0 +XGraphicsExposeEvent.serial 4 +XGraphicsExposeEvent.send_event 8 +XGraphicsExposeEvent.display 12 +XGraphicsExposeEvent.drawable 16 +XGraphicsExposeEvent.x 20 +XGraphicsExposeEvent.y 24 +XGraphicsExposeEvent.width 28 +XGraphicsExposeEvent.height 32 +XGraphicsExposeEvent.count 36 +XGraphicsExposeEvent.major_code 40 +XGraphicsExposeEvent.minor_code 44 +XGraphicsExposeEvent 48 +XEvent.type 0 +XEvent.xany 0 +XEvent.xkey 0 +XEvent.xbutton 0 +XEvent.xmotion 0 +XEvent.xcrossing 0 +XEvent.xfocus 0 +XEvent.xexpose 0 +XEvent.xgraphicsexpose 0 +XEvent.xnoexpose 0 +XEvent.xvisibility 0 +XEvent.xcreatewindow 0 +XEvent.xdestroywindow 0 +XEvent.xunmap 0 +XEvent.xmap 0 +XEvent.xmaprequest 0 +XEvent.xreparent 0 +XEvent.xconfigure 0 +XEvent.xgravity 0 +XEvent.xresizerequest 0 +XEvent.xconfigurerequest 0 +XEvent.xcirculate 0 +XEvent.xcirculaterequest 0 +XEvent.xproperty 0 +XEvent.xselectionclear 0 +XEvent.xselectionrequest 0 +XEvent.xselection 0 +XEvent.xcolormap 0 +XEvent.xclient 0 +XEvent.xmapping 0 +XEvent.xerror 0 +XEvent.xkeymap 0 +XEvent.pad 0 +XEvent 96 +XRenderDirectFormat.red 0 +XRenderDirectFormat.redMask 2 +XRenderDirectFormat.green 4 +XRenderDirectFormat.greenMask 6 +XRenderDirectFormat.blue 8 +XRenderDirectFormat.blueMask 10 +XRenderDirectFormat.alpha 12 +XRenderDirectFormat.alphaMask 14 +XRenderDirectFormat 16 +ColorData.awt_Colors 0 +ColorData.awt_numICMcolors 4 +ColorData.awt_icmLUT 8 +ColorData.awt_icmLUT2Colors 12 +ColorData.img_grays 16 +ColorData.img_clr_tbl 20 +ColorData.img_oda_red 24 +ColorData.img_oda_green 28 +ColorData.img_oda_blue 32 +ColorData.pGrayInverseLutData 36 +ColorData.screendata 40 +ColorData 44 +XFontStruct.ext_data 0 +XFontStruct.fid 4 +XFontStruct.direction 8 +XFontStruct.min_char_or_byte2 12 +XFontStruct.max_char_or_byte2 16 +XFontStruct.min_byte1 20 +XFontStruct.max_byte1 24 +XFontStruct.all_chars_exist 28 +XFontStruct.n_properties 36 +XFontStruct.properties 40 +XFontStruct.min_bounds 44 +XFontStruct.max_bounds 56 +XFontStruct.per_char 68 +XFontStruct.ascent 72 +XFontStruct.descent 76 +XFontStruct 80 +XExtCodes.extension 0 +XExtCodes.major_opcode 4 +XExtCodes.first_event 8 +XExtCodes.first_error 12 +XExtCodes 16 +XFontSetExtents.max_ink_extent 0 +XFontSetExtents.max_logical_extent 8 +XFontSetExtents 16 +XSelectionEvent.type 0 +XSelectionEvent.serial 4 +XSelectionEvent.send_event 8 +XSelectionEvent.display 12 +XSelectionEvent.requestor 16 +XSelectionEvent.selection 20 +XSelectionEvent.target 24 +XSelectionEvent.property 28 +XSelectionEvent.time 32 +XSelectionEvent 36 +XArc.x 0 +XArc.y 2 +XArc.width 4 +XArc.height 6 +XArc.angle1 8 +XArc.angle2 10 +XArc 12 +XErrorEvent.type 0 +XErrorEvent.display 4 +XErrorEvent.resourceid 8 +XErrorEvent.serial 12 +XErrorEvent.error_code 16 +XErrorEvent.request_code 17 +XErrorEvent.minor_code 18 +XErrorEvent 20 +XConfigureRequestEvent.type 0 +XConfigureRequestEvent.serial 4 +XConfigureRequestEvent.send_event 8 +XConfigureRequestEvent.display 12 +XConfigureRequestEvent.parent 16 +XConfigureRequestEvent.window 20 +XConfigureRequestEvent.x 24 +XConfigureRequestEvent.y 28 +XConfigureRequestEvent.width 32 +XConfigureRequestEvent.height 36 +XConfigureRequestEvent.border_width 40 +XConfigureRequestEvent.above 44 +XConfigureRequestEvent.detail 48 +XConfigureRequestEvent.value_mask 52 +XConfigureRequestEvent 56 +ScreenFormat.ext_data 0 +ScreenFormat.depth 4 +ScreenFormat.bits_per_pixel 8 +ScreenFormat.scanline_pad 12 +ScreenFormat 16 +XButtonEvent.type 0 +XButtonEvent.serial 4 +XButtonEvent.send_event 8 +XButtonEvent.display 12 +XButtonEvent.window 16 +XButtonEvent.root 20 +XButtonEvent.subwindow 24 +XButtonEvent.time 28 +XButtonEvent.x 32 +XButtonEvent.y 36 +XButtonEvent.x_root 40 +XButtonEvent.y_root 44 +XButtonEvent.state 48 +XButtonEvent.button 52 +XButtonEvent.same_screen 56 +XButtonEvent 60 +XFontProp.name 0 +XFontProp.card32 4 +XFontProp 8 +XIMValuesList.count_values 0 +XIMValuesList.supported_values 4 +XIMValuesList 8 +XKeymapEvent.type 0 +XKeymapEvent.serial 4 +XKeymapEvent.send_event 8 +XKeymapEvent.display 12 +XKeymapEvent.window 16 +XKeymapEvent.key_vector 20 +XKeymapEvent 52 +XTextItem16.chars 0 +XTextItem16.nchars 4 +XTextItem16.delta 8 +XTextItem16.font 12 +XTextItem16 16 +XIMPreeditDrawCallbackStruct.caret 0 +XIMPreeditDrawCallbackStruct.chg_first 4 +XIMPreeditDrawCallbackStruct.chg_length 8 +XIMPreeditDrawCallbackStruct.text 12 +XIMPreeditDrawCallbackStruct 16 +XVisualInfo.visual 0 +XVisualInfo.visualid 4 +XVisualInfo.screen 8 +XVisualInfo.depth 12 +XVisualInfo.class 16 +XVisualInfo.red_mask 20 +XVisualInfo.green_mask 24 +XVisualInfo.blue_mask 28 +XVisualInfo.colormap_size 32 +XVisualInfo.bits_per_rgb 36 +XVisualInfo 40 +XkbControlsNotifyEvent.type 0 +XkbControlsNotifyEvent.serial 4 +XkbControlsNotifyEvent.send_event 8 +XkbControlsNotifyEvent.display 12 +XkbControlsNotifyEvent.time 16 +XkbControlsNotifyEvent.xkb_type 20 +XkbControlsNotifyEvent.device 24 +XkbControlsNotifyEvent.changed_ctrls 28 +XkbControlsNotifyEvent.enabled_ctrls 32 +XkbControlsNotifyEvent.enabled_ctrl_changes 36 +XkbControlsNotifyEvent.num_groups 40 +XkbControlsNotifyEvent.keycode 44 +XkbControlsNotifyEvent.event_type 45 +XkbControlsNotifyEvent.req_major 46 +XkbControlsNotifyEvent.req_minor 47 +XkbControlsNotifyEvent 48 +PropMwmHints.flags 0 +PropMwmHints.functions 4 +PropMwmHints.decorations 8 +PropMwmHints.inputMode 12 +PropMwmHints.status 16 +PropMwmHints 20 +XClientMessageEvent.type 0 +XClientMessageEvent.serial 4 +XClientMessageEvent.send_event 8 +XClientMessageEvent.display 12 +XClientMessageEvent.window 16 +XClientMessageEvent.message_type 20 +XClientMessageEvent.format 24 +XClientMessageEvent.data 28 +XClientMessageEvent 48 +XAnyEvent.type 0 +XAnyEvent.serial 4 +XAnyEvent.send_event 8 +XAnyEvent.display 12 +XAnyEvent.window 16 +XAnyEvent 20 +XkbIndicatorNotifyEvent.type 0 +XkbIndicatorNotifyEvent.serial 4 +XkbIndicatorNotifyEvent.send_event 8 +XkbIndicatorNotifyEvent.display 12 +XkbIndicatorNotifyEvent.time 16 +XkbIndicatorNotifyEvent.xkb_type 20 +XkbIndicatorNotifyEvent.device 24 +XkbIndicatorNotifyEvent.changed 28 +XkbIndicatorNotifyEvent.state 32 +XkbIndicatorNotifyEvent 36 +XIMPreeditStateNotifyCallbackStruct.state 0 +XIMPreeditStateNotifyCallbackStruct 4 +XkbAnyEvent.type 0 +XkbAnyEvent.serial 4 +XkbAnyEvent.send_event 8 +XkbAnyEvent.display 12 +XkbAnyEvent.time 16 +XkbAnyEvent.xkb_type 20 +XkbAnyEvent.device 24 +XkbAnyEvent 28 +XMotionEvent.type 0 +XMotionEvent.serial 4 +XMotionEvent.send_event 8 +XMotionEvent.display 12 +XMotionEvent.window 16 +XMotionEvent.root 20 +XMotionEvent.subwindow 24 +XMotionEvent.time 28 +XMotionEvent.x 32 +XMotionEvent.y 36 +XMotionEvent.x_root 40 +XMotionEvent.y_root 44 +XMotionEvent.state 48 +XMotionEvent.is_hint 52 +XMotionEvent.same_screen 56 +XMotionEvent 60 +XIMHotKeyTriggers.num_hot_key 0 +XIMHotKeyTriggers.key 4 +XIMHotKeyTriggers 8 +XIMStyles.count_styles 0 +XIMStyles.supported_styles 4 +XIMStyles 8 +XkbExtensionDeviceNotifyEvent.type 0 +XkbExtensionDeviceNotifyEvent.serial 4 +XkbExtensionDeviceNotifyEvent.send_event 8 +XkbExtensionDeviceNotifyEvent.display 12 +XkbExtensionDeviceNotifyEvent.time 16 +XkbExtensionDeviceNotifyEvent.xkb_type 20 +XkbExtensionDeviceNotifyEvent.device 24 +XkbExtensionDeviceNotifyEvent.reason 28 +XkbExtensionDeviceNotifyEvent.supported 32 +XkbExtensionDeviceNotifyEvent.unsupported 36 +XkbExtensionDeviceNotifyEvent.first_btn 40 +XkbExtensionDeviceNotifyEvent.num_btns 44 +XkbExtensionDeviceNotifyEvent.leds_defined 48 +XkbExtensionDeviceNotifyEvent.led_state 52 +XkbExtensionDeviceNotifyEvent.led_class 56 +XkbExtensionDeviceNotifyEvent.led_id 60 +XkbExtensionDeviceNotifyEvent 64 +XwcTextItem.chars 0 +XwcTextItem.nchars 4 +XwcTextItem.delta 8 +XwcTextItem.font_set 12 +XwcTextItem 16 +XClassHint.res_name 0 +XClassHint.res_class 4 +XClassHint 8 +XChar2b.byte1 0 +XChar2b.byte2 1 +XChar2b 2 +XSetWindowAttributes.background_pixmap 0 +XSetWindowAttributes.background_pixel 4 +XSetWindowAttributes.border_pixmap 8 +XSetWindowAttributes.border_pixel 12 +XSetWindowAttributes.bit_gravity 16 +XSetWindowAttributes.win_gravity 20 +XSetWindowAttributes.backing_store 24 +XSetWindowAttributes.backing_planes 28 +XSetWindowAttributes.backing_pixel 32 +XSetWindowAttributes.save_under 36 +XSetWindowAttributes.event_mask 40 +XSetWindowAttributes.do_not_propagate_mask 44 +XSetWindowAttributes.override_redirect 48 +XSetWindowAttributes.colormap 52 +XSetWindowAttributes.cursor 56 +XSetWindowAttributes 60 +XRenderPictFormat.id 0 +XRenderPictFormat.type 4 +XRenderPictFormat.depth 8 +XRenderPictFormat.direct 12 +XRenderPictFormat.colormap 28 +XRenderPictFormat 32 +XReparentEvent.type 0 +XReparentEvent.serial 4 +XReparentEvent.send_event 8 +XReparentEvent.display 12 +XReparentEvent.event 16 +XReparentEvent.window 20 +XReparentEvent.parent 24 +XReparentEvent.x 28 +XReparentEvent.y 32 +XReparentEvent.override_redirect 36 +XReparentEvent 40 +XCirculateRequestEvent.type 0 +XCirculateRequestEvent.serial 4 +XCirculateRequestEvent.send_event 8 +XCirculateRequestEvent.display 12 +XCirculateRequestEvent.parent 16 +XCirculateRequestEvent.window 20 +XCirculateRequestEvent.place 24 +XCirculateRequestEvent 28 +XImage.width 0 +XImage.height 4 +XImage.xoffset 8 +XImage.format 12 +XImage.data 16 +XImage.byte_order 20 +XImage.bitmap_unit 24 +XImage.bitmap_bit_order 28 +XImage.bitmap_pad 32 +XImage.depth 36 +XImage.bytes_per_line 40 +XImage.bits_per_pixel 44 +XImage.red_mask 48 +XImage.green_mask 52 +XImage.blue_mask 56 +XImage.obdata 60 +XImage.f.create_image 64 +XImage.f.destroy_image 68 +XImage.f.get_pixel 72 +XImage.f.put_pixel 76 +XImage.f.sub_image 80 +XImage.f.add_pixel 84 +XImage 88 +XKeyEvent.type 0 +XKeyEvent.serial 4 +XKeyEvent.send_event 8 +XKeyEvent.display 12 +XKeyEvent.window 16 +XKeyEvent.root 20 +XKeyEvent.subwindow 24 +XKeyEvent.time 28 +XKeyEvent.x 32 +XKeyEvent.y 36 +XKeyEvent.x_root 40 +XKeyEvent.y_root 44 +XKeyEvent.state 48 +XKeyEvent.keycode 52 +XKeyEvent.same_screen 56 +XKeyEvent 60 +XkbActionMessageEvent.type 0 +XkbActionMessageEvent.serial 4 +XkbActionMessageEvent.send_event 8 +XkbActionMessageEvent.display 12 +XkbActionMessageEvent.time 16 +XkbActionMessageEvent.xkb_type 20 +XkbActionMessageEvent.device 24 +XkbActionMessageEvent.keycode 28 +XkbActionMessageEvent.press 32 +XkbActionMessageEvent.key_event_follows 36 +XkbActionMessageEvent.group 40 +XkbActionMessageEvent.mods 44 +XkbActionMessageEvent.message 48 +XkbActionMessageEvent 56 +XdbeSwapInfo.swap_window 0 +XdbeSwapInfo.swap_action 4 +XdbeSwapInfo 8 +XTextItem.chars 0 +XTextItem.nchars 4 +XTextItem.delta 8 +XTextItem.font 12 +XTextItem 16 +XModifierKeymap.max_keypermod 0 +XModifierKeymap.modifiermap 4 +XModifierKeymap 8 +XCharStruct.lbearing 0 +XCharStruct.rbearing 2 +XCharStruct.width 4 +XCharStruct.ascent 6 +XCharStruct.descent 8 +XCharStruct.attributes 10 +XCharStruct 12 +XGravityEvent.type 0 +XGravityEvent.serial 4 +XGravityEvent.send_event 8 +XGravityEvent.display 12 +XGravityEvent.event 16 +XGravityEvent.window 20 +XGravityEvent.x 24 +XGravityEvent.y 28 +XGravityEvent 32 +Visual.ext_data 0 +Visual.visualid 4 +Visual.class 8 +Visual.red_mask 12 +Visual.green_mask 16 +Visual.blue_mask 20 +Visual.bits_per_rgb 24 +Visual.map_entries 28 +Visual 32 +XOMOrientation.num_orientation 0 +XOMOrientation.orientation 4 +XOMOrientation 8 +XkbAccessXNotifyEvent.type 0 +XkbAccessXNotifyEvent.serial 4 +XkbAccessXNotifyEvent.send_event 8 +XkbAccessXNotifyEvent.display 12 +XkbAccessXNotifyEvent.time 16 +XkbAccessXNotifyEvent.xkb_type 20 +XkbAccessXNotifyEvent.device 24 +XkbAccessXNotifyEvent.detail 28 +XkbAccessXNotifyEvent.keycode 32 +XkbAccessXNotifyEvent.sk_delay 36 +XkbAccessXNotifyEvent.debounce_delay 40 +XkbAccessXNotifyEvent 44 +XWindowAttributes.x 0 +XWindowAttributes.y 4 +XWindowAttributes.width 8 +XWindowAttributes.height 12 +XWindowAttributes.border_width 16 +XWindowAttributes.depth 20 +XWindowAttributes.visual 24 +XWindowAttributes.root 28 +XWindowAttributes.class 32 +XWindowAttributes.bit_gravity 36 +XWindowAttributes.win_gravity 40 +XWindowAttributes.backing_store 44 +XWindowAttributes.backing_planes 48 +XWindowAttributes.backing_pixel 52 +XWindowAttributes.save_under 56 +XWindowAttributes.colormap 60 +XWindowAttributes.map_installed 64 +XWindowAttributes.map_state 68 +XWindowAttributes.all_event_masks 72 +XWindowAttributes.your_event_mask 76 +XWindowAttributes.do_not_propagate_mask 80 +XWindowAttributes.override_redirect 84 +XWindowAttributes.screen 88 +XWindowAttributes 92 +XmbTextItem.chars 0 +XmbTextItem.nchars 4 +XmbTextItem.delta 8 +XmbTextItem.font_set 12 +XmbTextItem 16 +XMappingEvent.type 0 +XMappingEvent.serial 4 +XMappingEvent.send_event 8 +XMappingEvent.display 12 +XMappingEvent.window 16 +XMappingEvent.request 20 +XMappingEvent.first_keycode 24 +XMappingEvent.count 28 +XMappingEvent 32 +XSizeHints.flags 0 +XSizeHints.x 4 +XSizeHints.y 8 +XSizeHints.width 12 +XSizeHints.height 16 +XSizeHints.min_width 20 +XSizeHints.min_height 24 +XSizeHints.max_width 28 +XSizeHints.max_height 32 +XSizeHints.width_inc 36 +XSizeHints.height_inc 40 +XSizeHints.min_aspect.x 44 +XSizeHints.min_aspect.y 48 +XSizeHints.max_aspect.x 52 +XSizeHints.max_aspect.y 56 +XSizeHints.base_width 60 +XSizeHints.base_height 64 +XSizeHints.win_gravity 68 +XSizeHints 72 +XUnmapEvent.type 0 +XUnmapEvent.serial 4 +XUnmapEvent.send_event 8 +XUnmapEvent.display 12 +XUnmapEvent.event 16 +XUnmapEvent.window 20 +XUnmapEvent.from_configure 24 +XUnmapEvent 28 +awtImageData.Depth 0 +awtImageData.wsImageFormat 4 +awtImageData.clrdata 16 +awtImageData.convert 48 +awtImageData 304 +XkbStateNotifyEvent.type 0 +XkbStateNotifyEvent.serial 4 +XkbStateNotifyEvent.send_event 8 +XkbStateNotifyEvent.display 12 +XkbStateNotifyEvent.time 16 +XkbStateNotifyEvent.xkb_type 20 +XkbStateNotifyEvent.device 24 +XkbStateNotifyEvent.changed 28 +XkbStateNotifyEvent.group 32 +XkbStateNotifyEvent.base_group 36 +XkbStateNotifyEvent.latched_group 40 +XkbStateNotifyEvent.locked_group 44 +XkbStateNotifyEvent.mods 48 +XkbStateNotifyEvent.base_mods 52 +XkbStateNotifyEvent.latched_mods 56 +XkbStateNotifyEvent.locked_mods 60 +XkbStateNotifyEvent.compat_state 64 +XkbStateNotifyEvent.grab_mods 68 +XkbStateNotifyEvent.compat_grab_mods 69 +XkbStateNotifyEvent.lookup_mods 70 +XkbStateNotifyEvent.compat_lookup_mods 71 +XkbStateNotifyEvent.ptr_buttons 72 +XkbStateNotifyEvent.keycode 76 +XkbStateNotifyEvent.event_type 77 +XkbStateNotifyEvent.req_major 78 +XkbStateNotifyEvent.req_minor 79 +XkbStateNotifyEvent 80 +XExposeEvent.type 0 +XExposeEvent.serial 4 +XExposeEvent.send_event 8 +XExposeEvent.display 12 +XExposeEvent.window 16 +XExposeEvent.x 20 +XExposeEvent.y 24 +XExposeEvent.width 28 +XExposeEvent.height 32 +XExposeEvent.count 36 +XExposeEvent 40 +XkbMapNotifyEvent.type 0 +XkbMapNotifyEvent.serial 4 +XkbMapNotifyEvent.send_event 8 +XkbMapNotifyEvent.display 12 +XkbMapNotifyEvent.time 16 +XkbMapNotifyEvent.xkb_type 20 +XkbMapNotifyEvent.device 24 +XkbMapNotifyEvent.changed 28 +XkbMapNotifyEvent.flags 32 +XkbMapNotifyEvent.first_type 36 +XkbMapNotifyEvent.num_types 40 +XkbMapNotifyEvent.min_key_code 44 +XkbMapNotifyEvent.max_key_code 45 +XkbMapNotifyEvent.first_key_sym 46 +XkbMapNotifyEvent.first_key_act 47 +XkbMapNotifyEvent.first_key_behavior 48 +XkbMapNotifyEvent.first_key_explicit 49 +XkbMapNotifyEvent.first_modmap_key 50 +XkbMapNotifyEvent.first_vmodmap_key 51 +XkbMapNotifyEvent.num_key_syms 52 +XkbMapNotifyEvent.num_key_acts 56 +XkbMapNotifyEvent.num_key_behaviors 60 +XkbMapNotifyEvent.num_key_explicit 64 +XkbMapNotifyEvent.num_modmap_keys 68 +XkbMapNotifyEvent.num_vmodmap_keys 72 +XkbMapNotifyEvent.vmods 76 +XkbMapNotifyEvent 80 +XGCValues.function 0 +XGCValues.plane_mask 4 +XGCValues.foreground 8 +XGCValues.background 12 +XGCValues.line_width 16 +XGCValues.line_style 20 +XGCValues.cap_style 24 +XGCValues.join_style 28 +XGCValues.fill_style 32 +XGCValues.fill_rule 36 +XGCValues.arc_mode 40 +XGCValues.tile 44 +XGCValues.stipple 48 +XGCValues.ts_x_origin 52 +XGCValues.ts_y_origin 56 +XGCValues.font 60 +XGCValues.subwindow_mode 64 +XGCValues.graphics_exposures 68 +XGCValues.clip_x_origin 72 +XGCValues.clip_y_origin 76 +XGCValues.clip_mask 80 +XGCValues.dash_offset 84 +XGCValues.dashes 88 +XGCValues 92 +XFocusChangeEvent.type 0 +XFocusChangeEvent.serial 4 +XFocusChangeEvent.send_event 8 +XFocusChangeEvent.display 12 +XFocusChangeEvent.window 16 +XFocusChangeEvent.mode 20 +XFocusChangeEvent.detail 24 +XFocusChangeEvent 28 +XPixmapFormatValues.depth 0 +XPixmapFormatValues.bits_per_pixel 4 +XPixmapFormatValues.scanline_pad 8 +XPixmapFormatValues 12 +XMapEvent.type 0 +XMapEvent.serial 4 +XMapEvent.send_event 8 +XMapEvent.display 12 +XMapEvent.event 16 +XMapEvent.window 20 +XMapEvent.override_redirect 24 +XMapEvent 28 +XkbBellNotifyEvent.type 0 +XkbBellNotifyEvent.serial 4 +XkbBellNotifyEvent.send_event 8 +XkbBellNotifyEvent.display 12 +XkbBellNotifyEvent.time 16 +XkbBellNotifyEvent.xkb_type 20 +XkbBellNotifyEvent.device 24 +XkbBellNotifyEvent.percent 28 +XkbBellNotifyEvent.pitch 32 +XkbBellNotifyEvent.duration 36 +XkbBellNotifyEvent.bell_class 40 +XkbBellNotifyEvent.bell_id 44 +XkbBellNotifyEvent.name 48 +XkbBellNotifyEvent.window 52 +XkbBellNotifyEvent.event_only 56 +XkbBellNotifyEvent 60 +XIMStringConversionText.length 0 +XIMStringConversionText.feedback 4 +XIMStringConversionText.encoding_is_wchar 8 +XIMStringConversionText.string 12 +XIMStringConversionText 16 +XKeyboardState.key_click_percent 0 +XKeyboardState.bell_percent 4 +XKeyboardState.bell_pitch 8 +XKeyboardState.bell_duration 12 +XKeyboardState.led_mask 16 +XKeyboardState.global_auto_repeat 20 +XKeyboardState.auto_repeats 24 +XKeyboardState 56 +XkbEvent.type 0 +XkbEvent.any 0 +XkbEvent.new_kbd 0 +XkbEvent.map 0 +XkbEvent.state 0 +XkbEvent.ctrls 0 +XkbEvent.indicators 0 +XkbEvent.names 0 +XkbEvent.compat 0 +XkbEvent.bell 0 +XkbEvent.message 0 +XkbEvent.accessx 0 +XkbEvent.device 0 +XkbEvent.core 0 +XkbEvent 96 +XPoint.x 0 +XPoint.y 2 +XPoint 4 +XSegment.x1 0 +XSegment.y1 2 +XSegment.x2 4 +XSegment.y2 6 +XSegment 8 +XIconSize.min_width 0 +XIconSize.min_height 4 +XIconSize.max_width 8 +XIconSize.max_height 12 +XIconSize.width_inc 16 +XIconSize.height_inc 20 +XIconSize 24 +XIMCallback.client_data 0 +XIMCallback.callback 4 +XIMCallback 8 +XConfigureEvent.type 0 +XConfigureEvent.serial 4 +XConfigureEvent.send_event 8 +XConfigureEvent.display 12 +XConfigureEvent.event 16 +XConfigureEvent.window 20 +XConfigureEvent.x 24 +XConfigureEvent.y 28 +XConfigureEvent.width 32 +XConfigureEvent.height 36 +XConfigureEvent.border_width 40 +XConfigureEvent.above 44 +XConfigureEvent.override_redirect 48 +XConfigureEvent 52 +XRectangle.x 0 +XRectangle.y 2 +XRectangle.width 4 +XRectangle.height 6 +XRectangle 8 +XkbNamesNotifyEvent.type 0 +XkbNamesNotifyEvent.serial 4 +XkbNamesNotifyEvent.send_event 8 +XkbNamesNotifyEvent.display 12 +XkbNamesNotifyEvent.time 16 +XkbNamesNotifyEvent.xkb_type 20 +XkbNamesNotifyEvent.device 24 +XkbNamesNotifyEvent.changed 28 +XkbNamesNotifyEvent.first_type 32 +XkbNamesNotifyEvent.num_types 36 +XkbNamesNotifyEvent.first_lvl 40 +XkbNamesNotifyEvent.num_lvls 44 +XkbNamesNotifyEvent.num_aliases 48 +XkbNamesNotifyEvent.num_radio_groups 52 +XkbNamesNotifyEvent.changed_vmods 56 +XkbNamesNotifyEvent.changed_groups 60 +XkbNamesNotifyEvent.changed_indicators 64 +XkbNamesNotifyEvent.first_key 68 +XkbNamesNotifyEvent.num_keys 72 +XkbNamesNotifyEvent 76 +XCreateWindowEvent.type 0 +XCreateWindowEvent.serial 4 +XCreateWindowEvent.send_event 8 +XCreateWindowEvent.display 12 +XCreateWindowEvent.parent 16 +XCreateWindowEvent.window 20 +XCreateWindowEvent.x 24 +XCreateWindowEvent.y 28 +XCreateWindowEvent.width 32 +XCreateWindowEvent.height 36 +XCreateWindowEvent.border_width 40 +XCreateWindowEvent.override_redirect 44 +XCreateWindowEvent 48 +XVisibilityEvent.type 0 +XVisibilityEvent.serial 4 +XVisibilityEvent.send_event 8 +XVisibilityEvent.display 12 +XVisibilityEvent.window 16 +XVisibilityEvent.state 20 +XVisibilityEvent 24 +XWMHints.flags 0 +XWMHints.initial_state 8 +XWMHints.icon_pixmap 12 +XWMHints.icon_window 16 +XWMHints.icon_x 20 +XWMHints.icon_y 24 +XWMHints.icon_mask 28 +XWMHints.input 4 +XWMHints.window_group 32 +XWMHints 36 +XCrossingEvent.type 0 +XCrossingEvent.serial 4 +XCrossingEvent.send_event 8 +XCrossingEvent.display 12 +XCrossingEvent.window 16 +XCrossingEvent.root 20 +XCrossingEvent.subwindow 24 +XCrossingEvent.time 28 +XCrossingEvent.x 32 +XCrossingEvent.y 36 +XCrossingEvent.x_root 40 +XCrossingEvent.y_root 44 +XCrossingEvent.mode 48 +XCrossingEvent.detail 52 +XCrossingEvent.same_screen 56 +XCrossingEvent.focus 60 +XCrossingEvent.state 64 +XCrossingEvent 68 +XSelectionRequestEvent.type 0 +XSelectionRequestEvent.serial 4 +XSelectionRequestEvent.send_event 8 +XSelectionRequestEvent.display 12 +XSelectionRequestEvent.owner 16 +XSelectionRequestEvent.requestor 20 +XSelectionRequestEvent.selection 24 +XSelectionRequestEvent.target 28 +XSelectionRequestEvent.property 32 +XSelectionRequestEvent.time 36 +XSelectionRequestEvent 40 +XNoExposeEvent.type 0 +XNoExposeEvent.serial 4 +XNoExposeEvent.send_event 8 +XNoExposeEvent.display 12 +XNoExposeEvent.drawable 16 +XNoExposeEvent.major_code 20 +XNoExposeEvent.minor_code 24 +XNoExposeEvent 28 +XHostAddress.family 0 +XHostAddress.length 4 +XHostAddress.address 8 +XHostAddress 12 +XColormapEvent.type 0 +XColormapEvent.serial 4 +XColormapEvent.send_event 8 +XColormapEvent.display 12 +XColormapEvent.window 16 +XColormapEvent.colormap 20 +XColormapEvent.new 24 +XColormapEvent.state 28 +XColormapEvent 32 +ColorEntry.r 0 +ColorEntry.g 1 +ColorEntry.b 2 +ColorEntry.flags 3 +ColorEntry 4 +XResizeRequestEvent.type 0 +XResizeRequestEvent.serial 4 +XResizeRequestEvent.send_event 8 +XResizeRequestEvent.display 12 +XResizeRequestEvent.window 16 +XResizeRequestEvent.width 20 +XResizeRequestEvent.height 24 +XResizeRequestEvent 28 +Depth.depth 0 +Depth.nvisuals 4 +Depth.visuals 8 +Depth 12 +XPropertyEvent.type 0 +XPropertyEvent.serial 4 +XPropertyEvent.send_event 8 +XPropertyEvent.display 12 +XPropertyEvent.window 16 +XPropertyEvent.atom 20 +XPropertyEvent.time 24 +XPropertyEvent.state 28 +XPropertyEvent 32 +XDestroyWindowEvent.type 0 +XDestroyWindowEvent.serial 4 +XDestroyWindowEvent.send_event 8 +XDestroyWindowEvent.display 12 +XDestroyWindowEvent.event 16 +XDestroyWindowEvent.window 20 +XDestroyWindowEvent 24 +XStandardColormap.colormap 0 +XStandardColormap.red_max 4 +XStandardColormap.red_mult 8 +XStandardColormap.green_max 12 +XStandardColormap.green_mult 16 +XStandardColormap.blue_max 20 +XStandardColormap.blue_mult 24 +XStandardColormap.base_pixel 28 +XStandardColormap.visualid 32 +XStandardColormap.killid 36 +XStandardColormap 40 +XComposeStatus.compose_ptr 0 +XComposeStatus.chars_matched 4 +XComposeStatus 8 +AwtGraphicsConfigData.awt_depth 0 +AwtGraphicsConfigData.awt_cmap 4 +AwtGraphicsConfigData.awt_visInfo 8 +AwtGraphicsConfigData.awt_num_colors 48 +AwtGraphicsConfigData.awtImage 52 +AwtGraphicsConfigData.AwtColorMatch 56 +AwtGraphicsConfigData.monoImage 60 +AwtGraphicsConfigData.monoPixmap 64 +AwtGraphicsConfigData.monoPixmapWidth 68 +AwtGraphicsConfigData.monoPixmapHeight 72 +AwtGraphicsConfigData.monoPixmapGC 76 +AwtGraphicsConfigData.pixelStride 80 +AwtGraphicsConfigData.color_data 84 +AwtGraphicsConfigData.glxInfo 88 +AwtGraphicsConfigData.isTranslucencySupported 92 +AwtGraphicsConfigData.renderPictFormat 96 +AwtGraphicsConfigData 128 +XColor.pixel 0 +XColor.red 4 +XColor.green 6 +XColor.blue 8 +XColor.flags 10 +XColor.pad 11 +XColor 12 +XTextProperty.value 0 +XTextProperty.encoding 4 +XTextProperty.format 8 +XTextProperty.nitems 12 +XTextProperty 16 diff -r a8bbd962f34a -r 41654275896d src/solaris/classes/sun/awt/X11/generator/sizes.64 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/classes/sun/awt/X11/generator/sizes.64 Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,1016 @@ +long 8 +int 4 +short 2 +ptr 8 +Bool 4 +Atom 8 +Window 8 +XExtData.number 0 +XExtData.next 8 +XExtData.free_private 16 +XExtData.private_data 24 +XExtData 32 +XIMStringConversionCallbackStruct.position 0 +XIMStringConversionCallbackStruct.direction 4 +XIMStringConversionCallbackStruct.operation 8 +XIMStringConversionCallbackStruct.factor 10 +XIMStringConversionCallbackStruct.text 16 +XIMStringConversionCallbackStruct 24 +XkbNewKeyboardNotifyEvent.type 0 +XkbNewKeyboardNotifyEvent.serial 8 +XkbNewKeyboardNotifyEvent.send_event 16 +XkbNewKeyboardNotifyEvent.display 24 +XkbNewKeyboardNotifyEvent.time 32 +XkbNewKeyboardNotifyEvent.xkb_type 40 +XkbNewKeyboardNotifyEvent.device 44 +XkbNewKeyboardNotifyEvent.old_device 48 +XkbNewKeyboardNotifyEvent.min_key_code 52 +XkbNewKeyboardNotifyEvent.max_key_code 56 +XkbNewKeyboardNotifyEvent.old_min_key_code 60 +XkbNewKeyboardNotifyEvent.old_max_key_code 64 +XkbNewKeyboardNotifyEvent.changed 68 +XkbNewKeyboardNotifyEvent.req_major 72 +XkbNewKeyboardNotifyEvent.req_minor 73 +XkbNewKeyboardNotifyEvent 80 +XTimeCoord.time 0 +XTimeCoord.x 8 +XTimeCoord.y 10 +XTimeCoord 16 +XkbCompatMapNotifyEvent.type 0 +XkbCompatMapNotifyEvent.serial 8 +XkbCompatMapNotifyEvent.send_event 16 +XkbCompatMapNotifyEvent.display 24 +XkbCompatMapNotifyEvent.time 32 +XkbCompatMapNotifyEvent.xkb_type 40 +XkbCompatMapNotifyEvent.device 44 +XkbCompatMapNotifyEvent.changed_groups 48 +XkbCompatMapNotifyEvent.first_si 52 +XkbCompatMapNotifyEvent.num_si 56 +XkbCompatMapNotifyEvent.num_total_si 60 +XkbCompatMapNotifyEvent 64 +XIMStatusDrawCallbackStruct.type 0 +XIMStatusDrawCallbackStruct.data 8 +XIMStatusDrawCallbackStruct 16 +XKeyboardControl.key_click_percent 0 +XKeyboardControl.bell_percent 4 +XKeyboardControl.bell_pitch 8 +XKeyboardControl.bell_duration 12 +XKeyboardControl.led 16 +XKeyboardControl.led_mode 20 +XKeyboardControl.key 24 +XKeyboardControl.auto_repeat_mode 28 +XKeyboardControl 32 +XSelectionClearEvent.type 0 +XSelectionClearEvent.serial 8 +XSelectionClearEvent.send_event 16 +XSelectionClearEvent.display 24 +XSelectionClearEvent.window 32 +XSelectionClearEvent.selection 40 +XSelectionClearEvent.time 48 +XSelectionClearEvent 56 +XWindowChanges.x 0 +XWindowChanges.y 4 +XWindowChanges.width 8 +XWindowChanges.height 12 +XWindowChanges.border_width 16 +XWindowChanges.sibling 24 +XWindowChanges.stack_mode 32 +XWindowChanges 40 +XIMPreeditCaretCallbackStruct.position 0 +XIMPreeditCaretCallbackStruct.direction 4 +XIMPreeditCaretCallbackStruct.style 8 +XIMPreeditCaretCallbackStruct 12 +XOMCharSetList.charset_count 0 +XOMCharSetList.charset_list 8 +XOMCharSetList 16 +XOMFontInfo.num_font 0 +XOMFontInfo.font_struct_list 8 +XOMFontInfo.font_name_list 16 +XOMFontInfo 24 +AwtScreenData.numConfigs 0 +AwtScreenData.root 8 +AwtScreenData.whitepixel 16 +AwtScreenData.blackpixel 24 +AwtScreenData.defaultConfig 32 +AwtScreenData.configs 40 +AwtScreenData 48 +XIMHotKeyTrigger.keysym 0 +XIMHotKeyTrigger.modifier 8 +XIMHotKeyTrigger.modifier_mask 12 +XIMHotKeyTrigger 16 +XCirculateEvent.type 0 +XCirculateEvent.serial 8 +XCirculateEvent.send_event 16 +XCirculateEvent.display 24 +XCirculateEvent.event 32 +XCirculateEvent.window 40 +XCirculateEvent.place 48 +XCirculateEvent 56 +Screen.ext_data 0 +Screen.display 8 +Screen.root 16 +Screen.width 24 +Screen.height 28 +Screen.mwidth 32 +Screen.mheight 36 +Screen.ndepths 40 +Screen.depths 48 +Screen.root_depth 56 +Screen.root_visual 64 +Screen.default_gc 72 +Screen.cmap 80 +Screen.white_pixel 88 +Screen.black_pixel 96 +Screen.max_maps 104 +Screen.min_maps 108 +Screen.backing_store 112 +Screen.save_unders 116 +Screen.root_input_mask 120 +Screen 128 +XMapRequestEvent.type 0 +XMapRequestEvent.serial 8 +XMapRequestEvent.send_event 16 +XMapRequestEvent.display 24 +XMapRequestEvent.parent 32 +XMapRequestEvent.window 40 +XMapRequestEvent 48 +XIMText.length 0 +XIMText.feedback 8 +XIMText.encoding_is_wchar 16 +XIMText.string 24 +XIMText 32 +XGraphicsExposeEvent.type 0 +XGraphicsExposeEvent.serial 8 +XGraphicsExposeEvent.send_event 16 +XGraphicsExposeEvent.display 24 +XGraphicsExposeEvent.drawable 32 +XGraphicsExposeEvent.x 40 +XGraphicsExposeEvent.y 44 +XGraphicsExposeEvent.width 48 +XGraphicsExposeEvent.height 52 +XGraphicsExposeEvent.count 56 +XGraphicsExposeEvent.major_code 60 +XGraphicsExposeEvent.minor_code 64 +XGraphicsExposeEvent 72 +XEvent.type 0 +XEvent.xany 0 +XEvent.xkey 0 +XEvent.xbutton 0 +XEvent.xmotion 0 +XEvent.xcrossing 0 +XEvent.xfocus 0 +XEvent.xexpose 0 +XEvent.xgraphicsexpose 0 +XEvent.xnoexpose 0 +XEvent.xvisibility 0 +XEvent.xcreatewindow 0 +XEvent.xdestroywindow 0 +XEvent.xunmap 0 +XEvent.xmap 0 +XEvent.xmaprequest 0 +XEvent.xreparent 0 +XEvent.xconfigure 0 +XEvent.xgravity 0 +XEvent.xresizerequest 0 +XEvent.xconfigurerequest 0 +XEvent.xcirculate 0 +XEvent.xcirculaterequest 0 +XEvent.xproperty 0 +XEvent.xselectionclear 0 +XEvent.xselectionrequest 0 +XEvent.xselection 0 +XEvent.xcolormap 0 +XEvent.xclient 0 +XEvent.xmapping 0 +XEvent.xerror 0 +XEvent.xkeymap 0 +XEvent.pad 0 +XEvent 192 +XRenderDirectFormat.red 0 +XRenderDirectFormat.redMask 2 +XRenderDirectFormat.green 4 +XRenderDirectFormat.greenMask 6 +XRenderDirectFormat.blue 8 +XRenderDirectFormat.blueMask 10 +XRenderDirectFormat.alpha 12 +XRenderDirectFormat.alphaMask 14 +XRenderDirectFormat 16 +ColorData.awt_Colors 0 +ColorData.awt_numICMcolors 8 +ColorData.awt_icmLUT 16 +ColorData.awt_icmLUT2Colors 24 +ColorData.img_grays 32 +ColorData.img_clr_tbl 40 +ColorData.img_oda_red 48 +ColorData.img_oda_green 56 +ColorData.img_oda_blue 64 +ColorData.pGrayInverseLutData 72 +ColorData.screendata 80 +ColorData 88 +XFontStruct.ext_data 0 +XFontStruct.fid 8 +XFontStruct.direction 16 +XFontStruct.min_char_or_byte2 20 +XFontStruct.max_char_or_byte2 24 +XFontStruct.min_byte1 28 +XFontStruct.max_byte1 32 +XFontStruct.all_chars_exist 36 +XFontStruct.n_properties 44 +XFontStruct.properties 48 +XFontStruct.min_bounds 56 +XFontStruct.max_bounds 68 +XFontStruct.per_char 80 +XFontStruct.ascent 88 +XFontStruct.descent 92 +XFontStruct 96 +XExtCodes.extension 0 +XExtCodes.major_opcode 4 +XExtCodes.first_event 8 +XExtCodes.first_error 12 +XExtCodes 16 +XFontSetExtents.max_ink_extent 0 +XFontSetExtents.max_logical_extent 8 +XFontSetExtents 16 +XSelectionEvent.type 0 +XSelectionEvent.serial 8 +XSelectionEvent.send_event 16 +XSelectionEvent.display 24 +XSelectionEvent.requestor 32 +XSelectionEvent.selection 40 +XSelectionEvent.target 48 +XSelectionEvent.property 56 +XSelectionEvent.time 64 +XSelectionEvent 72 +XArc.x 0 +XArc.y 2 +XArc.width 4 +XArc.height 6 +XArc.angle1 8 +XArc.angle2 10 +XArc 12 +XErrorEvent.type 0 +XErrorEvent.display 8 +XErrorEvent.resourceid 16 +XErrorEvent.serial 24 +XErrorEvent.error_code 32 +XErrorEvent.request_code 33 +XErrorEvent.minor_code 34 +XErrorEvent 40 +XConfigureRequestEvent.type 0 +XConfigureRequestEvent.serial 8 +XConfigureRequestEvent.send_event 16 +XConfigureRequestEvent.display 24 +XConfigureRequestEvent.parent 32 +XConfigureRequestEvent.window 40 +XConfigureRequestEvent.x 48 +XConfigureRequestEvent.y 52 +XConfigureRequestEvent.width 56 +XConfigureRequestEvent.height 60 +XConfigureRequestEvent.border_width 64 +XConfigureRequestEvent.above 72 +XConfigureRequestEvent.detail 80 +XConfigureRequestEvent.value_mask 88 +XConfigureRequestEvent 96 +ScreenFormat.ext_data 0 +ScreenFormat.depth 8 +ScreenFormat.bits_per_pixel 12 +ScreenFormat.scanline_pad 16 +ScreenFormat 24 +XButtonEvent.type 0 +XButtonEvent.serial 8 +XButtonEvent.send_event 16 +XButtonEvent.display 24 +XButtonEvent.window 32 +XButtonEvent.root 40 +XButtonEvent.subwindow 48 +XButtonEvent.time 56 +XButtonEvent.x 64 +XButtonEvent.y 68 +XButtonEvent.x_root 72 +XButtonEvent.y_root 76 +XButtonEvent.state 80 +XButtonEvent.button 84 +XButtonEvent.same_screen 88 +XButtonEvent 96 +XFontProp.name 0 +XFontProp.card32 8 +XFontProp 16 +XIMValuesList.count_values 0 +XIMValuesList.supported_values 8 +XIMValuesList 16 +XKeymapEvent.type 0 +XKeymapEvent.serial 8 +XKeymapEvent.send_event 16 +XKeymapEvent.display 24 +XKeymapEvent.window 32 +XKeymapEvent.key_vector 40 +XKeymapEvent 72 +XTextItem16.chars 0 +XTextItem16.nchars 8 +XTextItem16.delta 12 +XTextItem16.font 16 +XTextItem16 24 +XIMPreeditDrawCallbackStruct.caret 0 +XIMPreeditDrawCallbackStruct.chg_first 4 +XIMPreeditDrawCallbackStruct.chg_length 8 +XIMPreeditDrawCallbackStruct.text 16 +XIMPreeditDrawCallbackStruct 24 +XVisualInfo.visual 0 +XVisualInfo.visualid 8 +XVisualInfo.screen 16 +XVisualInfo.depth 20 +XVisualInfo.class 24 +XVisualInfo.red_mask 32 +XVisualInfo.green_mask 40 +XVisualInfo.blue_mask 48 +XVisualInfo.colormap_size 56 +XVisualInfo.bits_per_rgb 60 +XVisualInfo 64 +XkbControlsNotifyEvent.type 0 +XkbControlsNotifyEvent.serial 8 +XkbControlsNotifyEvent.send_event 16 +XkbControlsNotifyEvent.display 24 +XkbControlsNotifyEvent.time 32 +XkbControlsNotifyEvent.xkb_type 40 +XkbControlsNotifyEvent.device 44 +XkbControlsNotifyEvent.changed_ctrls 48 +XkbControlsNotifyEvent.enabled_ctrls 52 +XkbControlsNotifyEvent.enabled_ctrl_changes 56 +XkbControlsNotifyEvent.num_groups 60 +XkbControlsNotifyEvent.keycode 64 +XkbControlsNotifyEvent.event_type 65 +XkbControlsNotifyEvent.req_major 66 +XkbControlsNotifyEvent.req_minor 67 +XkbControlsNotifyEvent 72 +PropMwmHints.flags 0 +PropMwmHints.functions 8 +PropMwmHints.decorations 16 +PropMwmHints.inputMode 24 +PropMwmHints.status 32 +PropMwmHints 40 +XClientMessageEvent.type 0 +XClientMessageEvent.serial 8 +XClientMessageEvent.send_event 16 +XClientMessageEvent.display 24 +XClientMessageEvent.window 32 +XClientMessageEvent.message_type 40 +XClientMessageEvent.format 48 +XClientMessageEvent.data 56 +XClientMessageEvent 96 +XAnyEvent.type 0 +XAnyEvent.serial 8 +XAnyEvent.send_event 16 +XAnyEvent.display 24 +XAnyEvent.window 32 +XAnyEvent 40 +XkbIndicatorNotifyEvent.type 0 +XkbIndicatorNotifyEvent.serial 8 +XkbIndicatorNotifyEvent.send_event 16 +XkbIndicatorNotifyEvent.display 24 +XkbIndicatorNotifyEvent.time 32 +XkbIndicatorNotifyEvent.xkb_type 40 +XkbIndicatorNotifyEvent.device 44 +XkbIndicatorNotifyEvent.changed 48 +XkbIndicatorNotifyEvent.state 52 +XkbIndicatorNotifyEvent 56 +XIMPreeditStateNotifyCallbackStruct.state 0 +XIMPreeditStateNotifyCallbackStruct 8 +XkbAnyEvent.type 0 +XkbAnyEvent.serial 8 +XkbAnyEvent.send_event 16 +XkbAnyEvent.display 24 +XkbAnyEvent.time 32 +XkbAnyEvent.xkb_type 40 +XkbAnyEvent.device 44 +XkbAnyEvent 48 +XMotionEvent.type 0 +XMotionEvent.serial 8 +XMotionEvent.send_event 16 +XMotionEvent.display 24 +XMotionEvent.window 32 +XMotionEvent.root 40 +XMotionEvent.subwindow 48 +XMotionEvent.time 56 +XMotionEvent.x 64 +XMotionEvent.y 68 +XMotionEvent.x_root 72 +XMotionEvent.y_root 76 +XMotionEvent.state 80 +XMotionEvent.is_hint 84 +XMotionEvent.same_screen 88 +XMotionEvent 96 +XIMHotKeyTriggers.num_hot_key 0 +XIMHotKeyTriggers.key 8 +XIMHotKeyTriggers 16 +XIMStyles.count_styles 0 +XIMStyles.supported_styles 8 +XIMStyles 16 +XkbExtensionDeviceNotifyEvent.type 0 +XkbExtensionDeviceNotifyEvent.serial 8 +XkbExtensionDeviceNotifyEvent.send_event 16 +XkbExtensionDeviceNotifyEvent.display 24 +XkbExtensionDeviceNotifyEvent.time 32 +XkbExtensionDeviceNotifyEvent.xkb_type 40 +XkbExtensionDeviceNotifyEvent.device 44 +XkbExtensionDeviceNotifyEvent.reason 48 +XkbExtensionDeviceNotifyEvent.supported 52 +XkbExtensionDeviceNotifyEvent.unsupported 56 +XkbExtensionDeviceNotifyEvent.first_btn 60 +XkbExtensionDeviceNotifyEvent.num_btns 64 +XkbExtensionDeviceNotifyEvent.leds_defined 68 +XkbExtensionDeviceNotifyEvent.led_state 72 +XkbExtensionDeviceNotifyEvent.led_class 76 +XkbExtensionDeviceNotifyEvent.led_id 80 +XkbExtensionDeviceNotifyEvent 88 +XwcTextItem.chars 0 +XwcTextItem.nchars 8 +XwcTextItem.delta 12 +XwcTextItem.font_set 16 +XwcTextItem 24 +XClassHint.res_name 0 +XClassHint.res_class 8 +XClassHint 16 +XChar2b.byte1 0 +XChar2b.byte2 1 +XChar2b 2 +XSetWindowAttributes.background_pixmap 0 +XSetWindowAttributes.background_pixel 8 +XSetWindowAttributes.border_pixmap 16 +XSetWindowAttributes.border_pixel 24 +XSetWindowAttributes.bit_gravity 32 +XSetWindowAttributes.win_gravity 36 +XSetWindowAttributes.backing_store 40 +XSetWindowAttributes.backing_planes 48 +XSetWindowAttributes.backing_pixel 56 +XSetWindowAttributes.save_under 64 +XSetWindowAttributes.event_mask 72 +XSetWindowAttributes.do_not_propagate_mask 80 +XSetWindowAttributes.override_redirect 88 +XSetWindowAttributes.colormap 96 +XSetWindowAttributes.cursor 104 +XSetWindowAttributes 112 +XRenderPictFormat.id 0 +XRenderPictFormat.type 8 +XRenderPictFormat.depth 12 +XRenderPictFormat.direct 16 +XRenderPictFormat.colormap 32 +XRenderPictFormat 40 +XReparentEvent.type 0 +XReparentEvent.serial 8 +XReparentEvent.send_event 16 +XReparentEvent.display 24 +XReparentEvent.event 32 +XReparentEvent.window 40 +XReparentEvent.parent 48 +XReparentEvent.x 56 +XReparentEvent.y 60 +XReparentEvent.override_redirect 64 +XReparentEvent 72 +XCirculateRequestEvent.type 0 +XCirculateRequestEvent.serial 8 +XCirculateRequestEvent.send_event 16 +XCirculateRequestEvent.display 24 +XCirculateRequestEvent.parent 32 +XCirculateRequestEvent.window 40 +XCirculateRequestEvent.place 48 +XCirculateRequestEvent 56 +XImage.width 0 +XImage.height 4 +XImage.xoffset 8 +XImage.format 12 +XImage.data 16 +XImage.byte_order 24 +XImage.bitmap_unit 28 +XImage.bitmap_bit_order 32 +XImage.bitmap_pad 36 +XImage.depth 40 +XImage.bytes_per_line 44 +XImage.bits_per_pixel 48 +XImage.red_mask 56 +XImage.green_mask 64 +XImage.blue_mask 72 +XImage.obdata 80 +XImage.f.create_image 88 +XImage.f.destroy_image 96 +XImage.f.get_pixel 104 +XImage.f.put_pixel 112 +XImage.f.sub_image 120 +XImage.f.add_pixel 128 +XImage 136 +XKeyEvent.type 0 +XKeyEvent.serial 8 +XKeyEvent.send_event 16 +XKeyEvent.display 24 +XKeyEvent.window 32 +XKeyEvent.root 40 +XKeyEvent.subwindow 48 +XKeyEvent.time 56 +XKeyEvent.x 64 +XKeyEvent.y 68 +XKeyEvent.x_root 72 +XKeyEvent.y_root 76 +XKeyEvent.state 80 +XKeyEvent.keycode 84 +XKeyEvent.same_screen 88 +XKeyEvent 96 +XkbActionMessageEvent.type 0 +XkbActionMessageEvent.serial 8 +XkbActionMessageEvent.send_event 16 +XkbActionMessageEvent.display 24 +XkbActionMessageEvent.time 32 +XkbActionMessageEvent.xkb_type 40 +XkbActionMessageEvent.device 44 +XkbActionMessageEvent.keycode 48 +XkbActionMessageEvent.press 52 +XkbActionMessageEvent.key_event_follows 56 +XkbActionMessageEvent.group 60 +XkbActionMessageEvent.mods 64 +XkbActionMessageEvent.message 68 +XkbActionMessageEvent 80 +XdbeSwapInfo.swap_window 0 +XdbeSwapInfo.swap_action 8 +XdbeSwapInfo 16 +XTextItem.chars 0 +XTextItem.nchars 8 +XTextItem.delta 12 +XTextItem.font 16 +XTextItem 24 +XModifierKeymap.max_keypermod 0 +XModifierKeymap.modifiermap 8 +XModifierKeymap 16 +XCharStruct.lbearing 0 +XCharStruct.rbearing 2 +XCharStruct.width 4 +XCharStruct.ascent 6 +XCharStruct.descent 8 +XCharStruct.attributes 10 +XCharStruct 12 +XGravityEvent.type 0 +XGravityEvent.serial 8 +XGravityEvent.send_event 16 +XGravityEvent.display 24 +XGravityEvent.event 32 +XGravityEvent.window 40 +XGravityEvent.x 48 +XGravityEvent.y 52 +XGravityEvent 56 +Visual.ext_data 0 +Visual.visualid 8 +Visual.class 16 +Visual.red_mask 24 +Visual.green_mask 32 +Visual.blue_mask 40 +Visual.bits_per_rgb 48 +Visual.map_entries 52 +Visual 56 +XOMOrientation.num_orientation 0 +XOMOrientation.orientation 8 +XOMOrientation 16 +XkbAccessXNotifyEvent.type 0 +XkbAccessXNotifyEvent.serial 8 +XkbAccessXNotifyEvent.send_event 16 +XkbAccessXNotifyEvent.display 24 +XkbAccessXNotifyEvent.time 32 +XkbAccessXNotifyEvent.xkb_type 40 +XkbAccessXNotifyEvent.device 44 +XkbAccessXNotifyEvent.detail 48 +XkbAccessXNotifyEvent.keycode 52 +XkbAccessXNotifyEvent.sk_delay 56 +XkbAccessXNotifyEvent.debounce_delay 60 +XkbAccessXNotifyEvent 64 +XWindowAttributes.x 0 +XWindowAttributes.y 4 +XWindowAttributes.width 8 +XWindowAttributes.height 12 +XWindowAttributes.border_width 16 +XWindowAttributes.depth 20 +XWindowAttributes.visual 24 +XWindowAttributes.root 32 +XWindowAttributes.class 40 +XWindowAttributes.bit_gravity 44 +XWindowAttributes.win_gravity 48 +XWindowAttributes.backing_store 52 +XWindowAttributes.backing_planes 56 +XWindowAttributes.backing_pixel 64 +XWindowAttributes.save_under 72 +XWindowAttributes.colormap 80 +XWindowAttributes.map_installed 88 +XWindowAttributes.map_state 92 +XWindowAttributes.all_event_masks 96 +XWindowAttributes.your_event_mask 104 +XWindowAttributes.do_not_propagate_mask 112 +XWindowAttributes.override_redirect 120 +XWindowAttributes.screen 128 +XWindowAttributes 136 +XmbTextItem.chars 0 +XmbTextItem.nchars 8 +XmbTextItem.delta 12 +XmbTextItem.font_set 16 +XmbTextItem 24 +XMappingEvent.type 0 +XMappingEvent.serial 8 +XMappingEvent.send_event 16 +XMappingEvent.display 24 +XMappingEvent.window 32 +XMappingEvent.request 40 +XMappingEvent.first_keycode 44 +XMappingEvent.count 48 +XMappingEvent 56 +XSizeHints.flags 0 +XSizeHints.x 8 +XSizeHints.y 12 +XSizeHints.width 16 +XSizeHints.height 20 +XSizeHints.min_width 24 +XSizeHints.min_height 28 +XSizeHints.max_width 32 +XSizeHints.max_height 36 +XSizeHints.width_inc 40 +XSizeHints.height_inc 44 +XSizeHints.min_aspect.x 48 +XSizeHints.min_aspect.y 52 +XSizeHints.max_aspect.x 56 +XSizeHints.max_aspect.y 60 +XSizeHints.base_width 64 +XSizeHints.base_height 68 +XSizeHints.win_gravity 72 +XSizeHints 80 +XUnmapEvent.type 0 +XUnmapEvent.serial 8 +XUnmapEvent.send_event 16 +XUnmapEvent.display 24 +XUnmapEvent.event 32 +XUnmapEvent.window 40 +XUnmapEvent.from_configure 48 +XUnmapEvent 56 +awtImageData.Depth 0 +awtImageData.wsImageFormat 4 +awtImageData.clrdata 16 +awtImageData.convert 48 +awtImageData 560 +XkbStateNotifyEvent.type 0 +XkbStateNotifyEvent.serial 8 +XkbStateNotifyEvent.send_event 16 +XkbStateNotifyEvent.display 24 +XkbStateNotifyEvent.time 32 +XkbStateNotifyEvent.xkb_type 40 +XkbStateNotifyEvent.device 44 +XkbStateNotifyEvent.changed 48 +XkbStateNotifyEvent.group 52 +XkbStateNotifyEvent.base_group 56 +XkbStateNotifyEvent.latched_group 60 +XkbStateNotifyEvent.locked_group 64 +XkbStateNotifyEvent.mods 68 +XkbStateNotifyEvent.base_mods 72 +XkbStateNotifyEvent.latched_mods 76 +XkbStateNotifyEvent.locked_mods 80 +XkbStateNotifyEvent.compat_state 84 +XkbStateNotifyEvent.grab_mods 88 +XkbStateNotifyEvent.compat_grab_mods 89 +XkbStateNotifyEvent.lookup_mods 90 +XkbStateNotifyEvent.compat_lookup_mods 91 +XkbStateNotifyEvent.ptr_buttons 92 +XkbStateNotifyEvent.keycode 96 +XkbStateNotifyEvent.event_type 97 +XkbStateNotifyEvent.req_major 98 +XkbStateNotifyEvent.req_minor 99 +XkbStateNotifyEvent 104 +XExposeEvent.type 0 +XExposeEvent.serial 8 +XExposeEvent.send_event 16 +XExposeEvent.display 24 +XExposeEvent.window 32 +XExposeEvent.x 40 +XExposeEvent.y 44 +XExposeEvent.width 48 +XExposeEvent.height 52 +XExposeEvent.count 56 +XExposeEvent 64 +XkbMapNotifyEvent.type 0 +XkbMapNotifyEvent.serial 8 +XkbMapNotifyEvent.send_event 16 +XkbMapNotifyEvent.display 24 +XkbMapNotifyEvent.time 32 +XkbMapNotifyEvent.xkb_type 40 +XkbMapNotifyEvent.device 44 +XkbMapNotifyEvent.changed 48 +XkbMapNotifyEvent.flags 52 +XkbMapNotifyEvent.first_type 56 +XkbMapNotifyEvent.num_types 60 +XkbMapNotifyEvent.min_key_code 64 +XkbMapNotifyEvent.max_key_code 65 +XkbMapNotifyEvent.first_key_sym 66 +XkbMapNotifyEvent.first_key_act 67 +XkbMapNotifyEvent.first_key_behavior 68 +XkbMapNotifyEvent.first_key_explicit 69 +XkbMapNotifyEvent.first_modmap_key 70 +XkbMapNotifyEvent.first_vmodmap_key 71 +XkbMapNotifyEvent.num_key_syms 72 +XkbMapNotifyEvent.num_key_acts 76 +XkbMapNotifyEvent.num_key_behaviors 80 +XkbMapNotifyEvent.num_key_explicit 84 +XkbMapNotifyEvent.num_modmap_keys 88 +XkbMapNotifyEvent.num_vmodmap_keys 92 +XkbMapNotifyEvent.vmods 96 +XkbMapNotifyEvent 104 +XGCValues.function 0 +XGCValues.plane_mask 8 +XGCValues.foreground 16 +XGCValues.background 24 +XGCValues.line_width 32 +XGCValues.line_style 36 +XGCValues.cap_style 40 +XGCValues.join_style 44 +XGCValues.fill_style 48 +XGCValues.fill_rule 52 +XGCValues.arc_mode 56 +XGCValues.tile 64 +XGCValues.stipple 72 +XGCValues.ts_x_origin 80 +XGCValues.ts_y_origin 84 +XGCValues.font 88 +XGCValues.subwindow_mode 96 +XGCValues.graphics_exposures 100 +XGCValues.clip_x_origin 104 +XGCValues.clip_y_origin 108 +XGCValues.clip_mask 112 +XGCValues.dash_offset 120 +XGCValues.dashes 124 +XGCValues 128 +XFocusChangeEvent.type 0 +XFocusChangeEvent.serial 8 +XFocusChangeEvent.send_event 16 +XFocusChangeEvent.display 24 +XFocusChangeEvent.window 32 +XFocusChangeEvent.mode 40 +XFocusChangeEvent.detail 44 +XFocusChangeEvent 48 +XPixmapFormatValues.depth 0 +XPixmapFormatValues.bits_per_pixel 4 +XPixmapFormatValues.scanline_pad 8 +XPixmapFormatValues 12 +XMapEvent.type 0 +XMapEvent.serial 8 +XMapEvent.send_event 16 +XMapEvent.display 24 +XMapEvent.event 32 +XMapEvent.window 40 +XMapEvent.override_redirect 48 +XMapEvent 56 +XkbBellNotifyEvent.type 0 +XkbBellNotifyEvent.serial 8 +XkbBellNotifyEvent.send_event 16 +XkbBellNotifyEvent.display 24 +XkbBellNotifyEvent.time 32 +XkbBellNotifyEvent.xkb_type 40 +XkbBellNotifyEvent.device 44 +XkbBellNotifyEvent.percent 48 +XkbBellNotifyEvent.pitch 52 +XkbBellNotifyEvent.duration 56 +XkbBellNotifyEvent.bell_class 60 +XkbBellNotifyEvent.bell_id 64 +XkbBellNotifyEvent.name 72 +XkbBellNotifyEvent.window 80 +XkbBellNotifyEvent.event_only 88 +XkbBellNotifyEvent 96 +XIMStringConversionText.length 0 +XIMStringConversionText.feedback 8 +XIMStringConversionText.encoding_is_wchar 16 +XIMStringConversionText.string 24 +XIMStringConversionText 32 +XKeyboardState.key_click_percent 0 +XKeyboardState.bell_percent 4 +XKeyboardState.bell_pitch 8 +XKeyboardState.bell_duration 12 +XKeyboardState.led_mask 16 +XKeyboardState.global_auto_repeat 24 +XKeyboardState.auto_repeats 28 +XKeyboardState 64 +XkbEvent.type 0 +XkbEvent.any 0 +XkbEvent.new_kbd 0 +XkbEvent.map 0 +XkbEvent.state 0 +XkbEvent.ctrls 0 +XkbEvent.indicators 0 +XkbEvent.names 0 +XkbEvent.compat 0 +XkbEvent.bell 0 +XkbEvent.message 0 +XkbEvent.accessx 0 +XkbEvent.device 0 +XkbEvent.core 0 +XkbEvent 192 +XPoint.x 0 +XPoint.y 2 +XPoint 4 +XSegment.x1 0 +XSegment.y1 2 +XSegment.x2 4 +XSegment.y2 6 +XSegment 8 +XIconSize.min_width 0 +XIconSize.min_height 4 +XIconSize.max_width 8 +XIconSize.max_height 12 +XIconSize.width_inc 16 +XIconSize.height_inc 20 +XIconSize 24 +XIMCallback.client_data 0 +XIMCallback.callback 8 +XIMCallback 16 +XConfigureEvent.type 0 +XConfigureEvent.serial 8 +XConfigureEvent.send_event 16 +XConfigureEvent.display 24 +XConfigureEvent.event 32 +XConfigureEvent.window 40 +XConfigureEvent.x 48 +XConfigureEvent.y 52 +XConfigureEvent.width 56 +XConfigureEvent.height 60 +XConfigureEvent.border_width 64 +XConfigureEvent.above 72 +XConfigureEvent.override_redirect 80 +XConfigureEvent 88 +XRectangle.x 0 +XRectangle.y 2 +XRectangle.width 4 +XRectangle.height 6 +XRectangle 8 +XkbNamesNotifyEvent.type 0 +XkbNamesNotifyEvent.serial 8 +XkbNamesNotifyEvent.send_event 16 +XkbNamesNotifyEvent.display 24 +XkbNamesNotifyEvent.time 32 +XkbNamesNotifyEvent.xkb_type 40 +XkbNamesNotifyEvent.device 44 +XkbNamesNotifyEvent.changed 48 +XkbNamesNotifyEvent.first_type 52 +XkbNamesNotifyEvent.num_types 56 +XkbNamesNotifyEvent.first_lvl 60 +XkbNamesNotifyEvent.num_lvls 64 +XkbNamesNotifyEvent.num_aliases 68 +XkbNamesNotifyEvent.num_radio_groups 72 +XkbNamesNotifyEvent.changed_vmods 76 +XkbNamesNotifyEvent.changed_groups 80 +XkbNamesNotifyEvent.changed_indicators 84 +XkbNamesNotifyEvent.first_key 88 +XkbNamesNotifyEvent.num_keys 92 +XkbNamesNotifyEvent 96 +XCreateWindowEvent.type 0 +XCreateWindowEvent.serial 8 +XCreateWindowEvent.send_event 16 +XCreateWindowEvent.display 24 +XCreateWindowEvent.parent 32 +XCreateWindowEvent.window 40 +XCreateWindowEvent.x 48 +XCreateWindowEvent.y 52 +XCreateWindowEvent.width 56 +XCreateWindowEvent.height 60 +XCreateWindowEvent.border_width 64 +XCreateWindowEvent.override_redirect 68 +XCreateWindowEvent 72 +XVisibilityEvent.type 0 +XVisibilityEvent.serial 8 +XVisibilityEvent.send_event 16 +XVisibilityEvent.display 24 +XVisibilityEvent.window 32 +XVisibilityEvent.state 40 +XVisibilityEvent 48 +XWMHints.flags 0 +XWMHints.initial_state 12 +XWMHints.icon_pixmap 16 +XWMHints.icon_window 24 +XWMHints.icon_x 32 +XWMHints.icon_y 36 +XWMHints.icon_mask 40 +XWMHints.input 8 +XWMHints.window_group 48 +XWMHints 56 +XCrossingEvent.type 0 +XCrossingEvent.serial 8 +XCrossingEvent.send_event 16 +XCrossingEvent.display 24 +XCrossingEvent.window 32 +XCrossingEvent.root 40 +XCrossingEvent.subwindow 48 +XCrossingEvent.time 56 +XCrossingEvent.x 64 +XCrossingEvent.y 68 +XCrossingEvent.x_root 72 +XCrossingEvent.y_root 76 +XCrossingEvent.mode 80 +XCrossingEvent.detail 84 +XCrossingEvent.same_screen 88 +XCrossingEvent.focus 92 +XCrossingEvent.state 96 +XCrossingEvent 104 +XSelectionRequestEvent.type 0 +XSelectionRequestEvent.serial 8 +XSelectionRequestEvent.send_event 16 +XSelectionRequestEvent.display 24 +XSelectionRequestEvent.owner 32 +XSelectionRequestEvent.requestor 40 +XSelectionRequestEvent.selection 48 +XSelectionRequestEvent.target 56 +XSelectionRequestEvent.property 64 +XSelectionRequestEvent.time 72 +XSelectionRequestEvent 80 +XNoExposeEvent.type 0 +XNoExposeEvent.serial 8 +XNoExposeEvent.send_event 16 +XNoExposeEvent.display 24 +XNoExposeEvent.drawable 32 +XNoExposeEvent.major_code 40 +XNoExposeEvent.minor_code 44 +XNoExposeEvent 48 +XHostAddress.family 0 +XHostAddress.length 4 +XHostAddress.address 8 +XHostAddress 16 +XColormapEvent.type 0 +XColormapEvent.serial 8 +XColormapEvent.send_event 16 +XColormapEvent.display 24 +XColormapEvent.window 32 +XColormapEvent.colormap 40 +XColormapEvent.new 48 +XColormapEvent.state 52 +XColormapEvent 56 +ColorEntry.r 0 +ColorEntry.g 1 +ColorEntry.b 2 +ColorEntry.flags 3 +ColorEntry 4 +XResizeRequestEvent.type 0 +XResizeRequestEvent.serial 8 +XResizeRequestEvent.send_event 16 +XResizeRequestEvent.display 24 +XResizeRequestEvent.window 32 +XResizeRequestEvent.width 40 +XResizeRequestEvent.height 44 +XResizeRequestEvent 48 +Depth.depth 0 +Depth.nvisuals 4 +Depth.visuals 8 +Depth 16 +XPropertyEvent.type 0 +XPropertyEvent.serial 8 +XPropertyEvent.send_event 16 +XPropertyEvent.display 24 +XPropertyEvent.window 32 +XPropertyEvent.atom 40 +XPropertyEvent.time 48 +XPropertyEvent.state 56 +XPropertyEvent 64 +XDestroyWindowEvent.type 0 +XDestroyWindowEvent.serial 8 +XDestroyWindowEvent.send_event 16 +XDestroyWindowEvent.display 24 +XDestroyWindowEvent.event 32 +XDestroyWindowEvent.window 40 +XDestroyWindowEvent 48 +XStandardColormap.colormap 0 +XStandardColormap.red_max 8 +XStandardColormap.red_mult 16 +XStandardColormap.green_max 24 +XStandardColormap.green_mult 32 +XStandardColormap.blue_max 40 +XStandardColormap.blue_mult 48 +XStandardColormap.base_pixel 56 +XStandardColormap.visualid 64 +XStandardColormap.killid 72 +XStandardColormap 80 +XComposeStatus.compose_ptr 0 +XComposeStatus.chars_matched 8 +XComposeStatus 16 +AwtGraphicsConfigData.awt_depth 0 +AwtGraphicsConfigData.awt_cmap 8 +AwtGraphicsConfigData.awt_visInfo 16 +AwtGraphicsConfigData.awt_num_colors 80 +AwtGraphicsConfigData.awtImage 88 +AwtGraphicsConfigData.AwtColorMatch 96 +AwtGraphicsConfigData.monoImage 104 +AwtGraphicsConfigData.monoPixmap 112 +AwtGraphicsConfigData.monoPixmapWidth 120 +AwtGraphicsConfigData.monoPixmapHeight 124 +AwtGraphicsConfigData.monoPixmapGC 128 +AwtGraphicsConfigData.pixelStride 136 +AwtGraphicsConfigData.color_data 144 +AwtGraphicsConfigData.glxInfo 152 +AwtGraphicsConfigData.isTranslucencySupported 160 +AwtGraphicsConfigData.renderPictFormat 168 +AwtGraphicsConfigData 208 +XColor.pixel 0 +XColor.red 8 +XColor.green 10 +XColor.blue 12 +XColor.flags 14 +XColor.pad 15 +XColor 16 +XTextProperty.value 0 +XTextProperty.encoding 8 +XTextProperty.format 16 +XTextProperty.nitems 24 +XTextProperty 32 diff -r a8bbd962f34a -r 41654275896d src/solaris/native/java/net/linux_close.c --- a/src/solaris/native/java/net/linux_close.c Mon Jan 28 16:29:10 2013 -0400 +++ b/src/solaris/native/java/net/linux_close.c Mon Feb 04 17:29:58 2013 -0400 @@ -192,17 +192,6 @@ { /* - * Send a wakeup signal to all threads blocked on this - * file descriptor. - */ - threadEntry_t *curr = fdEntry->threads; - while (curr != NULL) { - curr->intr = 1; - pthread_kill( curr->thr, sigWakeup ); - curr = curr->next; - } - - /* * And close/dup the file descriptor * (restart if interrupted by signal) */ @@ -214,6 +203,16 @@ } } while (rv == -1 && errno == EINTR); + /* + * Send a wakeup signal to all threads blocked on this + * file descriptor. + */ + threadEntry_t *curr = fdEntry->threads; + while (curr != NULL) { + curr->intr = 1; + pthread_kill( curr->thr, sigWakeup ); + curr = curr->next; + } } /* diff -r a8bbd962f34a -r 41654275896d src/windows/bin/cmdtoargs.c --- a/src/windows/bin/cmdtoargs.c Mon Jan 28 16:29:10 2013 -0400 +++ b/src/windows/bin/cmdtoargs.c Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,6 +104,11 @@ case ' ': case '\t': + if (prev == '\\') { + for (i = 0 ; i < slashes; i++) { + *dest++ = prev; + } + } if (quotes % 2 == 1) { *dest++ = ch; } else { @@ -591,6 +596,12 @@ // v->disable(); vectors[i++] = v; + v= new Vector(argv[0], "a b\\\\ d"); + v->add("a", FALSE); + v->add("b\\\\", FALSE); + v->add("d", FALSE); + vectors[i++] = v; + dotest(vectors); printf("All tests pass [%d]\n", i); doexit(0); diff -r a8bbd962f34a -r 41654275896d test/ProblemList.txt --- a/test/ProblemList.txt Mon Jan 28 16:29:10 2013 -0400 +++ b/test/ProblemList.txt Mon Feb 04 17:29:58 2013 -0400 @@ -321,12 +321,12 @@ tools/pack200/CommandLineTests.java generic-all tools/pack200/Pack200Test.java generic-all -# 8001163 -tools/pack200/AttributeTests.java generic-all - # 7150569 tools/launcher/UnicodeTest.java macosx-all +# 8007410 +tools/launcher/FXLauncherTest.java linux-all + ############################################################################ # jdk_jdi diff -r a8bbd962f34a -r 41654275896d test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/FullScreen/FullScreenInsets/FullScreenInsets.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.AWTException; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.DisplayMode; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.image.BufferedImage; + +import sun.awt.SunToolkit; + +/** + * @test + * @bug 8003173 7019055 + * @summary Full-screen windows should have the proper insets. + * @author Sergey Bylokhov + */ +public final class FullScreenInsets { + + private static boolean passed = true; + + public static void main(final String[] args) { + final GraphicsEnvironment ge = GraphicsEnvironment + .getLocalGraphicsEnvironment(); + final GraphicsDevice[] devices = ge.getScreenDevices(); + + final Window wGreen = new Frame(); + wGreen.setBackground(Color.GREEN); + wGreen.setSize(300, 300); + wGreen.setVisible(true); + sleep(); + final Insets iGreen = wGreen.getInsets(); + final Dimension sGreen = wGreen.getSize(); + + final Window wRed = new Frame(); + wRed.setBackground(Color.RED); + wRed.setSize(300, 300); + wRed.setVisible(true); + sleep(); + final Insets iRed = wGreen.getInsets(); + final Dimension sRed = wGreen.getSize(); + + for (final GraphicsDevice device : devices) { + if (!device.isFullScreenSupported()) { + continue; + } + device.setFullScreenWindow(wGreen); + sleep(); + testWindowBounds(device.getDisplayMode(), wGreen); + testColor(wGreen, Color.GREEN); + + device.setFullScreenWindow(wRed); + sleep(); + testWindowBounds(device.getDisplayMode(), wRed); + testColor(wRed, Color.RED); + + device.setFullScreenWindow(null); + sleep(); + testInsets(wGreen.getInsets(), iGreen); + testInsets(wRed.getInsets(), iRed); + testSize(wGreen.getSize(), sGreen); + testSize(wRed.getSize(), sRed); + } + wGreen.dispose(); + wRed.dispose(); + if (!passed) { + throw new RuntimeException("Test failed"); + } + } + + private static void testSize(final Dimension actual, final Dimension exp) { + if (!exp.equals(actual)) { + System.err.println(" Wrong window size:" + + " Expected: " + exp + " Actual: " + actual); + passed = false; + } + } + + private static void testInsets(final Insets actual, final Insets exp) { + if (!actual.equals(exp)) { + System.err.println(" Wrong window insets:" + + " Expected: " + exp + " Actual: " + actual); + passed = false; + } + } + + private static void testWindowBounds(final DisplayMode dm, final Window w) { + if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) { + System.err.println(" Wrong window bounds:" + + " Expected: width = " + dm.getWidth() + + ", height = " + dm.getHeight() + " Actual: " + + w.getSize()); + passed = false; + } + } + + private static void testColor(final Window w, final Color color) { + final Robot r; + try { + r = new Robot(w.getGraphicsConfiguration().getDevice()); + } catch (AWTException e) { + e.printStackTrace(); + passed = false; + return; + } + final BufferedImage bi = r.createScreenCapture(w.getBounds()); + for (int y = 0; y < bi.getHeight(); y++) { + for (int x = 0; x < bi.getWidth(); x++) { + if (bi.getRGB(x, y) != color.getRGB()) { + System.err.println( + "Incorrect pixel at " + x + "x" + y + " : " + + Integer.toHexString(bi.getRGB(x, y)) + + " ,expected : " + Integer.toHexString( + color.getRGB())); + passed = false; + return; + } + } + } + } + + private static void sleep() { + ((SunToolkit) Toolkit.getDefaultToolkit()).realSync(); + try { + Thread.sleep(2000); + } catch (InterruptedException ignored) { + } + } +} diff -r a8bbd962f34a -r 41654275896d test/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java --- a/test/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.lang.reflect.InvocationTargetException; import test.java.awt.regtesthelpers.Util; +import sun.awt.OSInfo; public class SubMenuShowTest extends Applet { Robot robot; @@ -86,6 +87,11 @@ frame.setVisible(true); Util.waitForIdle(robot); + boolean isMacOSX = (OSInfo.getOSType() == OSInfo.OSType.MACOSX); + if (isMacOSX) { + robot.keyPress(KeyEvent.VK_CONTROL); + robot.delay(20); + } robot.keyPress(KeyEvent.VK_ALT); robot.delay(20); robot.keyPress(KeyEvent.VK_F); @@ -93,6 +99,10 @@ robot.keyRelease(KeyEvent.VK_F); robot.delay(20); robot.keyRelease(KeyEvent.VK_ALT); + if (isMacOSX) { + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.delay(20); + } Util.waitForIdle(robot); robot.keyPress(KeyEvent.VK_M); diff -r a8bbd962f34a -r 41654275896d test/java/beans/Introspector/TestTypeResolver.java --- a/test/java/beans/Introspector/TestTypeResolver.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/beans/Introspector/TestTypeResolver.java Mon Feb 04 17:29:58 2013 -0400 @@ -180,10 +180,22 @@ return null; // not used } + public T[] getAnnotations(Class annotationClass) { + return null; // not used + } + public Annotation[] getAnnotations() { return null; // not used } + public T getDeclaredAnnotation(Class annotationClass) { + return null; // not used + } + + public T[] getDeclaredAnnotations(Class annotationClass) { + return null; // not used + } + public Annotation[] getDeclaredAnnotations() { return null; // not used } diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/TypeAnnotationReflection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/annotation/TypeAnnotationReflection.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8004698 + * @summary Unit test for type annotations + */ + +import java.util.*; +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.io.Serializable; + +public class TypeAnnotationReflection { + public static void main(String[] args) throws Exception { + testSuper(); + testInterfaces(); + testReturnType(); + testNested(); + testArray(); + testRunException(); + testClassTypeVarBounds(); + testMethodTypeVarBounds(); + testFields(); + testClassTypeVar(); + testMethodTypeVar(); + testParameterizedType(); + testNestedParameterizedType(); + testWildcardType(); + } + + private static void check(boolean b) { + if (!b) + throw new RuntimeException(); + } + + private static void testSuper() throws Exception { + check(Object.class.getAnnotatedSuperclass().getAnnotations().length == 0); + check(Class.class.getAnnotatedSuperclass().getAnnotations().length == 0); + + AnnotatedType a; + a = TestClassArray.class.getAnnotatedSuperclass(); + Annotation[] annos = a.getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("extends")); + check(((TypeAnno2)annos[1]).value().equals("extends2")); + } + + private static void testInterfaces() throws Exception { + AnnotatedType[] as; + as = TestClassArray.class.getAnnotatedInterfaces(); + check(as.length == 3); + check(as[1].getAnnotations().length == 0); + + Annotation[] annos; + annos = as[0].getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("implements serializable")); + check(((TypeAnno2)annos[1]).value().equals("implements2 serializable")); + + annos = as[2].getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("implements cloneable")); + check(((TypeAnno2)annos[1]).value().equals("implements2 cloneable")); + } + + private static void testReturnType() throws Exception { + Method m = TestClassArray.class.getDeclaredMethod("foo", (Class[])null); + Annotation[] annos = m.getAnnotatedReturnType().getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("return1")); + } + + private static void testNested() throws Exception { + Method m = TestClassNested.class.getDeclaredMethod("foo", (Class[])null); + Annotation[] annos = m.getAnnotatedReturnType().getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("array")); + + AnnotatedType t = m.getAnnotatedReturnType(); + t = ((AnnotatedArrayType)t).getAnnotatedGenericComponentType(); + annos = t.getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("Inner")); + } + + private static void testArray() throws Exception { + Method m = TestClassArray.class.getDeclaredMethod("foo", (Class[])null); + AnnotatedArrayType t = (AnnotatedArrayType) m.getAnnotatedReturnType(); + Annotation[] annos = t.getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("return1")); + + t = (AnnotatedArrayType)t.getAnnotatedGenericComponentType(); + annos = t.getAnnotations(); + check(annos.length == 0); + + t = (AnnotatedArrayType)t.getAnnotatedGenericComponentType(); + annos = t.getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("return3")); + + AnnotatedType tt = t.getAnnotatedGenericComponentType(); + check(!(tt instanceof AnnotatedArrayType)); + annos = tt.getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("return4")); + } + + private static void testRunException() throws Exception { + Method m = TestClassException.class.getDeclaredMethod("foo", (Class[])null); + AnnotatedType[] ts = m.getAnnotatedExceptionTypes(); + check(ts.length == 3); + + AnnotatedType t; + Annotation[] annos; + t = ts[0]; + annos = t.getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("RE")); + check(((TypeAnno2)annos[1]).value().equals("RE2")); + + t = ts[1]; + annos = t.getAnnotations(); + check(annos.length == 0); + + t = ts[2]; + annos = t.getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("AIOOBE")); + } + + private static void testClassTypeVarBounds() throws Exception { + Method m = TestClassTypeVarAndField.class.getDeclaredMethod("foo", (Class[])null); + AnnotatedType ret = m.getAnnotatedReturnType(); + Annotation[] annos = ret.getAnnotations(); + check(annos.length == 2); + + AnnotatedType[] annotatedBounds = ((AnnotatedTypeVariable)ret).getAnnotatedBounds(); + check(annotatedBounds.length == 2); + + annos = annotatedBounds[0].getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("Object1")); + + annos = annotatedBounds[1].getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("Runnable1")); + check(((TypeAnno2)annos[1]).value().equals("Runnable2")); + } + + private static void testMethodTypeVarBounds() throws Exception { + Method m2 = TestClassTypeVarAndField.class.getDeclaredMethod("foo2", (Class[])null); + AnnotatedType ret2 = m2.getAnnotatedReturnType(); + AnnotatedType[] annotatedBounds2 = ((AnnotatedTypeVariable)ret2).getAnnotatedBounds(); + check(annotatedBounds2.length == 1); + + Annotation[] annos = annotatedBounds2[0].getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("M Runnable")); + } + + private static void testFields() throws Exception { + Field f1 = TestClassTypeVarAndField.class.getDeclaredField("field1"); + AnnotatedType at; + Annotation[] annos; + + at = f1.getAnnotatedType(); + annos = at.getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("T1 field")); + check(((TypeAnno2)annos[1]).value().equals("T2 field")); + + Field f2 = TestClassTypeVarAndField.class.getDeclaredField("field2"); + at = f2.getAnnotatedType(); + annos = at.getAnnotations(); + check(annos.length == 0); + + Field f3 = TestClassTypeVarAndField.class.getDeclaredField("field3"); + at = f3.getAnnotatedType(); + annos = at.getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("Object field")); + } + + private static void testClassTypeVar() throws Exception { + TypeVariable[] typeVars = TestClassTypeVarAndField.class.getTypeParameters(); + Annotation[] annos; + check(typeVars.length == 2); + + // First TypeVar + AnnotatedType[] annotatedBounds = typeVars[0].getAnnotatedBounds(); + check(annotatedBounds.length == 2); + + annos = annotatedBounds[0].getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("Object1")); + + annos = annotatedBounds[1].getAnnotations(); + check(annos.length == 2); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(annos[1].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno)annos[0]).value().equals("Runnable1")); + check(((TypeAnno2)annos[1]).value().equals("Runnable2")); + + // second TypeVar regular anno + Annotation[] regularAnnos = typeVars[1].getAnnotations(); + check(regularAnnos.length == 1); + check(typeVars[1].getAnnotation(TypeAnno.class).value().equals("EE")); + + // second TypeVar + annotatedBounds = typeVars[1].getAnnotatedBounds(); + check(annotatedBounds.length == 1); + + annos = annotatedBounds[0].getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno2.class)); + check(((TypeAnno2)annos[0]).value().equals("EEBound")); + } + + private static void testMethodTypeVar() throws Exception { + Method m2 = TestClassTypeVarAndField.class.getDeclaredMethod("foo2", (Class[])null); + TypeVariable[] t = m2.getTypeParameters(); + check(t.length == 1); + Annotation[] annos = t[0].getAnnotations(); + check(annos.length == 0); + + AnnotatedType[] annotatedBounds2 = t[0].getAnnotatedBounds(); + check(annotatedBounds2.length == 1); + + annos = annotatedBounds2[0].getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("M Runnable")); + + // Second method + m2 = TestClassTypeVarAndField.class.getDeclaredMethod("foo3", (Class[])null); + t = m2.getTypeParameters(); + check(t.length == 1); + annos = t[0].getAnnotations(); + check(annos.length == 1); + check(annos[0].annotationType().equals(TypeAnno.class)); + check(((TypeAnno)annos[0]).value().equals("K")); + + annotatedBounds2 = t[0].getAnnotatedBounds(); + check(annotatedBounds2.length == 1); + + annos = annotatedBounds2[0].getAnnotations(); + check(annos.length == 0); + } + + private static void testParameterizedType() { + // Base + AnnotatedType[] as; + as = TestParameterizedType.class.getAnnotatedInterfaces(); + check(as.length == 1); + check(as[0].getAnnotations().length == 1); + check(as[0].getAnnotation(TypeAnno.class).value().equals("M")); + + Annotation[] annos; + as = ((AnnotatedParameterizedType)as[0]).getAnnotatedActualTypeArguments(); + check(as.length == 2); + annos = as[0].getAnnotations(); + check(annos.length == 1); + check(as[0].getAnnotation(TypeAnno.class).value().equals("S")); + check(as[0].getAnnotation(TypeAnno2.class) == null); + + annos = as[1].getAnnotations(); + check(annos.length == 2); + check(((TypeAnno)annos[0]).value().equals("I")); + check(as[1].getAnnotation(TypeAnno2.class).value().equals("I2")); + } + + private static void testNestedParameterizedType() throws Exception { + Method m = TestParameterizedType.class.getDeclaredMethod("foo2", (Class[])null); + AnnotatedType ret = m.getAnnotatedReturnType(); + Annotation[] annos; + annos = ret.getAnnotations(); + check(annos.length == 1); + check(((TypeAnno)annos[0]).value().equals("I")); + + AnnotatedType[] args = ((AnnotatedParameterizedType)ret).getAnnotatedActualTypeArguments(); + check(args.length == 1); + annos = args[0].getAnnotations(); + check(annos.length == 2); + check(((TypeAnno)annos[0]).value().equals("I1")); + check(args[0].getAnnotation(TypeAnno2.class).value().equals("I2")); + } + + private static void testWildcardType() throws Exception { + Method m = TestWildcardType.class.getDeclaredMethod("foo", (Class[])null); + AnnotatedType ret = m.getAnnotatedReturnType(); + AnnotatedType[] t; + t = ((AnnotatedParameterizedType)ret).getAnnotatedActualTypeArguments(); + check(t.length == 1); + ret = t[0]; + + Field f = TestWildcardType.class.getDeclaredField("f1"); + AnnotatedWildcardType w = (AnnotatedWildcardType)((AnnotatedParameterizedType)f + .getAnnotatedType()).getAnnotatedActualTypeArguments()[0]; + t = w.getAnnotatedLowerBounds(); + check(t.length == 0); + t = w.getAnnotatedUpperBounds(); + check(t.length == 1); + Annotation[] annos; + annos = t[0].getAnnotations(); + check(annos.length == 1); + check(((TypeAnno)annos[0]).value().equals("2")); + + f = TestWildcardType.class.getDeclaredField("f2"); + w = (AnnotatedWildcardType)((AnnotatedParameterizedType)f + .getAnnotatedType()).getAnnotatedActualTypeArguments()[0]; + t = w.getAnnotatedUpperBounds(); + check(t.length == 0); + t = w.getAnnotatedLowerBounds(); + check(t.length == 1); + } +} + +abstract class TestWildcardType { + public List foo() { return null;} + public Class<@TypeAnno("1") ? extends @TypeAnno("2") Annotation> f1; + public Class<@TypeAnno("3") ? super @TypeAnno("4") Annotation> f2; +} + +abstract class TestParameterizedType implements @TypeAnno("M") Map<@TypeAnno("S")String, @TypeAnno("I") @TypeAnno2("I2")Integer> { + public ParameterizedOuter.ParameterizedInner foo() {return null;} + public @TypeAnno("O") ParameterizedOuter<@TypeAnno("S1") @TypeAnno2("S2") String>. + @TypeAnno("I") ParameterizedInner<@TypeAnno("I1") @TypeAnno2("I2")Integer> foo2() { + return null; + } +} + +class ParameterizedOuter { + class ParameterizedInner {} +} + +abstract class TestClassArray extends @TypeAnno("extends") @TypeAnno2("extends2") Object + implements @TypeAnno("implements serializable") @TypeAnno2("implements2 serializable") Serializable, + Readable, + @TypeAnno("implements cloneable") @TypeAnno2("implements2 cloneable") Cloneable { + public @TypeAnno("return4") Object @TypeAnno("return1") [][] @TypeAnno("return3")[] foo() { return null; } +} + +abstract class TestClassNested { + public @TypeAnno("Outer") Outer.@TypeAnno("Inner")Inner @TypeAnno("array")[] foo() { return null; } +} + +class Outer { + class Inner { + } +} + +abstract class TestClassException { + public Object foo() throws @TypeAnno("RE") @TypeAnno2("RE2") RuntimeException, + NullPointerException, + @TypeAnno("AIOOBE") ArrayIndexOutOfBoundsException { + return null; + } +} + +abstract class TestClassTypeVarAndField { + @TypeAnno("T1 field") @TypeAnno2("T2 field") T field1; + T field2; + @TypeAnno("Object field") Object field3; + + public @TypeAnno("t1") @TypeAnno2("t2") T foo(){ return null; } + public M foo2() {return null;} + public <@TypeAnno("K") K extends Cloneable> K foo3() {return null;} +} + +@Target(ElementType.TYPE_USE) +@Retention(RetentionPolicy.RUNTIME) +@interface TypeAnno { + String value(); +} + +@Target(ElementType.TYPE_USE) +@Retention(RetentionPolicy.RUNTIME) +@interface TypeAnno2 { + String value(); +} diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/TypeParamAnnotation.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/lang/annotation/TypeParamAnnotation.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8004698 + * @summary Unit test for annotations on TypeVariables + */ + +import java.util.*; +import java.lang.annotation.*; +import java.lang.reflect.*; +import java.io.Serializable; + +public class TypeParamAnnotation { + public static void main(String[] args) throws Exception { + testOnClass(); + testOnMethod(); + testGetAnno(); + testGetAnnos(); + } + + private static void check(boolean b) { + if (!b) + throw new RuntimeException(); + } + + private static void testOnClass() { + TypeVariable[] ts = TypeParam.class.getTypeParameters(); + check(ts.length == 3); + + Annotation[] as; + + as = ts[0].getAnnotations(); + check(as.length == 2); + check(((ParamAnno)as[0]).value().equals("t")); + check(((ParamAnno2)as[1]).value() == 1); + + as = ts[1].getAnnotations(); + check(as.length == 0); + + as = ts[2].getAnnotations(); + check(as.length == 2); + check(((ParamAnno)as[0]).value().equals("v")); + check(((ParamAnno2)as[1]).value() == 2); + } + private static void testOnMethod() throws Exception { + TypeVariable[] ts = TypeParam.class.getDeclaredMethod("foo").getTypeParameters(); + check(ts.length == 3); + + Annotation[] as; + + as = ts[0].getAnnotations(); + check(as.length == 2); + check(((ParamAnno)as[0]).value().equals("x")); + check(((ParamAnno2)as[1]).value() == 3); + + as = ts[1].getAnnotations(); + check(as.length == 0); + + as = ts[2].getAnnotations(); + check(as.length == 2); + check(((ParamAnno)as[0]).value().equals("z")); + check(((ParamAnno2)as[1]).value() == 4); + } + + private static void testGetAnno() { + TypeVariable[] ts = TypeParam.class.getTypeParameters(); + ParamAnno a; + a = ts[0].getAnnotation(ParamAnno.class); + check(a.value().equals("t")); + } + private static void testGetAnnos() throws Exception { + TypeVariable[] ts = TypeParam.class.getDeclaredMethod("foo").getTypeParameters(); + ParamAnno2[] as; + as = ts[0].getAnnotations(ParamAnno2.class); + check(as.length == 1); + check(as[0].value() == 3); + } +} + +class TypeParam <@ParamAnno("t") @ParamAnno2(1) T, + U, + @ParamAnno("v") @ParamAnno2(2) V extends Runnable> { + public <@ParamAnno("x") @ParamAnno2(3) X, + Y, + @ParamAnno("z") @ParamAnno2(4) Z extends Cloneable> void foo() {} +} + +@Target(ElementType.TYPE_PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@interface ParamAnno { + String value(); +} + +@Target(ElementType.TYPE_PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@interface ParamAnno2 { + int value(); +} diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/repeatingAnnotations/RepeatedUnitTest.java --- a/test/java/lang/annotation/repeatingAnnotations/RepeatedUnitTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/lang/annotation/repeatingAnnotations/RepeatedUnitTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 7154390 + * @bug 7154390 8005712 * @summary Unit test for repeated annotation reflection * * @compile RepeatedUnitTest.java subpackage/package-info.java subpackage/Container.java subpackage/Containee.java subpackage/NonRepeated.java subpackage/InheritedContainee.java subpackage/InheritedContainer.java subpackage/InheritedNonRepeated.java @@ -58,7 +58,7 @@ checkMultiplier(Me1.class.getField("foo"), 1); // METHOD - checkMultiplier(Me1.class.getDeclaredMethod("mee", null), 100); + checkMultiplier(Me1.class.getDeclaredMethod("mee", (Class[])null), 100); // INNER CLASS checkMultiplier(Me1.MiniMee.class, 1000); @@ -84,8 +84,7 @@ static void packageRepeated(AnnotatedElement e) { Containee c = e.getAnnotation(Containee.class); - check(c.value() == 1); - + check(c == null); check(2 == countAnnotation(e, Containee.class)); c = e.getAnnotations(Containee.class)[0]; @@ -93,7 +92,7 @@ c = e.getAnnotations(Containee.class)[1]; check(c.value() == 2); - check(2 == containsAnnotationOfType(e.getAnnotations(), Containee.class)); + check(0 == containsAnnotationOfType(e.getAnnotations(), Containee.class)); } static void packageContainer(AnnotatedElement e) { @@ -161,14 +160,26 @@ } static void checkMultiplier(AnnotatedElement e, int m) { + // Basic sanity of non-repeating getAnnotation(Class) check(e.getAnnotation(NonRepeated.class).value() == 5 * m); + // Check count of annotations returned from getAnnotations(Class) check(4 == countAnnotation(e, Containee.class)); check(1 == countAnnotation(e, Container.class)); check(1 == countAnnotation(e, NonRepeated.class)); + // Check contents of array returned from getAnnotations(Class) check(e.getAnnotations(Containee.class)[2].value() == 3 * m); check(e.getAnnotations(NonRepeated.class)[0].value() == 5 * m); + + // Check getAnnotation(Class) + check(e.getAnnotation(Containee.class) == null); + check(e.getAnnotation(Container.class) != null); + + // Check count of annotations returned from getAnnotations() + check(0 == containsAnnotationOfType(e.getAnnotations(), Containee.class)); + check(1 == containsAnnotationOfType(e.getAnnotations(), Container.class)); + check(1 == containsAnnotationOfType(e.getAnnotations(), NonRepeated.class)); } static void check(Boolean b) { diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/repeatingAnnotations/subpackage/Containee.java --- a/test/java/lang/annotation/repeatingAnnotations/subpackage/Containee.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/lang/annotation/repeatingAnnotations/subpackage/Containee.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * 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,7 +26,6 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) -@ContainedBy(Container.class) @Repeatable(Container.class) public @interface Containee { int value(); diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/repeatingAnnotations/subpackage/Container.java --- a/test/java/lang/annotation/repeatingAnnotations/subpackage/Container.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/lang/annotation/repeatingAnnotations/subpackage/Container.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * 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,7 +26,6 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) -@ContainerFor(Containee.class) public @interface Container { Containee[] value(); } diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainee.java --- a/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainee.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainee.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ @Inherited @Retention(RetentionPolicy.RUNTIME) -@ContainedBy(InheritedContainer.class) @Repeatable(InheritedContainer.class) public @interface InheritedContainee { int value(); diff -r a8bbd962f34a -r 41654275896d test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainer.java --- a/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainer.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/lang/annotation/repeatingAnnotations/subpackage/InheritedContainer.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ @Inherited @Retention(RetentionPolicy.RUNTIME) -@ContainerFor(InheritedContainee.class) public @interface InheritedContainer { InheritedContainee[] value(); } diff -r a8bbd962f34a -r 41654275896d test/java/lang/reflect/Parameter/WithoutParameters.java --- a/test/java/lang/reflect/Parameter/WithoutParameters.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/lang/reflect/Parameter/WithoutParameters.java Mon Feb 04 17:29:58 2013 -0400 @@ -23,163 +23,152 @@ /* * @test + * @bug 8004729 * @summary javac should generate method parameters correctly. */ import java.lang.*; import java.lang.reflect.*; +import java.lang.annotation.*; import java.util.List; +import java.util.Objects; + +import static java.lang.annotation.ElementType.*; public class WithoutParameters { + int errors = 0; - private static final Class[] qux_types = { - int.class, - Foo.class, - List.class, - List.class, - List.class, - String[].class - }; + private WithoutParameters() {} public static void main(String argv[]) throws Exception { - int error = 0; - Method[] methods = Foo.class.getMethods(); - for(Method m : methods) { - System.err.println("Inspecting method " + m); - Parameter[] parameters = m.getParameters(); - if(parameters == null) - throw new Exception("getParameters should never be null"); - for(int i = 0; i < parameters.length; i++) { - Parameter p = parameters[i]; - if(!p.getDeclaringExecutable().equals(m)) { - System.err.println(p + ".getDeclaringExecutable != " + m); - error++; - } - if(null == p.getType()) { - System.err.println(p + ".getType() == null"); - error++; - } - if(null == p.getParameterizedType()) { - System.err.println(p + ".getParameterizedType == null"); - error++; - } - } - if(m.getName().equals("qux")) { - if(6 != parameters.length) { - System.err.println("Wrong number of parameters for qux"); - error++; - } - for(int i = 0; i < parameters.length; i++) { - Parameter p = parameters[i]; - // The getType family work with or without - // parameter attributes compiled in. - if(!parameters[i].getType().equals(qux_types[i])) { - System.err.println("Wrong parameter type for " + parameters[0] + ": expected " + qux_types[i] + ", but got " + parameters[i].getType()); - error++; + WithoutParameters wp = new WithoutParameters(); + wp.runTests(Foo.class.getMethods()); + wp.runTests(Foo.Inner.class.getConstructors()); + wp.checkForErrors(); + } + + void runTests(Method[] methods) throws Exception { + for(Method m : methods) {runTest(m);} + } + + void runTests(Constructor[] constructors) throws Exception { + for(Constructor c : constructors) {runTest(c);} + } + + void runTest(Executable e) throws Exception { + System.err.println("Inspecting executable " + e); + Parameter[] parameters = e.getParameters(); + Objects.requireNonNull(parameters, "getParameters should never be null"); + + ExpectedParameterInfo epi = e.getAnnotation(ExpectedParameterInfo.class); + if (epi != null) { + abortIfTrue(epi.parameterCount() != e.getParameterCount(), "Bad parameter count for "+ e); + abortIfTrue(epi.isVarArgs() != e.isVarArgs(),"Bad varargs value for "+ e); + } + abortIfTrue(e.getParameterCount() != parameters.length, "Mismatched of parameter counts."); + + for(int i = 0; i < parameters.length; i++) { + Parameter p = parameters[i]; + errorIfTrue(!p.getDeclaringExecutable().equals(e), p + ".getDeclaringExecutable != " + e); + Objects.requireNonNull(p.getType(), "getType() should not be null"); + Objects.requireNonNull(p.getParameterizedType(), "getParameterizedType() should not be null"); + + if (epi != null) { + Class expectedParameterType = epi.parameterTypes()[i]; + errorIfTrue(!p.getType().equals(expectedParameterType), + "Wrong parameter type for " + p + ": expected " + expectedParameterType + + ", but got " + p.getType()); + + ParameterizedInfo[] expectedParameterizedTypes = epi.parameterizedTypes(); + if (expectedParameterizedTypes.length > 0) { + Type parameterizedType = p.getParameterizedType(); + Class expectedParameterziedTypeType = expectedParameterizedTypes[i].value(); + errorIfTrue(!expectedParameterziedTypeType.isAssignableFrom(parameterizedType.getClass()), + "Wrong class of parameteried type of " + p + ": expected " + expectedParameterziedTypeType + + ", but got " + parameterizedType.getClass()); + + if (expectedParameterziedTypeType.equals(Class.class)) { + errorIfTrue(!parameterizedType.equals(expectedParameterType), + "Wrong parameteried type for " + p + ": expected " + expectedParameterType + + ", but got " + parameterizedType); + } else { + if (expectedParameterziedTypeType.equals(ParameterizedType.class)) { + ParameterizedType ptype = (ParameterizedType)parameterizedType; + errorIfTrue(!ptype.getRawType().equals(expectedParameterType), + "Wrong raw type for " + p + ": expected " + expectedParameterType + + ", but got " + ptype.getRawType()); + } + + // Check string representation + String expectedStringOfType = epi.parameterizedTypes()[i].string(); + errorIfTrue(!expectedStringOfType.equals(parameterizedType.toString()), + "Bad type string" + p + ": expected " + expectedStringOfType + + ", but got " + parameterizedType.toString()); } } - if(!parameters[0].getParameterizedType().equals(int.class)) { - System.err.println("getParameterizedType for quux is wrong"); - error++; - } - if(!parameters[1].getParameterizedType().equals(Foo.class)) { - System.err.println("getParameterizedType for quux is wrong"); - error++; - } - if(!(parameters[2].getParameterizedType() instanceof - ParameterizedType)) { - System.err.println("getParameterizedType for l is wrong"); - error++; - } else { - ParameterizedType pt = - (ParameterizedType) parameters[2].getParameterizedType(); - if(!pt.getRawType().equals(List.class)) { - System.err.println("Raw type for l is wrong"); - error++; - } - if(1 != pt.getActualTypeArguments().length) { - System.err.println("Number of type parameters for l is wrong"); - error++; - } - if(!(pt.getActualTypeArguments()[0] instanceof WildcardType)) { - System.err.println("Type parameter for l is wrong"); - error++; - } - } - if(!(parameters[3].getParameterizedType() instanceof - ParameterizedType)) { - System.err.println("getParameterizedType for l2 is wrong"); - error++; - } else { - ParameterizedType pt = - (ParameterizedType) parameters[3].getParameterizedType(); - if(!pt.getRawType().equals(List.class)) { - System.err.println("Raw type for l2 is wrong"); - error++; - } - if(1 != pt.getActualTypeArguments().length) { - System.err.println("Number of type parameters for l2 is wrong"); - error++; - } - if(!(pt.getActualTypeArguments()[0].equals(Foo.class))) { - System.err.println("Type parameter for l2 is wrong"); - error++; - } - } - if(!(parameters[4].getParameterizedType() instanceof - ParameterizedType)) { - System.err.println("getParameterizedType for l3 is wrong"); - error++; - } else { - ParameterizedType pt = - (ParameterizedType) parameters[4].getParameterizedType(); - if(!pt.getRawType().equals(List.class)) { - System.err.println("Raw type for l3 is wrong"); - error++; - } - if(1 != pt.getActualTypeArguments().length) { - System.err.println("Number of type parameters for l3 is wrong"); - error++; - } - if(!(pt.getActualTypeArguments()[0] instanceof WildcardType)) { - System.err.println("Type parameter for l3 is wrong"); - error++; - } else { - WildcardType wt = (WildcardType) - pt.getActualTypeArguments()[0]; - if(!wt.getUpperBounds()[0].equals(Foo.class)) { - System.err.println("Upper bounds on type parameter fol l3 is wrong"); - error++; - } - } - } - if(!parameters[5].isVarArgs()) { - System.err.println("isVarArg for rest is wrong"); - error++; - } - if(!(parameters[5].getParameterizedType().equals(String[].class))) { - System.err.println("getParameterizedType for rest is wrong"); - error++; - } - } } - if(0 != error) - throw new Exception("Failed " + error + " tests"); + } + + private void checkForErrors() { + if (errors > 0) + throw new RuntimeException("Failed " + errors + " tests"); + } + + private void errorIfTrue(boolean predicate, String errMessage) { + if (predicate) { + errors++; + System.err.println(errMessage); + } + } + + private void abortIfTrue(boolean predicate, String errMessage) { + if (predicate) { + throw new RuntimeException(errMessage); + } + } + + @Retention(RetentionPolicy.RUNTIME) + @Target({METHOD, CONSTRUCTOR}) + @interface ExpectedParameterInfo { + int parameterCount() default 0; + Class[] parameterTypes() default {}; + ParameterizedInfo[] parameterizedTypes() default {}; + boolean isVarArgs() default false; + } + + @Target({}) + @interface ParameterizedInfo { + Class value() default Class.class; + String string() default ""; } public class Foo { int thing; + @ExpectedParameterInfo(parameterCount = 6, + parameterTypes = + {int.class, Foo.class, + List.class, List.class, + List.class, String[].class}, + parameterizedTypes = + {@ParameterizedInfo(Class.class), + @ParameterizedInfo(Class.class), + @ParameterizedInfo(value=ParameterizedType.class, string="java.util.List"), + @ParameterizedInfo(value=ParameterizedType.class, string="java.util.List"), + @ParameterizedInfo(value=ParameterizedType.class, string="java.util.List"), + @ParameterizedInfo(Class.class)}, + isVarArgs = true) public void qux(int quux, Foo quuux, List l, List l2, List l3, String... rest) {} public class Inner { int thang; + @ExpectedParameterInfo(parameterCount = 2, + parameterTypes = {Foo.class, int.class}) public Inner(int theng) { thang = theng + thing; } } } - } diff -r a8bbd962f34a -r 41654275896d test/java/net/Socket/asyncClose/Race.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/Socket/asyncClose/Race.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8006395 + * @summary Race in async socket close on Linux + */ + +import java.io.InputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.util.concurrent.Phaser; + +// Racey test, will not always fail, but if it does then we have a problem. + +public class Race { + final static int THREADS = 100; + + public static void main(String[] args) throws Exception { + try (ServerSocket ss = new ServerSocket(0)) { + final int port = ss.getLocalPort(); + final Phaser phaser = new Phaser(THREADS + 1); + for (int i=0; i<100; i++) { + final Socket s = new Socket("localhost", port); + s.setSoLinger(false, 0); + try (Socket sa = ss.accept()) { + sa.setSoLinger(false, 0); + final InputStream is = s.getInputStream(); + Thread[] threads = new Thread[THREADS]; + for (int j=0; j 0 && args[0] != null) { - urls = args[0]; - } + List entries = new ArrayList<>(); + entries.addAll(Arrays.asList(fileURLs)); + entries.addAll(Arrays.asList(jarURLs)); + entries.addAll(Arrays.asList(normalHttpURLs)); + entries.addAll(Arrays.asList(abnormalHttpURLs)); + if (hasFtp()) + entries.addAll(Arrays.asList(ftpURLs)); + URL url; - File f = new File(urls); - InputStream file = new FileInputStream(f); - BufferedReader in = new BufferedReader(new InputStreamReader(file)); - while(true) { - String context = in.readLine(); - if (context == null) { - break; - } - context = getValue(context); - String spec = getValue(in.readLine()); - String expected = getValue(in.readLine()); + for (Entry e : entries) { + if (e.context == null) + url = new URL(e.spec); + else + url = new URL(new URL(e.context), e.spec); - if (context.equals("null")) { - url = new URL(spec); - } else { - url = new URL(new URL(context), spec); - } - if (!(url.toString().equals(expected))) { - throw new RuntimeException("error for: \n\tURL:" + context + - "\n\tspec: " + spec + - "\n\texpected: " + expected + + if (!(url.toString().equals(e.expected))) { + throw new RuntimeException("error for: \n\tURL:" + e.context + + "\n\tspec: " + e.spec + + "\n\texpected: " + e.expected + "\n\tactual: " + url.toString()); } else { - System.out.println("success for: " + url + "\n"); + //debug + //System.out.println("success for: " + url); } - in.readLine(); + } + } + + private static boolean hasFtp() { + try { + return new java.net.URL("ftp://") != null; + } catch (java.net.MalformedURLException x) { + System.out.println("FTP not supported by this runtime."); + return false; } - in.close(); + } + + static class Entry { + final String context; + final String spec; + final String expected; + Entry(String context, String spec, String expected) { + this.context = context; + this.spec =spec; + this.expected = expected; + } } - private static String getValue(String value) { - return value.substring(value.indexOf(':') + 2); - } + static Entry[] fileURLs = new Entry[] { + new Entry(null, + "file://JavaSoft/Test", + "file://JavaSoft/Test"), + new Entry(null, + "file:///JavaSoft/Test", + "file:/JavaSoft/Test"), + new Entry(null, + "file:/JavaSoft/Test", + "file:/JavaSoft/Test"), + new Entry(null, + "file:/c:/JavaSoft/Test", + "file:/c:/JavaSoft/Test"), + new Entry(null, + "file:/c:/JavaSoft/Test:something", + "file:/c:/JavaSoft/Test:something"), + new Entry(null, + "file:/c:/JavaSoft/Test#anchor", + "file:/c:/JavaSoft/Test#anchor"), + new Entry("file://JavaSoft/Test", + "Test#bar", + "file://JavaSoft/Test#bar"), + new Entry("file://codrus/c:/jdk/eng/index.html", + "pulsar.html", + "file://codrus/c:/jdk/eng/pulsar.html"), + new Entry("file:///c:/jdk/eng/index.html", + "pulsar.html", + "file:/c:/jdk/eng/pulsar.html"), + new Entry("file:///jdk/eng/index.html", + "pulsar.html", + "file:/jdk/eng/pulsar.html"), + new Entry("file://JavaSoft/Test", + "file://radartoad.com/Test#bar", + "file://radartoad.com/Test#bar"), + new Entry("file://JavaSoft/Test", + "/c:/Test#bar", + "file://JavaSoft/c:/Test#bar"), + }; + + static Entry[] jarURLs = new Entry[] { + new Entry(null, + "jar:http://www.foo.com/dir1/jar.jar!/dir2/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir2/entry.txt"), + new Entry(null, + "jar:http://www.foo.com/dir1/jar.jar!/", + "jar:http://www.foo.com/dir1/jar.jar!/"), + new Entry(null, + "jar:http://www.foo.com/dir1/jar.jar!/", + "jar:http://www.foo.com/dir1/jar.jar!/"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "dir1/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "/dir1/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/dir1/", + "entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/dir2/dir3/entry2.txt", + "/dir1/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "/dir1/foo/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/foo/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/dir1/dir2/dir3/", + "dir4/foo/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/dir2/dir3/dir4/foo/entry.txt"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/", + "/dir1/foo/entry.txt", + "jar:http://www.foo.com/dir1/jar.jar!/dir1/foo/entry.txt"), + new Entry(null, + "jar:http://www.foo.com/dir1/jar.jar!/foo.txt#anchor", + "jar:http://www.foo.com/dir1/jar.jar!/foo.txt#anchor"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/foo.txt", + "#anchor", + "jar:http://www.foo.com/dir1/jar.jar!/foo.txt#anchor"), + new Entry("jar:http://www.foo.com/dir1/jar.jar!/foo/bar/", + "baz/quux#anchor", + "jar:http://www.foo.com/dir1/jar.jar!/foo/bar/baz/quux#anchor"), + new Entry("jar:http://balloo.com/olle.jar!/", + "p2", + "jar:http://balloo.com/olle.jar!/p2") + }; + + static Entry[] normalHttpURLs = new Entry[] { + new Entry("http://a/b/c/d;p?q", "g", "http://a/b/c/g"), + new Entry("http://a/b/c/d;p?q", "./g", "http://a/b/c/g"), + new Entry("http://a/b/c/d;p?q", "g/", "http://a/b/c/g/"), + new Entry("http://a/b/c/d;p?q", "/g", "http://a/g"), + new Entry("http://a/b/c/d;p?q", "//g", "http://g"), + new Entry("http://a/b/c/d;p?q", "?y", "http://a/b/c/?y"), + new Entry("http://a/b/c/d;p?q", "g?y", "http://a/b/c/g?y"), + new Entry("http://a/b/c/d;p?q", "g#s", "http://a/b/c/g#s"), + new Entry("http://a/b/c/d;p?q", "g?y#s", "http://a/b/c/g?y#s"), + new Entry("http://a/b/c/d;p?q", ";x", "http://a/b/c/;x"), + new Entry("http://a/b/c/d;p?q", "g;x", "http://a/b/c/g;x"), + new Entry("http://a/b/c/d;p?q", "g;x?y#s", "http://a/b/c/g;x?y#s"), + new Entry("http://a/b/c/d;p?q", ".", "http://a/b/c/"), + new Entry("http://a/b/c/d;p?q", "./", "http://a/b/c/"), + new Entry("http://a/b/c/d;p?q", "..", "http://a/b/"), + new Entry("http://a/b/c/d;p?q", "../", "http://a/b/"), + new Entry("http://a/b/c/d;p?q", "../g", "http://a/b/g"), + new Entry("http://a/b/c/d;p?q", "../..", "http://a/"), + new Entry("http://a/b/c/d;p?q", "../../", "http://a/"), + new Entry("http://a/b/c/d;p?q", "../../g", "http://a/g"), + new Entry(null, + "http://www.javasoft.com/jdc/community/chat/index.html#javalive?frontpage-jdc", + "http://www.javasoft.com/jdc/community/chat/index.html#javalive?frontpage-jdc") + }; + + static Entry[] abnormalHttpURLs = new Entry[] { + new Entry("http://a/b/c/d;p?q", "../../../g", "http://a/../g"), + new Entry("http://a/b/c/d;p?q", "../../../../g", "http://a/../../g"), + new Entry("http://a/b/c/d;p?q", "/./g", "http://a/./g"), + new Entry("http://a/b/c/d;p?q", "/../g", "http://a/../g"), + new Entry("http://a/b/c/d;p?q", ".g", "http://a/b/c/.g"), + new Entry("http://a/b/c/d;p?q", "g.", "http://a/b/c/g."), + new Entry("http://a/b/c/d;p?q", "./../g", "http://a/b/g"), + new Entry("http://a/b/c/d;p?q", "./g/.", "http://a/b/c/g/"), + new Entry("http://a/b/c/d;p?q", "g/./h", "http://a/b/c/g/h"), + new Entry("http://a/b/c/d;p?q", "g;x=1/./y", "http://a/b/c/g;x=1/y"), + new Entry("http://a/b/c/d;p?q", "g;x=1/../y", "http://a/b/c/y") + }; + + static Entry[] ftpURLs = new Entry[] { + new Entry(null, + "ftp://ftp.foo.com/dir1/entry.txt", + "ftp://ftp.foo.com/dir1/entry.txt"), + new Entry(null, + "ftp://br:pwd@ftp.foo.com/dir1/jar.jar", + "ftp://br:pwd@ftp.foo.com/dir1/jar.jar"), + new Entry("ftp://ftp.foo.com/dir1/foo.txt", + "bar.txt", + "ftp://ftp.foo.com/dir1/bar.txt"), + new Entry("ftp://ftp.foo.com/dir1/jar.jar", + "/entry.txt", + "ftp://ftp.foo.com/entry.txt"), + new Entry("ftp://ftp.foo.com/dir1/jar.jar", + "dir1/entry.txt", + "ftp://ftp.foo.com/dir1/dir1/entry.txt"), + new Entry("ftp://ftp.foo.com/dir1/jar.jar", + "/dir1/entry.txt", + "ftp://ftp.foo.com/dir1/entry.txt"), + new Entry("ftp://br:pwd@ftp.foo.com/dir1/jar.jar", + "/dir1/entry.txt", + "ftp://br:pwd@ftp.foo.com/dir1/entry.txt") + }; } diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/HandlerLoop.java --- a/test/java/net/URL/HandlerLoop.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/net/URL/HandlerLoop.java Mon Feb 04 17:29:58 2013 -0400 @@ -36,7 +36,7 @@ public static void main(String args[]) throws Exception { URL.setURLStreamHandlerFactory( new HandlerFactory("sun.net.www.protocol")); - URL url = new URL("file://bogus/index.html"); + URL url = new URL("file:///bogus/index.html"); System.out.println("url = " + url); url.openConnection(); } diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/Test.java --- a/test/java/net/URL/Test.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/net/URL/Test.java Mon Feb 04 17:29:58 2013 -0400 @@ -310,7 +310,14 @@ throw new RuntimeException("Test failed"); } - + private static boolean hasFtp() { + try { + return new java.net.URL("ftp://") != null; + } catch (java.net.MalformedURLException x) { + System.out.println("FTP not supported by this runtime."); + return false; + } + } // -- Tests -- @@ -319,8 +326,9 @@ header("RFC2396: Basic examples"); - test("ftp://ftp.is.co.za/rfc/rfc1808.txt") - .s("ftp").h("ftp.is.co.za").p("/rfc/rfc1808.txt").z(); + if (hasFtp()) + test("ftp://ftp.is.co.za/rfc/rfc1808.txt") + .s("ftp").h("ftp.is.co.za").p("/rfc/rfc1808.txt").z(); test("http://www.math.uio.no/faq/compression-faq/part1.html") .s("http").h("www.math.uio.no").p("/faq/compression-faq/part1.html").z(); @@ -328,8 +336,9 @@ test("http://www.w3.org/Addressing/") .s("http").h("www.w3.org").p("/Addressing/").z(); - test("ftp://ds.internic.net/rfc/") - .s("ftp").h("ds.internic.net").p("/rfc/").z(); + if (hasFtp()) + test("ftp://ds.internic.net/rfc/") + .s("ftp").h("ds.internic.net").p("/rfc/").z(); test("http://www.ics.uci.edu/pub/ietf/url/historical.html#WARNING") .s("http").h("www.ics.uci.edu").p("/pub/ietf/url/historical.html") diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/URIToURLTest.java --- a/test/java/net/URL/URIToURLTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/net/URL/URIToURLTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -28,20 +28,22 @@ */ import java.net.*; +import java.util.ArrayList; +import java.util.List; public class URIToURLTest { public static void main(String args[]) throws Exception { - String[] uris = { - "http://jag:cafebabe@java.sun.com:94/b/c/d?q#g", - "http://[1080:0:0:0:8:800:200C:417A]/index.html", - "http://a/b/c/d;p?q", - "ftp://ftp.is.co.za/rfc/rfc1808.txt", - "mailto:mduerst@ifi.unizh.ch", // opaque url - "http:comp.infosystems.www.servers.unix" //opaque url - }; + List uris = new ArrayList<>(); + uris.add("http://jag:cafebabe@java.sun.com:94/b/c/d?q#g"); + uris.add("http://[1080:0:0:0:8:800:200C:417A]/index.html"); + uris.add("http://a/b/c/d;p?q"); + uris.add("mailto:mduerst@ifi.unizh.ch"); + uris.add("http:comp.infosystems.www.servers.unix"); + if (hasFtp()) + uris.add("ftp://ftp.is.co.za/rfc/rfc1808.txt"); - for (int i = 0; i < uris.length; i++) { - URI uri = new URI(uris[i]); + for (String uriStr : uris) { + URI uri = new URI(uriStr); URL url = uri.toURL(); String scheme = uri.getScheme(); boolean schemeCheck = scheme == null? url.getProtocol() == null : @@ -111,4 +113,13 @@ url.getRef()); } } + + private static boolean hasFtp() { + try { + return new java.net.URL("ftp://") != null; + } catch (java.net.MalformedURLException x) { + System.out.println("FTP not supported by this runtime."); + return false; + } + } } diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/abnormal_http_urls --- a/test/java/net/URL/abnormal_http_urls Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -URL: http://a/b/c/d;p?q -spec: ../../../g -expected: http://a/../g - -URL: http://a/b/c/d;p?q -spec: ../../../../g -expected: http://a/../../g - -URL: http://a/b/c/d;p?q -spec: /./g -expected: http://a/./g - -URL: http://a/b/c/d;p?q -spec: /../g -expected: http://a/../g - -URL: http://a/b/c/d;p?q -spec: .g -expected: http://a/b/c/.g - -URL: http://a/b/c/d;p?q -spec: g. -expected: http://a/b/c/g. - -URL: http://a/b/c/d;p?q -spec: ./../g -expected: http://a/b/g - -URL: http://a/b/c/d;p?q -spec: ./g/. -expected: http://a/b/c/g/ - -URL: http://a/b/c/d;p?q -spec: g/./h -expected: http://a/b/c/g/h - -URL: http://a/b/c/d;p?q -spec: g;x=1/./y -expected: http://a/b/c/g;x=1/y - -URL: http://a/b/c/d;p?q -spec: g;x=1/../y -expected: http://a/b/c/y diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/ftp_urls --- a/test/java/net/URL/ftp_urls Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -URL: null -spec: ftp://ftp.foo.com/dir1/entry.txt -expected: ftp://ftp.foo.com/dir1/entry.txt - -URL: null -spec: ftp://br:pwd@ftp.foo.com/dir1/jar.jar -expected: ftp://br:pwd@ftp.foo.com/dir1/jar.jar - -URL: ftp://ftp.foo.com/dir1/foo.txt -spec: bar.txt -expected: ftp://ftp.foo.com/dir1/bar.txt - -URL: ftp://ftp.foo.com/dir1/jar.jar -spec: /entry.txt -expected: ftp://ftp.foo.com/entry.txt - -URL: ftp://ftp.foo.com/dir1/jar.jar -spec: dir1/entry.txt -expected: ftp://ftp.foo.com/dir1/dir1/entry.txt - -URL: ftp://ftp.foo.com/dir1/jar.jar -spec: /dir1/entry.txt -expected: ftp://ftp.foo.com/dir1/entry.txt - -URL: ftp://br:pwd@ftp.foo.com/dir1/jar.jar -spec: /dir1/entry.txt -expected: ftp://br:pwd@ftp.foo.com/dir1/entry.txt diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/jar_urls --- a/test/java/net/URL/jar_urls Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -URL: null -spec: jar:http://www.foo.com/dir1/jar.jar!/dir2/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir2/entry.txt - -URL: null -spec: jar:http://www.foo.com/dir1/jar.jar!/ -expected: jar:http://www.foo.com/dir1/jar.jar!/ - -URL: null -spec: jar:http://www.foo.com/dir1/jar.jar!/ -expected: jar:http://www.foo.com/dir1/jar.jar!/ - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: /entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: dir1/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: /dir1/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: /entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: /entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/dir1/ -spec: entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/dir2/dir3/entry2.txt -spec: /dir1/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: /dir1/foo/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/foo/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/dir1/dir2/dir3/ -spec: dir4/foo/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/dir2/dir3/dir4/foo/entry.txt - -URL: jar:http://www.foo.com/dir1/jar.jar!/ -spec: /dir1/foo/entry.txt -expected: jar:http://www.foo.com/dir1/jar.jar!/dir1/foo/entry.txt - -URL: null -spec: jar:http://www.foo.com/dir1/jar.jar!/foo.txt#anchor -expected: jar:http://www.foo.com/dir1/jar.jar!/foo.txt#anchor - -URL: jar:http://www.foo.com/dir1/jar.jar!/foo.txt -spec: #anchor -expected: jar:http://www.foo.com/dir1/jar.jar!/foo.txt#anchor - -URL: jar:http://www.foo.com/dir1/jar.jar!/foo/bar/ -spec: baz/quux#anchor -expected: jar:http://www.foo.com/dir1/jar.jar!/foo/bar/baz/quux#anchor - -URL: jar:http://balloo.com/olle.jar!/ -spec: p2 -expected: jar:http://balloo.com/olle.jar!/p2 diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/normal_http_urls --- a/test/java/net/URL/normal_http_urls Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -URL: http://a/b/c/d;p?q -spec: g -expected: http://a/b/c/g - -URL: http://a/b/c/d;p?q -spec: ./g -expected: http://a/b/c/g - -URL: http://a/b/c/d;p?q -spec: g/ -expected: http://a/b/c/g/ - -URL: http://a/b/c/d;p?q -spec: /g -expected: http://a/g - -URL: http://a/b/c/d;p?q -spec: //g -expected: http://g - -URL: http://a/b/c/d;p?q -spec: ?y -expected: http://a/b/c/?y - -URL: http://a/b/c/d;p?q -spec: g?y -expected: http://a/b/c/g?y - -URL: http://a/b/c/d;p?q -spec: g#s -expected: http://a/b/c/g#s - -URL: http://a/b/c/d;p?q -spec: g?y#s -expected: http://a/b/c/g?y#s - -URL: http://a/b/c/d;p?q -spec: ;x -expected: http://a/b/c/;x - -URL: http://a/b/c/d;p?q -spec: g;x -expected: http://a/b/c/g;x - -URL: http://a/b/c/d;p?q -spec: g;x?y#s -expected: http://a/b/c/g;x?y#s - -URL: http://a/b/c/d;p?q -spec: . -expected: http://a/b/c/ - -URL: http://a/b/c/d;p?q -spec: ./ -expected: http://a/b/c/ - -URL: http://a/b/c/d;p?q -spec: .. -expected: http://a/b/ - -URL: http://a/b/c/d;p?q -spec: ../ -expected: http://a/b/ - -URL: http://a/b/c/d;p?q -spec: ../g -expected: http://a/b/g - -URL: http://a/b/c/d;p?q -spec: ../.. -expected: http://a/ - -URL: http://a/b/c/d;p?q -spec: ../../ -expected: http://a/ - -URL: http://a/b/c/d;p?q -spec: ../../g -expected: http://a/g - -URL: null -spec: http://www.javasoft.com/jdc/community/chat/index.html#javalive?frontpage-jdc -expected: http://www.javasoft.com/jdc/community/chat/index.html#javalive?frontpage-jdc diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/runconstructor.sh --- a/test/java/net/URL/runconstructor.sh Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -# -# 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 -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4393671 -# @summary URL constructor URL(URL context, String spec) FAILED with specific input in merlin -# -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - PS=":" - FS="/" - ;; - CYGWIN* ) - PS=";" - FS="/" - ;; - Windows* ) - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac -${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \ - ${TESTSRC}${FS}Constructor.java - -failures=0 - -go() { - echo '' - ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} Constructor $1 - if [ $? != 0 ]; then failures=`expr $failures + 1`; fi -} - -go ${TESTSRC}${FS}share_file_urls -go ${TESTSRC}${FS}jar_urls -go ${TESTSRC}${FS}normal_http_urls -go ${TESTSRC}${FS}ftp_urls -go ${TESTSRC}${FS}abnormal_http_urls - -if [ "$failures" != "0" ]; then - echo $failures tests failed - exit 1; -fi diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/share_file_urls --- a/test/java/net/URL/share_file_urls Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -URL: null -spec: file://JavaSoft/Test -expected: file://JavaSoft/Test - -URL: null -spec: file:///JavaSoft/Test -expected: file:/JavaSoft/Test - -URL: null -spec: file:/JavaSoft/Test -expected: file:/JavaSoft/Test - -URL: null -spec: file:/c:/JavaSoft/Test -expected: file:/c:/JavaSoft/Test - -URL: null -spec: file:/c:/JavaSoft/Test:something -expected: file:/c:/JavaSoft/Test:something - -URL: null -spec: file:/c:/JavaSoft/Test#anchor -expected: file:/c:/JavaSoft/Test#anchor - -URL: null -spec: file:/JavaSoft/Test -expected: file:/JavaSoft/Test - -URL: file://JavaSoft/Test -spec: Test#bar -expected: file://JavaSoft/Test#bar - -URL: file://codrus/c:/jdk/eng/index.html -spec: pulsar.html -expected: file://codrus/c:/jdk/eng/pulsar.html - -URL: file:///c:/jdk/eng/index.html -spec: pulsar.html -expected: file:/c:/jdk/eng/pulsar.html - -URL: file:///jdk/eng/index.html -spec: pulsar.html -expected: file:/jdk/eng/pulsar.html - -URL: file://JavaSoft/Test -spec: file://radartoad.com/Test#bar -expected: file://radartoad.com/Test#bar - -URL: file://JavaSoft/Test -spec: /c:/Test#bar -expected: file://JavaSoft/c:/Test#bar \ No newline at end of file diff -r a8bbd962f34a -r 41654275896d test/java/net/URL/win32_file_urls --- a/test/java/net/URL/win32_file_urls Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -URL: null -spec: file://c:\JavaSoft\Test -expected: file://c:/JavaSoft/Test - -URL: null -spec: file:/c:\JavaSoft\Test -expected: file:/c:/JavaSoft/Test - -URL: null -spec: file:/c:\JavaSoft\Test:something#anchor -expected: file:/c:/JavaSoft/Test:something#anchor - -URL: file:///c:\jdk\eng\index.html -spec: pulsar.html -expected: file:/c:/jdk/eng/pulsar.html \ No newline at end of file diff -r a8bbd962f34a -r 41654275896d test/java/net/URLConnection/RequestProperties.java --- a/test/java/net/URLConnection/RequestProperties.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/net/URLConnection/RequestProperties.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,90 +28,55 @@ */ import java.net.*; +import java.util.ArrayList; +import java.util.List; public class RequestProperties { + static int failed; + public static void main (String args[]) throws Exception { - URL url0 = new URL ("http://foo.com/bar/"); - URL url1 = new URL ("file:/etc/passwd"); - URL url2 = new URL ("ftp://foo:bar@foobar.com/etc/passwd"); - URL url3 = new URL ("jar:http://foo.com/bar.html!/foo/bar"); - URLConnection urlc0 = url0.openConnection (); - URLConnection urlc1 = url1.openConnection (); - URLConnection urlc2 = url2.openConnection (); - URLConnection urlc3 = url3.openConnection (); - int count = 0; - String s = null; - try { - urlc0.setRequestProperty (null, null); - System.out.println ("http: setRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } + List urls = new ArrayList<>(); + urls.add("http://foo.com/bar/"); + urls.add("jar:http://foo.com/bar.html!/foo/bar"); + urls.add("file:/etc/passwd"); + if (hasFtp()) + urls.add("ftp://foo:bar@foobar.com/etc/passwd"); + + for (String urlStr : urls) + test(new URL(urlStr)); + + if (failed != 0) + throw new RuntimeException(failed + " errors") ; + } + + static void test(URL url) throws Exception { + URLConnection urlc = url.openConnection(); try { - urlc0.addRequestProperty (null, null); - System.out.println ("http: addRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } + urlc.setRequestProperty(null, null); + System.out.println(url.getProtocol() + + ": setRequestProperty(null,) did not throw NPE"); + failed++; + } catch (NullPointerException e) { /* Expected */ } try { - urlc1.setRequestProperty (null, null); - System.out.println ("file: setRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } - try { - urlc1.addRequestProperty (null, null); - System.out.println ("file: addRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } - try { - urlc2.setRequestProperty (null, null); - System.out.println ("ftp: setRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; + urlc.addRequestProperty(null, null); + System.out.println(url.getProtocol() + + ": addRequestProperty(null,) did not throw NPE"); + failed++; + } catch (NullPointerException e) { /* Expected */ } + + if (urlc.getRequestProperty(null) != null) { + System.out.println(url.getProtocol() + + ": getRequestProperty(null,) did not return null"); + failed++; } - try { - urlc2.addRequestProperty (null, null); - System.out.println ("ftp: addRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } - try { - urlc3.setRequestProperty (null, null); - System.out.println ("jar: setRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } + } + + private static boolean hasFtp() { try { - urlc3.addRequestProperty (null, null); - System.out.println ("jar: addRequestProperty (null,) did not throw NPE"); - } catch (NullPointerException e) { - count ++; - } - if (urlc0.getRequestProperty (null) != null) { - System.out.println ("http: getRequestProperty (null,) did not return null"); - } else { - count ++; - } - if (urlc1.getRequestProperty (null) != null) { - System.out.println ("file: getRequestProperty (null,) did not return null"); - } else { - count ++; - } - if (urlc2.getRequestProperty (null) != null) { - System.out.println ("ftp: getRequestProperty (null,) did not return null"); - } else { - count ++; - } - if (urlc2.getRequestProperty (null) != null) { - System.out.println ("jar: getRequestProperty (null,) did not return null"); - } else { - count ++; - } - - if (count != 12) { - throw new RuntimeException ((12 -count) + " errors") ; + return new java.net.URL("ftp://") != null; + } catch (java.net.MalformedURLException x) { + System.out.println("FTP not supported by this runtime."); + return false; } } } diff -r a8bbd962f34a -r 41654275896d test/java/net/URLConnection/RequestPropertyValues.java --- a/test/java/net/URLConnection/RequestPropertyValues.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/net/URLConnection/RequestPropertyValues.java Mon Feb 04 17:29:58 2013 -0400 @@ -27,8 +27,11 @@ * @summary Test URLConnection Request Proterties */ +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; /** * Part1: @@ -45,28 +48,29 @@ } public static void part1() throws Exception { - URL[] urls = { new URL("http://localhost:8088"), - new URL("file:/etc/passwd"), - new URL("ftp://foo:bar@foobar.com/etc/passwd"), - new URL("jar:http://foo.com/bar.html!/foo/bar") - }; + List urls = new ArrayList<>(); + urls.add(new URL("http://localhost:8088")); + urls.add(new URL("file:/etc/passwd")); + urls.add(new URL("jar:http://foo.com/bar.html!/foo/bar")); + if (hasFtp()) + urls.add(new URL("ftp://foo:bar@foobar.com/etc/passwd")); boolean failed = false; - for (int proto = 0; proto < urls.length; proto++) { - URLConnection uc = (URLConnection) urls[proto].openConnection(); + for (URL url : urls) { + URLConnection uc = url.openConnection(); try { uc.setRequestProperty("TestHeader", null); } catch (NullPointerException npe) { System.out.println("setRequestProperty is throwing NPE" + - " for url: " + urls[proto]); + " for url: " + url); failed = true; } try { uc.addRequestProperty("TestHeader", null); } catch (NullPointerException npe) { System.out.println("addRequestProperty is throwing NPE" + - " for url: " + urls[proto]); + " for url: " + url); failed = true; } } @@ -110,4 +114,12 @@ } } + private static boolean hasFtp() { + try { + return new java.net.URL("ftp://") != null; + } catch (java.net.MalformedURLException x) { + System.out.println("FTP not supported by this runtime."); + return false; + } + } } diff -r a8bbd962f34a -r 41654275896d test/java/security/KeyStore/PBETest.java --- a/test/java/security/KeyStore/PBETest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/security/KeyStore/PBETest.java Mon Feb 04 17:29:58 2013 -0400 @@ -58,45 +58,46 @@ new File(NEW_KEYSTORE).delete(); - try { - KeyStore keystore = load(KEYSTORE_TYPE, KEYSTORE, PASSWORD); - KeyStore.Entry entry = - keystore.getEntry(ALIAS, - new KeyStore.PasswordProtection(PASSWORD)); - System.out.println("Retrieved entry named '" + ALIAS + "'"); + KeyStore keystore = load(KEYSTORE_TYPE, KEYSTORE, PASSWORD); + KeyStore.Entry entry = + keystore.getEntry(ALIAS, + new KeyStore.PasswordProtection(PASSWORD)); + System.out.println("Retrieved entry named '" + ALIAS + "'"); - // Set entry - KeyStore keystore2 = load(NEW_KEYSTORE_TYPE, null, null); - keystore2.setEntry(ALIAS, entry, - new KeyStore.PasswordProtection(PASSWORD, PBE_ALGO, - new PBEParameterSpec(SALT, ITERATION_COUNT, - new IvParameterSpec(IV)))); - System.out.println("Encrypted entry using: " + PBE_ALGO); + // Set entry + KeyStore keystore2 = load(NEW_KEYSTORE_TYPE, null, null); + keystore2.setEntry(ALIAS, entry, + new KeyStore.PasswordProtection(PASSWORD, PBE_ALGO, + new PBEParameterSpec(SALT, ITERATION_COUNT, + new IvParameterSpec(IV)))); + System.out.println("Encrypted entry using: " + PBE_ALGO); + try (FileOutputStream outStream = new FileOutputStream(NEW_KEYSTORE)) { System.out.println("Storing keystore to: " + NEW_KEYSTORE); - keystore2.store(new FileOutputStream(NEW_KEYSTORE), PASSWORD); + keystore2.store(outStream, PASSWORD); + } - keystore2 = load(NEW_KEYSTORE_TYPE, NEW_KEYSTORE, PASSWORD); - entry = keystore2.getEntry(ALIAS, - new KeyStore.PasswordProtection(PASSWORD)); - System.out.println("Retrieved entry named '" + ALIAS + "'"); - - } finally { - new File(NEW_KEYSTORE).delete(); - System.out.println("Deleted keystore: " + NEW_KEYSTORE); - } + keystore2 = load(NEW_KEYSTORE_TYPE, NEW_KEYSTORE, PASSWORD); + entry = keystore2.getEntry(ALIAS, + new KeyStore.PasswordProtection(PASSWORD)); + System.out.println("Retrieved entry named '" + ALIAS + "'"); } private static KeyStore load(String type, String path, char[] password) throws Exception { + KeyStore keystore = KeyStore.getInstance(type); - FileInputStream stream = null; if (path != null) { - stream = new FileInputStream(path); + + try (FileInputStream inStream = new FileInputStream(path)) { + System.out.println("Loading keystore from: " + path); + keystore.load(inStream, password); + System.out.println("Loaded keystore with " + keystore.size() + + " entries"); + } + } else { + keystore.load(null, null); } - KeyStore keystore = KeyStore.getInstance(type); - System.out.println("Loading keystore from: " + path); - keystore.load(stream, password); return keystore; } diff -r a8bbd962f34a -r 41654275896d test/java/util/Base64/TestBase64.java --- a/test/java/util/Base64/TestBase64.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/util/Base64/TestBase64.java Mon Feb 04 17:29:58 2013 -0400 @@ -22,7 +22,7 @@ */ /** - * @test 4235519 8004212 + * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 * @summary tests java.util.Base64 */ @@ -109,6 +109,15 @@ // test return value from decode(ByteBuffer, ByteBuffer) testDecBufRet(); + + // test single-non-base64 character for mime decoding + testSingleNonBase64MimeDec(); + + // test decoding of unpadded data + testDecodeUnpadded(); + + // test mime decoding with ignored character after padding + testDecodeIgnoredAfterPadding(); } private static sun.misc.BASE64Encoder sunmisc = new sun.misc.BASE64Encoder(); @@ -295,6 +304,7 @@ checkNull(new Runnable() { public void run() { enc.encode(bb_null); }}); checkNull(new Runnable() { public void run() { enc.encode(bb_null, ByteBuffer.allocate(10), 0); }}); checkNull(new Runnable() { public void run() { enc.encode(ByteBuffer.allocate(10), bb_null, 0); }}); + checkNull(new Runnable() { public void run() { enc.wrap(null); }}); } private static void testNull(final Base64.Decoder dec) { @@ -305,6 +315,7 @@ checkNull(new Runnable() { public void run() { dec.decode(bb_null); }}); checkNull(new Runnable() { public void run() { dec.decode(bb_null, ByteBuffer.allocate(10)); }}); checkNull(new Runnable() { public void run() { dec.decode(ByteBuffer.allocate(10), bb_null); }}); + checkNull(new Runnable() { public void run() { dec.wrap(null); }}); } private static interface Testable { @@ -354,6 +365,94 @@ } catch (IllegalArgumentException iae) {} } + private static void testDecodeIgnoredAfterPadding() throws Throwable { + for (byte nonBase64 : new byte[] {'#', '(', '!', '\\', '-', '_', '\n', '\r'}) { + byte[][] src = new byte[][] { + "A".getBytes("ascii"), + "AB".getBytes("ascii"), + "ABC".getBytes("ascii"), + "ABCD".getBytes("ascii"), + "ABCDE".getBytes("ascii") + }; + Base64.Encoder encM = Base64.getMimeEncoder(); + Base64.Decoder decM = Base64.getMimeDecoder(); + Base64.Encoder enc = Base64.getEncoder(); + Base64.Decoder dec = Base64.getDecoder(); + for (int i = 0; i < src.length; i++) { + // decode(byte[]) + byte[] encoded = encM.encode(src[i]); + encoded = Arrays.copyOf(encoded, encoded.length + 1); + encoded[encoded.length - 1] = nonBase64; + checkEqual(decM.decode(encoded), src[i], "Non-base64 char is not ignored"); + try { + dec.decode(encoded); + throw new RuntimeException("No IAE for non-base64 char"); + } catch (IllegalArgumentException iae) {} + + // decode(ByteBuffer[], ByteBuffer[]) + ByteBuffer encodedBB = ByteBuffer.wrap(encoded); + ByteBuffer decodedBB = ByteBuffer.allocate(100); + int ret = decM.decode(encodedBB, decodedBB); + byte[] buf = new byte[ret]; + decodedBB.flip(); + decodedBB.get(buf); + checkEqual(buf, src[i], "Non-base64 char is not ignored"); + try { + encodedBB.rewind(); + decodedBB.clear(); + dec.decode(encodedBB, decodedBB); + throw new RuntimeException("No IAE for non-base64 char"); + } catch (IllegalArgumentException iae) {} + // direct + encodedBB.rewind(); + decodedBB = ByteBuffer.allocateDirect(100); + ret = decM.decode(encodedBB, decodedBB); + buf = new byte[ret]; + decodedBB.flip(); + decodedBB.get(buf); + checkEqual(buf, src[i], "Non-base64 char is not ignored"); + try { + encodedBB.rewind(); + decodedBB.clear(); + dec.decode(encodedBB, decodedBB); + throw new RuntimeException("No IAE for non-base64 char"); + } catch (IllegalArgumentException iae) {} + } + } + } + + private static void testDecodeUnpadded() throws Throwable { + byte[] srcA = new byte[] { 'Q', 'Q' }; + byte[] srcAA = new byte[] { 'Q', 'Q', 'E'}; + Base64.Decoder dec = Base64.getDecoder(); + byte[] ret = dec.decode(srcA); + if (ret[0] != 'A') + throw new RuntimeException("Decoding unpadding input A failed"); + ret = dec.decode(srcAA); + if (ret[0] != 'A' && ret[1] != 'A') + throw new RuntimeException("Decoding unpadding input AA failed"); + ret = new byte[10]; + if (dec.wrap(new ByteArrayInputStream(srcA)).read(ret) != 1 && + ret[0] != 'A') + throw new RuntimeException("Decoding unpadding input A from stream failed"); + if (dec.wrap(new ByteArrayInputStream(srcA)).read(ret) != 2 && + ret[0] != 'A' && ret[1] != 'A') + throw new RuntimeException("Decoding unpadding input AA from stream failed"); + } + + // single-non-base64-char should be ignored for mime decoding, but + // iae for basic decoding + private static void testSingleNonBase64MimeDec() throws Throwable { + for (String nonBase64 : new String[] {"#", "(", "!", "\\", "-", "_"}) { + if (Base64.getMimeDecoder().decode(nonBase64).length != 0) { + throw new RuntimeException("non-base64 char is not ignored"); + } + try { + Base64.getDecoder().decode(nonBase64); + throw new RuntimeException("No IAE for single non-base64 char"); + } catch (IllegalArgumentException iae) {} + } + } private static void testDecBufRet() throws Throwable { Random rnd = new java.util.Random(); diff -r a8bbd962f34a -r 41654275896d test/java/util/Formatter/Basic-X.java.template --- a/test/java/util/Formatter/Basic-X.java.template Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/util/Formatter/Basic-X.java.template Mon Feb 04 17:29:58 2013 -0400 @@ -1103,6 +1103,15 @@ test("%.5f", "1.99999", val); test("%.6f", "1.999990", val); + val = new BigDecimal(0.9996); + test("%.0f", "1", val); + test("%.1f", "1.0", val); + test("%.2f", "1.00", val); + test("%.3f", "1.000", val); + test("%.4f", "0.9996", val); + test("%.5f", "0.99960", val); + test("%.6f", "0.999600", val); + #end[BigDecimal] #if[float] diff -r a8bbd962f34a -r 41654275896d test/java/util/Formatter/BasicBigDecimal.java --- a/test/java/util/Formatter/BasicBigDecimal.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/java/util/Formatter/BasicBigDecimal.java Mon Feb 04 17:29:58 2013 -0400 @@ -1103,6 +1103,15 @@ test("%.5f", "1.99999", val); test("%.6f", "1.999990", val); + val = new BigDecimal(0.9996); + test("%.0f", "1", val); + test("%.1f", "1.0", val); + test("%.2f", "1.00", val); + test("%.3f", "1.000", val); + test("%.4f", "0.9996", val); + test("%.5f", "0.99960", val); + test("%.6f", "0.999600", val); + diff -r a8bbd962f34a -r 41654275896d test/java/util/HashMap/HashMapCloneLeak.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/util/HashMap/HashMapCloneLeak.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 7042126 + * @summary Verify that we do not leak contents when we clone a HashMap + * @author david.buck@oracle.com + * @run main/othervm HashMapCloneLeak + * @run main/othervm -XX:+AggressiveOpts HashMapCloneLeak + */ + +import java.util.HashMap; +import java.lang.ref.WeakReference; + +public class HashMapCloneLeak { + + static WeakReference wr = null; + + // helper method to keep testObject and map out of main method's scope + private static HashMap makeMap() { + HashMap map = new HashMap(); + Object testObject = new Object(); + wr = new WeakReference(testObject); + map.put(42, testObject); + return map; + } + + public static void main(String[] args) throws Exception { + HashMap hm = makeMap(); + hm = (HashMap)hm.clone(); + hm.clear(); + // There should no longer be a strong reference to testObject + // the WeakReference should be nulled out by GC. If not, + // we will hang here until timed out by the test harness. + Object[] chain = null; + while (wr.get() != null) { + try { + Object[] allocate = new Object[1000000]; + allocate[0] = chain; + chain = allocate; + } catch (OutOfMemoryError oome) { + chain = null; + } + System.gc(); + Thread.sleep(100); + } + } + +} diff -r a8bbd962f34a -r 41654275896d test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComboBox/ShowPopupAfterHidePopupTest/ShowPopupAfterHidePopupTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 8006417 + @summary JComboBox.showPopup(), hidePopup() fails in JRE 1.7 on OS X + @author Anton Litvinov +*/ + +import java.awt.*; + +import javax.swing.*; +import javax.swing.plaf.metal.*; + +import sun.awt.SunToolkit; + +public class ShowPopupAfterHidePopupTest { + private static JFrame frame = null; + private static JComboBox comboBox = null; + private static boolean popupIsVisible = false; + + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame = new JFrame("Popup Menu of JComboBox"); + comboBox = new JComboBox(new String[]{"Item1", "Item2", "Item3"}); + frame.getContentPane().add(comboBox); + frame.pack(); + frame.setVisible(true); + } + }); + final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + comboBox.showPopup(); + comboBox.hidePopup(); + comboBox.showPopup(); + } + }); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + popupIsVisible = comboBox.isPopupVisible(); + frame.dispose(); + } + }); + if (!popupIsVisible) { + throw new RuntimeException("Calling hidePopup() affected the next call to showPopup()."); + } + } +} diff -r a8bbd962f34a -r 41654275896d test/javax/swing/JFileChooser/6817933/Test6817933.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JFileChooser/6817933/Test6817933.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6817933 + * @summary Tests that HTMLEditorKit does not affect JFileChooser + * @author Sergey Malenkov + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JToggleButton; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.text.html.HTMLEditorKit; +import javax.swing.text.html.StyleSheet; + +import sun.awt.SunToolkit; +import sun.swing.WindowsPlacesBar; + +public class Test6817933 { + + private static final String STYLE = "BODY {background:red}"; + private static final Color COLOR = Color.RED; + private static JFileChooser chooser; + + public static void main(String[] args) throws Exception { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); + } + catch (Exception exception) { + exception.printStackTrace(); + return; // ignore test on non-Windows machines + } + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + StyleSheet css = new StyleSheet(); + css.addRule(STYLE); + + HTMLEditorKit kit = new HTMLEditorKit(); + kit.setStyleSheet(css); + + JFrame frame = new JFrame(STYLE); + frame.add(chooser = new JFileChooser()); + frame.setSize(640, 480); + frame.setVisible(true); + } + }); + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + toolkit.realSync(500); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + JToggleButton button = get(JToggleButton.class, + get(WindowsPlacesBar.class, chooser)); + + int width = button.getWidth(); + int height = button.getHeight() / 3; + Point point = new Point(0, height * 2); + SwingUtilities.convertPointToScreen(point, button); + width += point.x; + height += point.y; + + int count = 0; + Robot robot = new Robot(); + for (int x = point.x; x < width; x++) { + for (int y = point.y; y < height; y++) { + count += COLOR.equals(robot.getPixelColor(x, y)) ? -2 : 1; + } + } + if (count < 0) { + throw new Exception("TEST ERROR: a lot of red pixels"); + } + } + catch (Exception exception) { + throw new Error(exception); + } + finally { + SwingUtilities.getWindowAncestor(chooser).dispose(); + } + } + }); + } + + private static T get(Class type, Container container) { + Component component = container.getComponent(0); + if (!type.isAssignableFrom(component.getClass())) { + throw new IllegalStateException("expected " + type + "; expected " + component.getClass()); + } + return (T) component; + } +} diff -r a8bbd962f34a -r 41654275896d test/javax/swing/JTree/8003400/Test8003400.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JTree/8003400/Test8003400.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8003400 + * @summary Tests that JTree shows the last row + * @author Sergey Malenkov + * @run main/othervm Test8003400 + * @run main/othervm Test8003400 reverse + * @run main/othervm Test8003400 system + * @run main/othervm Test8003400 system reverse + */ + +import sun.awt.SunToolkit; + +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.tree.DefaultMutableTreeNode; + +public class Test8003400 { + + private static final String TITLE = "Test JTree with a large model"; + private static List OBJECTS = Arrays.asList(TITLE, "x", "y", "z"); + private static JScrollPane pane; + + public static void main(String[] args) throws Exception { + for (String arg : args) { + if (arg.equals("reverse")) { + Collections.reverse(OBJECTS); + } + if (arg.equals("system")) { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + } + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + DefaultMutableTreeNode root = new DefaultMutableTreeNode(); + + JTree tree = new JTree(root); + tree.setLargeModel(true); + tree.setRowHeight(16); + + JFrame frame = new JFrame(TITLE); + frame.add(pane = new JScrollPane(tree)); + frame.setSize(200, 100); + frame.setLocationRelativeTo(null); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setVisible(true); + + for (String object : OBJECTS) { + root.add(new DefaultMutableTreeNode(object)); + } + tree.expandRow(0); + } + }); + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + toolkit.realSync(500); + new Robot().keyPress(KeyEvent.VK_END); + toolkit.realSync(500); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + JTree tree = (JTree) pane.getViewport().getView(); + Rectangle inner = tree.getRowBounds(tree.getRowCount() - 1); + Rectangle outer = SwingUtilities.convertRectangle(tree, inner, pane); + outer.y += tree.getRowHeight() - 1 - pane.getVerticalScrollBar().getHeight(); + // error reporting only for automatic testing + if (null != System.getProperty("test.src", null)) { + SwingUtilities.getWindowAncestor(pane).dispose(); + if (outer.y != 0) { + throw new Error("TEST FAILED: " + outer.y); + } + } + } + }); + } +} diff -r a8bbd962f34a -r 41654275896d test/javax/swing/JTree/8004298/bug8004298.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JTree/8004298/bug8004298.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8004298 + * @summary NPE in WindowsTreeUI.ensureRowsAreVisible + * @author Alexander Scherbatiy + * @library ../../regtesthelpers + * @build Util + * @run main bug8004298 + */ + +import java.awt.*; +import java.awt.event.InputEvent; +import javax.swing.*; +import javax.swing.tree.*; +import java.util.concurrent.Callable; +import sun.awt.SunToolkit; +import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; +import com.sun.java.swing.plaf.windows.WindowsTreeUI; + +public class bug8004298 { + + private static JTree tree; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + UIManager.setLookAndFeel(new WindowsLookAndFeel()); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + createAndShowGUI(); + } + }); + + toolkit.realSync(); + + Point point = Util.invokeOnEDT(new Callable() { + + @Override + public Point call() throws Exception { + Rectangle rect = tree.getRowBounds(2); + Point p = new Point(rect.x + rect.width / 2, rect.y + rect.height / 2); + SwingUtilities.convertPointToScreen(p, tree); + return p; + } + }); + + robot.mouseMove(point.x, point.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + } + + private static void createAndShowGUI() { + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + DefaultMutableTreeNode root = new DefaultMutableTreeNode("root"); + root.add(new DefaultMutableTreeNode("colors")); + DefaultMutableTreeNode sports = new DefaultMutableTreeNode("sports"); + sports.add(new DefaultMutableTreeNode("basketball")); + sports.add(new DefaultMutableTreeNode("football")); + root.add(sports); + + tree = new JTree(root); + tree.setUI(new NullReturningTreeUI()); + + frame.getContentPane().add(tree); + frame.pack(); + frame.setVisible(true); + + } + + private static final class NullReturningTreeUI extends WindowsTreeUI { + + @Override + public Rectangle getPathBounds(JTree tree, TreePath path) { + // the method can return null and callers have to be ready for + // that. Simulate the case by returning null for unknown reason. + if (path != null && path.toString().contains("football")) { + return null; + } + + return super.getPathBounds(tree, path); + } + } +} \ No newline at end of file diff -r a8bbd962f34a -r 41654275896d test/javax/swing/SpringLayout/4726194/bug4726194.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/SpringLayout/4726194/bug4726194.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4726194 7124209 + * @summary Tests for 4726194 + * @author Phil Milne + */ +import java.awt.*; +import java.lang.reflect.InvocationTargetException; +import java.util.*; +import java.util.List; +import javax.swing.*; + +public class bug4726194 { + + private static String[] hConstraints = {SpringLayout.WEST, "Width", SpringLayout.EAST, SpringLayout.HORIZONTAL_CENTER}; + private static String[] vConstraints = {SpringLayout.NORTH, "Height", SpringLayout.SOUTH, SpringLayout.VERTICAL_CENTER, SpringLayout.BASELINE}; + private static int[] FAIL = new int[3]; + private static boolean TEST_DUPLICATES = false; + + public static void main(String[] args) { + try { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + int minLevel = 2; + int maxLevel = 2; + for (int i = minLevel; i <= maxLevel; i++) { + test(i, true); + test(i, false); + } + } + }); + } catch (InterruptedException | InvocationTargetException ex) { + ex.printStackTrace(); + throw new RuntimeException("FAILED: SwingUtilities.invokeAndWait method failed!"); + } + } + + public static void test(int level, boolean horizontal) { + List result = new ArrayList(); + String[] constraints = horizontal ? hConstraints : vConstraints; + test(level, constraints, result, Arrays.asList(new Object[level])); + JTextField tf = new JTextField(""); + tf.setFont(new Font("Dialog", Font.PLAIN, 6)); + System.out.print("\t\t"); + for (int j = 0; j < constraints.length; j++) { + String constraint = constraints[j]; + System.out.print(constraint + " ".substring(constraint.length())); + } + System.out.println(""); + for (int i = 0; i < result.size(); i++) { + SpringLayout.Constraints c = new SpringLayout.Constraints(tf); + List cc = (List) result.get(i); + for (int j = 0; j < cc.size(); j++) { + String constraint = (String) cc.get(j); + c.setConstraint(constraint, Spring.constant((j + 1) * 10)); + } + System.out.print(" Input:\t\t"); + for (int j = 0; j < constraints.length; j++) { + String constraint = constraints[j]; + int jj = cc.indexOf(constraint); + String val = cc.contains(constraint) ? Integer.toString((jj + 1) * 10) : "?"; + System.out.print(val + "\t\t"); + } + System.out.println(""); + System.out.print("Output:\t\t"); + for (int j = 0; j < constraints.length; j++) { + String constraint = constraints[j]; + Spring spring = c.getConstraint(constraint); + String springVal = (spring == null) ? "?" : Integer.toString(spring.getValue()); + System.out.print(springVal); + System.out.print("\t\t"); + } + for (int j = 0; j < cc.size(); j++) { + String constraint = (String) cc.get(j); + Spring con = c.getConstraint(constraint); + if (con == null || con.getValue() != (j + 1) * 10) { + throw new RuntimeException("Values are wrong!!! "); + } + } + if (horizontal) { + int[] a1 = getValues(c, new String[]{SpringLayout.WEST, SpringLayout.WIDTH, SpringLayout.EAST}); + if (a1[0] + a1[1] != a1[2]) { + throw new RuntimeException("WEST + WIDTH != EAST!!! "); + } + int[] a2 = getValues(c, new String[]{SpringLayout.WEST, SpringLayout.WIDTH, SpringLayout.HORIZONTAL_CENTER}); + if (a2[0] + a2[1] / 2 != a2[2]) { + throw new RuntimeException("WEST + WIDTH/2 != HORIZONTAL_CENTER!!! "); + } + } else { + int[] a3 = getValues(c, new String[]{SpringLayout.NORTH, SpringLayout.HEIGHT, SpringLayout.SOUTH}); + if (a3[0] + a3[1] != a3[2]) { + throw new RuntimeException("NORTH + HEIGHT != SOUTH!!! "); + } + int[] a4 = getValues(c, new String[]{SpringLayout.NORTH, SpringLayout.HEIGHT, SpringLayout.VERTICAL_CENTER}); + int vcDiff = Math.abs(a4[0] + a4[1] / 2 - a4[2]); + if (vcDiff > 1) { + throw new RuntimeException("NORTH + HEIGHT/2 != VERTICAL_CENTER!!! "); + } + int[] a5 = getValues(c, new String[]{SpringLayout.NORTH, SpringLayout.BASELINE, SpringLayout.SOUTH}); + if (a5[0] > a5[1] != a5[1] > a5[2]) { + throw new RuntimeException("BASELINE is not in the range: [NORTH, SOUTH]!!!"); + } + } + System.out.println(""); + } + System.out.println(""); + } + + private static int[] getValues(SpringLayout.Constraints con, String[] cNames) { + int[] result = new int[cNames.length]; + for (int i = 0; i < cNames.length; i++) { + String name = cNames[i]; + Spring s = con.getConstraint(name); + if (s == null) { + System.out.print("Warning: " + name + " is undefined. "); + return FAIL; + } + result[i] = s.getValue(); + } + return result; + } + + public static void test(int level, String[] constraints, List result, List soFar) { + if (level == 0) { + result.add(soFar); + return; + } + for (int i = 0; i < constraints.length; i++) { + if (soFar.contains(constraints[i]) && !TEST_DUPLICATES) { + continue; + } + List child = new ArrayList(soFar); + child.set(level - 1, constraints[i]); + test(level - 1, constraints, result, child); + } + } +} diff -r a8bbd962f34a -r 41654275896d test/sun/management/jdp/JdpClient.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/management/jdp/JdpClient.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.NetworkInterface; +import java.net.ProtocolFamily; +import java.net.StandardProtocolFamily; +import java.net.StandardSocketOptions; +import java.nio.ByteBuffer; +import java.nio.channels.DatagramChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.util.Collections; +import java.util.Enumeration; +import sun.management.jdp.JdpException; +import sun.management.jdp.JdpJmxPacket; + +public class JdpClient { + + private static class PacketListener implements Runnable { + + private static final int BUFFER_LENGTH = 4096; + private final DatagramChannel channel; + private static int maxPacketCount = 1; + private static int maxEmptyPacketCount = 10; + + + PacketListener(DatagramChannel channel) { + this.channel = channel; + } + + @java.lang.Override + public void run() { + try { + Selector sel; + sel = Selector.open(); + channel.configureBlocking(false); + channel.register(sel, SelectionKey.OP_READ); + ByteBuffer buf = ByteBuffer.allocate(1024); + + int count = 1; + int emptyPacketsCount = 1; + + try { + while (true) { + + sel.selectedKeys().clear(); + buf.rewind(); + + sel.select(10 * 1000); + channel.receive(buf); + + if (buf.position() == 0 ){ + if (JdpDoSomething.getVerbose()){ + System.err.println("Empty packet received"); + } + if (++emptyPacketsCount > maxEmptyPacketCount){ + throw new RuntimeException("Test failed, maxEmptyPacketCount reached"); + } + + continue; + } + + buf.flip(); + byte[] dgramData = new byte[buf.remaining()]; + buf.get(dgramData); + + try { + JdpJmxPacket packet = new JdpJmxPacket(dgramData); + JdpDoSomething.printJdpPacket(packet); + if(++count > maxPacketCount){ + break; + } + } catch (JdpException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } + + } + + System.out.println("OK: Test passed"); + + } finally { + sel.close(); + channel.close(); + } + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } + } + } + + public static void main(String[] args) { + try { + String discoveryPort = System.getProperty("com.sun.management.jdp.port"); + String discoveryAddress = System.getProperty("com.sun.management.jdp.address"); + if (discoveryAddress == null || discoveryPort == null) { + System.out.println("Test failed. address and port must be specified"); + return; + } + + int port = Integer.parseInt(discoveryPort); + InetAddress address = InetAddress.getByName(discoveryAddress); + + + ProtocolFamily family = (address instanceof Inet6Address) + ? StandardProtocolFamily.INET6 : StandardProtocolFamily.INET; + + DatagramChannel channel; + + channel = DatagramChannel.open(family); + channel.setOption(StandardSocketOptions.SO_REUSEADDR, true); + channel.bind(new InetSocketAddress(port)); + + Enumeration nets = NetworkInterface.getNetworkInterfaces(); + for (NetworkInterface interf : Collections.list(nets)) { + if (interf.supportsMulticast()) { + try { + channel.join(address, interf); + } catch (IOException e) { + // Skip not configured interfaces + } + } + } + + PacketListener listener = new PacketListener(channel); + new Thread(listener, "Jdp Client").start(); + + } catch (RuntimeException e){ + System.out.println("Test failed."); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("Test failed. unexpected error " + e); + } + } +} diff -r a8bbd962f34a -r 41654275896d test/sun/management/jdp/JdpDoSomething.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/management/jdp/JdpDoSomething.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.Objects; + +import sun.management.jdp.JdpJmxPacket; +import sun.management.jdp.JdpException; + +public class JdpDoSomething { + + private static final String lockFileName = "JdpDoSomething.lck"; + private static final boolean verbose=false; + + public static boolean getVerbose(){ + return verbose; + } + + public static void printJdpPacket(JdpJmxPacket p) { + if (getVerbose()) { + try { + RandomAccessFile f = new RandomAccessFile("out.dmp", "rw"); + f.write(p.getPacketData()); + f.close(); + } catch (IOException e) { + System.out.println("Can't write a dump file: " + e); + } + + System.out.println("Id: " + p.getId()); + System.out.println("Jmx: " + p.getJmxServiceUrl()); + System.out.println("Main: " + p.getMainClass()); + System.out.println("InstanceName: " + p.getInstanceName()); + + System.out.flush(); + } + } + + public static void compaireJdpPacketEx(JdpJmxPacket p1, JdpJmxPacket p2) + throws JdpException { + + if (!Objects.equals(p1, p1)) { + throw new JdpException("Packet mismatch error"); + } + + if (!Objects.equals(p1.getMainClass(), p2.getMainClass())) { + throw new JdpException("Packet mismatch error (main class)"); + } + + if (!Objects.equals(p1.getInstanceName(), p2.getInstanceName())) { + throw new JdpException("Packet mismatch error (instance name)"); + } + } + + public static void doSomething() { + try { + File lockFile = new File(lockFileName); + lockFile.createNewFile(); + + while (lockFile.exists()) { + long datetime = lockFile.lastModified(); + long epoch = System.currentTimeMillis() / 1000; + + // Don't allow test app to run more than an hour + if (epoch - datetime > 3600) { + System.err.println("Lock is too old. Aborting"); + return; + } + Thread.sleep(1); + } + + } catch (Throwable e) { + System.err.println("Something bad happens:" + e); + } + } + + public static void main(String args[]) throws Exception { + System.err.println("main enter"); + doSomething(); + System.err.println("main exit"); + } +} diff -r a8bbd962f34a -r 41654275896d test/sun/management/jdp/JdpTest.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/management/jdp/JdpTest.sh Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,323 @@ +#!/bin/sh + +# Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. + +# @test +# @bug 7169888 +# @build JdpUnitTest JdpClient JdpDoSomething +# @run shell JdpTest.sh --jtreg --no-compile +# @summary No word Failed expected in the test output + +_verbose=no +_jtreg=no +_compile=yes + +# temporary disable jcmd related tests +# _testsuite="01,02,03,04,05" +_testsuite="01,02,04" + +_pwd=`pwd` + +_testclasses=".classes" +_testsrc="${_pwd}" +_lockFileName="JdpDoSomething.lck" + +_logname=".classes/output.txt" +_last_pid="" + + +_compile(){ + + if [ ! -e ${_testclasses} ] + then + mkdir -p ${_testclasses} + fi + + rm -f ${_testclasses}/*.class + + # Compile testcase + ${TESTJAVA}/bin/javac -d ${_testclasses} JdpUnitTest.java \ + JdpDoSomething.java \ + JdpClient.java + + + if [ ! -e ${_testclasses}/JdpDoSomething.class -o ! -e ${_testclasses}/JdpClient.class -o ! -e ${_testclasses}/JdpUnitTest.class ] + then + echo "ERROR: Can't compile" + exit -1 + fi +} + + +_app_start(){ + + testappname=$1 + shift + + ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} ${testappname} >> ${_logname} 2>&1 & + _last_pid=$! + + npid=`_get_pid` + if [ "${npid}" = "" ] + then + echo "ERROR: Test app not started" + if [ "${_jtreg}" = "yes" ] + then + exit -1 + fi + fi +} + +_get_pid(){ + ${TESTJAVA}/bin/jps | sed -n "/Jdp/s/ .*//p" +} + +_app_stop(){ + rm ${_lockFileName} + +# wait until VM is actually shuts down + while true + do + npid=`_get_pid` + if [ "${npid}" = "" ] + then + break + fi + sleep 1 + done +} + +_testme(){ + ${TESTJAVA}/bin/java \ + -cp ${_testclasses} \ + $* \ + -Dcom.sun.management.jdp.port=7095 \ + -Dcom.sun.management.jdp.address=239.255.255.225 \ + JdpClient + +} + + +_jcmd(){ + ${TESTJAVA}/bin/jcmd JdpDoSomething $* > /dev/null 2>/dev/null +} + + +_echo(){ + echo "$*" + echo "$*" >> ${_logname} +} + +# ============= TESTS ====================================== + +test_01(){ + + _echo "**** Test one ****" + + _app_start JdpUnitTest \ + -Dcom.sun.management.jdp.port=7095 \ + -Dcom.sun.management.jdp.address=239.255.255.225 \ + -Dcom.sun.management.jdp.pause=5 + + res=`_testme` + + case "${res}" in + OK*) + _echo "Passed" + ;; + *) + _echo "Failed!" + ;; + esac + + _app_stop +} + +test_02(){ + + _echo "**** Test two ****" + + _app_start JdpDoSomething \ + -Dcom.sun.management.jdp.port=7095 \ + -Dcom.sun.management.jdp.address=239.255.255.225 \ + -Dcom.sun.management.jdp.pause=5 \ + -Dcom.sun.management.jmxremote.port=4545 \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.ssl=false + + res=`_testme` + + case "${res}" in + OK*) + _echo "Passed" + ;; + *) + _echo "Failed!" + ;; + esac + + _app_stop +} + +test_03(){ + + _echo "**** Test three ****" + + _app_start JdpDoSomething + + _jcmd ManagementAgent.start\ + jdp.port=7095 \ + jdp.address=239.255.255.225 \ + jdp.pause=5 \ + jmxremote.port=4545 \ + jmxremote.authenticate=false \ + jmxremote.ssl=false + + res=`_testme` + + case "${res}" in + OK*) + _echo "Passed" + ;; + *) + _echo "Failed!" + ;; + esac + + _app_stop +} + +test_04(){ + + _echo "**** Test four ****" + + _app_start JdpDoSomething \ + -Dcom.sun.management.jmxremote.autodiscovery=true \ + -Dcom.sun.management.jmxremote.port=4545 \ + -Dcom.sun.management.jmxremote.authenticate=false \ + -Dcom.sun.management.jmxremote.ssl=false + + res=`_testme` + + case "${res}" in + OK*) + _echo "Passed" + ;; + *) + _echo "Failed!" + ;; + esac + + _app_stop +} + +test_05(){ + + _echo "**** Test five ****" + + _app_start JdpDoSomething + + _jcmd ManagementAgent.start\ + jmxremote.autodiscovery=true \ + jmxremote.port=4545 \ + jmxremote.authenticate=false \ + jmxremote.ssl=false + + + res=`_testme` + + case "${res}" in + OK*) + _echo "Passed" + ;; + *) + _echo "Failed!" + ;; + esac + + _app_stop +} + + +# ============= MAIN ======================================= + +if [ "x${TESTJAVA}" = "x" ] +then + echo "TESTJAVA env have to be set" + exit +fi + +#------------------------------------------------------------------------------ +# reading parameters + +for parm in "$@" +do + case $parm in + --verbose) _verbose=yes ;; + --jtreg) _jtreg=yes ;; + --no-compile) _compile=no ;; + --testsuite=*) _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"` ;; + *) + echo "Undefined parameter $parm. Try --help for help" + exit + ;; + esac +done + +if [ ${_compile} = "yes" ] +then + _compile +fi + +if [ ${_jtreg} = "yes" ] +then + _testclasses=${TESTCLASSES} + _testsrc=${TESTSRC} + _logname="output.txt" +fi + +# Make sure _tesclasses is absolute path +tt=`echo ${_testclasses} | sed -e 's,/,,'` +if [ ${tt} = ${_testclasses} ] +then + _testclasses="${_pwd}/${_testclasses}" +fi + +_policyname="${_testclasses}/policy" + +rm -f ${_logname} +rm -f ${_policyname} + +if [ -e ${_testsrc}/policy.tpl ] +then + +cat ${_testsrc}/policy.tpl | \ + sed -e "s,@_TESTCLASSES@,${_testclasses},g" -e "s,@TESTJAVA@,${TESTJAVA},g" \ + > ${_policyname} + +fi + +# Local mode tests +for i in `echo ${_testsuite} | sed -e "s/,/ /g"` +do + test_${i} +done diff -r a8bbd962f34a -r 41654275896d test/sun/management/jdp/JdpUnitTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/management/jdp/JdpUnitTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.net.InetAddress; +import java.util.UUID; + +import sun.management.jdp.JdpController; +import sun.management.jdp.JdpPacket; +import sun.management.jdp.JdpJmxPacket; +import sun.management.jdp.JdpException; + +public class JdpUnitTest { + + /** + * This test tests that complete packet is build correctly + */ + public static void PacketBuilderTest() + throws IOException, JdpException { + + /* Complete packet test */ + { + JdpJmxPacket p1 = new JdpJmxPacket(UUID.randomUUID(), "fake://unit-test"); + p1.setMainClass("FakeUnitTest"); + p1.setInstanceName("Fake"); + byte[] b = p1.getPacketData(); + + JdpJmxPacket p2 = new JdpJmxPacket(b); + JdpDoSomething.printJdpPacket(p1); + JdpDoSomething.compaireJdpPacketEx(p1, p2); + } + + /*Missed field packet test*/ + { + JdpJmxPacket p1 = new JdpJmxPacket(UUID.randomUUID(), "fake://unit-test"); + p1.setMainClass("FakeUnitTest"); + p1.setInstanceName(null); + byte[] b = p1.getPacketData(); + + JdpJmxPacket p2 = new JdpJmxPacket(b); + JdpDoSomething.printJdpPacket(p1); + JdpDoSomething.compaireJdpPacketEx(p1, p2); + } + + System.out.println("OK: Test passed"); + + } + + public static void startFakeDiscoveryService() + throws IOException, JdpException { + + String discoveryPort = System.getProperty("com.sun.management.jdp.port"); + String discoveryAddress = System.getProperty("com.sun.management.jdp.address"); + InetAddress address = InetAddress.getByName(discoveryAddress); + int port = Integer.parseInt(discoveryPort); + JdpController.startDiscoveryService(address, port, "FakeDiscovery", "fake://unit-test"); + } + + public static void main(String[] args) { + try { + PacketBuilderTest(); + startFakeDiscoveryService(); + JdpDoSomething.doSomething(); + + } catch (Throwable e) { + e.printStackTrace(); + System.out.println("Test failed. unexpected error " + e); + } + } +} diff -r a8bbd962f34a -r 41654275896d test/sun/net/ftp/EncDec.doc Binary file test/sun/net/ftp/EncDec.doc has changed diff -r a8bbd962f34a -r 41654275896d test/sun/net/ftp/MarkResetTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/net/ftp/MarkResetTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,455 @@ +/* + * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * + * run from MarkResetTest.sh + */ + +import java.io.*; +import java.net.*; +import java.util.regex.*; + +public class MarkResetTest { + + /** + * A class that simulates, on a separate, an FTP server. + */ + private class FtpServer extends Thread { + private ServerSocket server; + private int port; + private boolean done = false; + private boolean pasvEnabled = true; + private boolean portEnabled = true; + private boolean extendedEnabled = true; + + /** + * This Inner class will handle ONE client at a time. + * That's where 99% of the protocol handling is done. + */ + + private class FtpServerHandler extends Thread { + BufferedReader in; + PrintWriter out; + Socket client; + private final int ERROR = 0; + private final int USER = 1; + private final int PASS = 2; + private final int CWD = 3; + private final int TYPE = 4; + private final int RETR = 5; + private final int PASV = 6; + private final int PORT = 7; + private final int QUIT = 8; + private final int EPSV = 9; + String[] cmds = { "USER", "PASS", "CWD", + "TYPE", "RETR", "PASV", + "PORT", "QUIT", "EPSV"}; + private String arg = null; + private ServerSocket pasv = null; + private int data_port = 0; + private InetAddress data_addr = null; + + /** + * Parses a line to match it with one of the supported FTP commands. + * Returns the command number. + */ + + private int parseCmd(String cmd) { + if (cmd == null || cmd.length() < 3) + return ERROR; + int blank = cmd.indexOf(' '); + if (blank < 0) + blank = cmd.length(); + if (blank < 3) + return ERROR; + String s = cmd.substring(0, blank); + if (cmd.length() > blank+1) + arg = cmd.substring(blank+1, cmd.length()); + else + arg = null; + for (int i = 0; i < cmds.length; i++) { + if (s.equalsIgnoreCase(cmds[i])) + return i+1; + } + return ERROR; + } + + public FtpServerHandler(Socket cl) { + client = cl; + } + + protected boolean isPasvSet() { + if (pasv != null && !pasvEnabled) { + try { + pasv.close(); + } catch (IOException ex) { + } + pasv = null; + } + if (pasvEnabled && pasv != null) + return true; + return false; + } + + /** + * Open the data socket with the client. This can be the + * result of a "PASV" or "PORT" command. + */ + + protected OutputStream getOutDataStream() { + try { + if (isPasvSet()) { + Socket s = pasv.accept(); + return s.getOutputStream(); + } + if (data_addr != null) { + Socket s = new Socket(data_addr, data_port); + data_addr = null; + data_port = 0; + return s.getOutputStream(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + protected InputStream getInDataStream() { + try { + if (isPasvSet()) { + Socket s = pasv.accept(); + return s.getInputStream(); + } + if (data_addr != null) { + Socket s = new Socket(data_addr, data_port); + data_addr = null; + data_port = 0; + return s.getInputStream(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * Handles the protocol exchange with the client. + */ + + public void run() { + boolean done = false; + String str; + int res; + boolean logged = false; + boolean waitpass = false; + + try { + in = new BufferedReader(new InputStreamReader( + client.getInputStream())); + out = new PrintWriter(client.getOutputStream(), true); + out.println("220 tatooine FTP server (SunOS 5.8) ready."); + } catch (Exception ex) { + return; + } + while (!done) { + try { + str = in.readLine(); + res = parseCmd(str); + if ((res > PASS && res != QUIT) && !logged) { + out.println("530 Not logged in."); + continue; + } + switch (res) { + case ERROR: + out.println("500 '" + str + + "': command not understood."); + break; + case USER: + if (!logged && !waitpass) { + out.println("331 Password required for " + arg); + waitpass = true; + } else { + out.println("503 Bad sequence of commands."); + } + break; + case PASS: + if (!logged && waitpass) { + out.println("230-Welcome to the FTP server!"); + out.println("ab"); + out.println("230 Guest login ok, " + + "access restrictions apply."); + logged = true; + waitpass = false; + } else + out.println("503 Bad sequence of commands."); + break; + case QUIT: + out.println("221 Goodbye."); + out.flush(); + out.close(); + if (pasv != null) + pasv.close(); + done = true; + break; + case TYPE: + out.println("200 Type set to " + arg + "."); + break; + case CWD: + out.println("250 CWD command successful."); + break; + case EPSV: + if (!extendedEnabled || !pasvEnabled) { + out.println("500 EPSV is disabled, " + + "use PORT instead."); + continue; + } + if ("all".equalsIgnoreCase(arg)) { + out.println("200 EPSV ALL command successful."); + continue; + } + try { + if (pasv == null) + pasv = new ServerSocket(0); + int port = pasv.getLocalPort(); + out.println("229 Entering Extended" + + " Passive Mode (|||" + port + "|)"); + } catch (IOException ssex) { + out.println("425 Can't build data connection:" + + " Connection refused."); + } + break; + + case PASV: + if (!pasvEnabled) { + out.println("500 PASV is disabled, " + + "use PORT instead."); + continue; + } + try { + if (pasv == null) + pasv = new ServerSocket(0); + int port = pasv.getLocalPort(); + + // Parenthesis are optional, so let's be + // nasty and don't put them + out.println("227 Entering Passive Mode" + + " 127,0,0,1," + + (port >> 8) + "," + (port & 0xff)); + } catch (IOException ssex) { + out.println("425 Can't build data connection:" + + "Connection refused."); + } + break; + case PORT: + if (!portEnabled) { + out.println("500 PORT is disabled, " + + "use PASV instead"); + continue; + } + StringBuffer host; + int i = 0, j = 4; + while (j > 0) { + i = arg.indexOf(',', i + 1); + if (i < 0) + break; + j--; + } + if (j != 0) { + out.println("500 '" + arg + "':" + + " command not understood."); + continue; + } + try { + host = new StringBuffer(arg.substring(0, i)); + for (j = 0; j < host.length(); j++) + if (host.charAt(j) == ',') + host.setCharAt(j, '.'); + String ports = arg.substring(i+1); + i = ports.indexOf(','); + data_port = Integer.parseInt( + ports.substring(0, i)) << 8; + data_port += (Integer.parseInt( + ports.substring(i+1))); + data_addr = InetAddress.getByName( + host.toString()); + out.println("200 Command okay."); + } catch (Exception ex3) { + data_port = 0; + data_addr = null; + out.println("500 '" + arg + "':" + + " command not understood."); + } + break; + case RETR: + { + File file = new File(arg); + if (!file.exists()) { + System.out.println("File not found"); + out.println("200 Command okay."); + out.println("550 '" + arg + + "' No such file or directory."); + break; + } + FileInputStream fin = new FileInputStream(file); + OutputStream dout = getOutDataStream(); + if (dout != null) { + out.println("150 Binary data connection" + + " for " + arg + + " (" + client.getInetAddress(). + getHostAddress() + ") (" + + file.length() + " bytes)."); + int c; + int len = 0; + while ((c = fin.read()) != -1) { + dout.write(c); + len++; + } + dout.flush(); + dout.close(); + fin.close(); + out.println("226 Binary Transfer complete."); + } else { + out.println("425 Can't build data" + + " connection: Connection refused."); + } + } + break; + } + } catch (IOException ioe) { + ioe.printStackTrace(); + try { + out.close(); + } catch (Exception ex2) { + } + done = true; + } + } + } + } + + public FtpServer(int port) { + this.port = port; + } + + public FtpServer() { + this(21); + } + + public int getPort() { + if (server != null) + return server.getLocalPort(); + return 0; + } + + /** + * A way to tell the server that it can stop. + */ + synchronized public void terminate() { + done = true; + } + + + /* + * All we got to do here is create a ServerSocket and wait for a + * connection. When a connection happens, we just have to create + * a thread that will handle it. + */ + public void run() { + try { + server = new ServerSocket(port); + Socket client; + client = server.accept(); + (new FtpServerHandler(client)).start(); + server.close(); + } catch (Exception e) { + } + } + } + + public static void main(String[] args) throws Exception { + MarkResetTest test = new MarkResetTest(); + } + + public MarkResetTest() { + FtpServer server = null; + try { + server = new FtpServer(0); + server.start(); + int port = 0; + while (port == 0) { + Thread.sleep(500); + port = server.getPort(); + } + + String filename = "EncDec.doc"; + URL url = new URL("ftp://localhost:" + port + "/" + + filename); + + URLConnection con = url.openConnection(); + System.out.println("getContent: " + con.getContent()); + System.out.println("getContent-length: " + con.getContentLength()); + + InputStream is = con.getInputStream(); + + /** + * guessContentTypeFromStream method calls mark and reset methods + * on the given stream. Make sure that calling + * guessContentTypeFromStream repeatedly does not affect + * reading from the stream afterwards + */ + System.out.println("Call GuessContentTypeFromStream()" + + " several times.."); + for (int i = 0; i < 5; i++) { + System.out.println((i + 1) + " mime-type: " + + con.guessContentTypeFromStream(is)); + } + + int len = 0; + int c; + while ((c = is.read()) != -1) { + len++; + } + is.close(); + System.out.println("read: " + len + " bytes of the file"); + + // We're done! + server.terminate(); + server.interrupt(); + + // Did we pass ? + if (len != (new File(filename)).length()) { + throw new Exception("Failed to read the file correctly"); + } + System.out.println("PASSED: File read correctly"); + } catch (Exception e) { + e.printStackTrace(); + try { + server.terminate(); + server.interrupt(); + } catch (Exception ex) { + } + throw new RuntimeException("FTP support error: " + e.getMessage()); + } + } +} diff -r a8bbd962f34a -r 41654275896d test/sun/net/ftp/MarkResetTest.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/net/ftp/MarkResetTest.sh Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,55 @@ +# +# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 4673103 +# @run shell/timeout=140 MarkResetTest.sh +# @summary URLConnection.getContent() hangs over FTP for DOC, PPT, XLS files + +OS=`uname -s` +case "$OS" in + SunOS | Linux | Darwin ) + PS=":" + FS="/" + ;; + CYGWIN* ) + PS=";" + FS="/" + ;; + Windows* ) + PS=";" + FS="\\" + ;; + * ) + echo "Unrecognized system!" + exit 1; + ;; +esac + +${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}MarkResetTest.java + +# ftp server used by the test requires the file to be present +# in this directory +cp ${TESTSRC}${FS}EncDec.doc . + +${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} MarkResetTest diff -r a8bbd962f34a -r 41654275896d test/sun/net/www/EncDec.doc Binary file test/sun/net/www/EncDec.doc has changed diff -r a8bbd962f34a -r 41654275896d test/sun/net/www/MarkResetTest.java --- a/test/sun/net/www/MarkResetTest.java Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,455 +0,0 @@ -/* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * - * run from MarkResetTest.sh - */ - -import java.io.*; -import java.net.*; -import java.util.regex.*; - -public class MarkResetTest { - - /** - * A class that simulates, on a separate, an FTP server. - */ - private class FtpServer extends Thread { - private ServerSocket server; - private int port; - private boolean done = false; - private boolean pasvEnabled = true; - private boolean portEnabled = true; - private boolean extendedEnabled = true; - - /** - * This Inner class will handle ONE client at a time. - * That's where 99% of the protocol handling is done. - */ - - private class FtpServerHandler extends Thread { - BufferedReader in; - PrintWriter out; - Socket client; - private final int ERROR = 0; - private final int USER = 1; - private final int PASS = 2; - private final int CWD = 3; - private final int TYPE = 4; - private final int RETR = 5; - private final int PASV = 6; - private final int PORT = 7; - private final int QUIT = 8; - private final int EPSV = 9; - String[] cmds = { "USER", "PASS", "CWD", - "TYPE", "RETR", "PASV", - "PORT", "QUIT", "EPSV"}; - private String arg = null; - private ServerSocket pasv = null; - private int data_port = 0; - private InetAddress data_addr = null; - - /** - * Parses a line to match it with one of the supported FTP commands. - * Returns the command number. - */ - - private int parseCmd(String cmd) { - if (cmd == null || cmd.length() < 3) - return ERROR; - int blank = cmd.indexOf(' '); - if (blank < 0) - blank = cmd.length(); - if (blank < 3) - return ERROR; - String s = cmd.substring(0, blank); - if (cmd.length() > blank+1) - arg = cmd.substring(blank+1, cmd.length()); - else - arg = null; - for (int i = 0; i < cmds.length; i++) { - if (s.equalsIgnoreCase(cmds[i])) - return i+1; - } - return ERROR; - } - - public FtpServerHandler(Socket cl) { - client = cl; - } - - protected boolean isPasvSet() { - if (pasv != null && !pasvEnabled) { - try { - pasv.close(); - } catch (IOException ex) { - } - pasv = null; - } - if (pasvEnabled && pasv != null) - return true; - return false; - } - - /** - * Open the data socket with the client. This can be the - * result of a "PASV" or "PORT" command. - */ - - protected OutputStream getOutDataStream() { - try { - if (isPasvSet()) { - Socket s = pasv.accept(); - return s.getOutputStream(); - } - if (data_addr != null) { - Socket s = new Socket(data_addr, data_port); - data_addr = null; - data_port = 0; - return s.getOutputStream(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - protected InputStream getInDataStream() { - try { - if (isPasvSet()) { - Socket s = pasv.accept(); - return s.getInputStream(); - } - if (data_addr != null) { - Socket s = new Socket(data_addr, data_port); - data_addr = null; - data_port = 0; - return s.getInputStream(); - } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * Handles the protocol exchange with the client. - */ - - public void run() { - boolean done = false; - String str; - int res; - boolean logged = false; - boolean waitpass = false; - - try { - in = new BufferedReader(new InputStreamReader( - client.getInputStream())); - out = new PrintWriter(client.getOutputStream(), true); - out.println("220 tatooine FTP server (SunOS 5.8) ready."); - } catch (Exception ex) { - return; - } - while (!done) { - try { - str = in.readLine(); - res = parseCmd(str); - if ((res > PASS && res != QUIT) && !logged) { - out.println("530 Not logged in."); - continue; - } - switch (res) { - case ERROR: - out.println("500 '" + str + - "': command not understood."); - break; - case USER: - if (!logged && !waitpass) { - out.println("331 Password required for " + arg); - waitpass = true; - } else { - out.println("503 Bad sequence of commands."); - } - break; - case PASS: - if (!logged && waitpass) { - out.println("230-Welcome to the FTP server!"); - out.println("ab"); - out.println("230 Guest login ok, " + - "access restrictions apply."); - logged = true; - waitpass = false; - } else - out.println("503 Bad sequence of commands."); - break; - case QUIT: - out.println("221 Goodbye."); - out.flush(); - out.close(); - if (pasv != null) - pasv.close(); - done = true; - break; - case TYPE: - out.println("200 Type set to " + arg + "."); - break; - case CWD: - out.println("250 CWD command successful."); - break; - case EPSV: - if (!extendedEnabled || !pasvEnabled) { - out.println("500 EPSV is disabled, " + - "use PORT instead."); - continue; - } - if ("all".equalsIgnoreCase(arg)) { - out.println("200 EPSV ALL command successful."); - continue; - } - try { - if (pasv == null) - pasv = new ServerSocket(0); - int port = pasv.getLocalPort(); - out.println("229 Entering Extended" + - " Passive Mode (|||" + port + "|)"); - } catch (IOException ssex) { - out.println("425 Can't build data connection:" + - " Connection refused."); - } - break; - - case PASV: - if (!pasvEnabled) { - out.println("500 PASV is disabled, " + - "use PORT instead."); - continue; - } - try { - if (pasv == null) - pasv = new ServerSocket(0); - int port = pasv.getLocalPort(); - - // Parenthesis are optional, so let's be - // nasty and don't put them - out.println("227 Entering Passive Mode" + - " 127,0,0,1," + - (port >> 8) + "," + (port & 0xff)); - } catch (IOException ssex) { - out.println("425 Can't build data connection:" + - "Connection refused."); - } - break; - case PORT: - if (!portEnabled) { - out.println("500 PORT is disabled, " + - "use PASV instead"); - continue; - } - StringBuffer host; - int i = 0, j = 4; - while (j > 0) { - i = arg.indexOf(',', i + 1); - if (i < 0) - break; - j--; - } - if (j != 0) { - out.println("500 '" + arg + "':" + - " command not understood."); - continue; - } - try { - host = new StringBuffer(arg.substring(0, i)); - for (j = 0; j < host.length(); j++) - if (host.charAt(j) == ',') - host.setCharAt(j, '.'); - String ports = arg.substring(i+1); - i = ports.indexOf(','); - data_port = Integer.parseInt( - ports.substring(0, i)) << 8; - data_port += (Integer.parseInt( - ports.substring(i+1))); - data_addr = InetAddress.getByName( - host.toString()); - out.println("200 Command okay."); - } catch (Exception ex3) { - data_port = 0; - data_addr = null; - out.println("500 '" + arg + "':" + - " command not understood."); - } - break; - case RETR: - { - File file = new File(arg); - if (!file.exists()) { - System.out.println("File not found"); - out.println("200 Command okay."); - out.println("550 '" + arg + - "' No such file or directory."); - break; - } - FileInputStream fin = new FileInputStream(file); - OutputStream dout = getOutDataStream(); - if (dout != null) { - out.println("150 Binary data connection" + - " for " + arg + - " (" + client.getInetAddress(). - getHostAddress() + ") (" + - file.length() + " bytes)."); - int c; - int len = 0; - while ((c = fin.read()) != -1) { - dout.write(c); - len++; - } - dout.flush(); - dout.close(); - fin.close(); - out.println("226 Binary Transfer complete."); - } else { - out.println("425 Can't build data" + - " connection: Connection refused."); - } - } - break; - } - } catch (IOException ioe) { - ioe.printStackTrace(); - try { - out.close(); - } catch (Exception ex2) { - } - done = true; - } - } - } - } - - public FtpServer(int port) { - this.port = port; - } - - public FtpServer() { - this(21); - } - - public int getPort() { - if (server != null) - return server.getLocalPort(); - return 0; - } - - /** - * A way to tell the server that it can stop. - */ - synchronized public void terminate() { - done = true; - } - - - /* - * All we got to do here is create a ServerSocket and wait for a - * connection. When a connection happens, we just have to create - * a thread that will handle it. - */ - public void run() { - try { - server = new ServerSocket(port); - Socket client; - client = server.accept(); - (new FtpServerHandler(client)).start(); - server.close(); - } catch (Exception e) { - } - } - } - - public static void main(String[] args) throws Exception { - MarkResetTest test = new MarkResetTest(); - } - - public MarkResetTest() { - FtpServer server = null; - try { - server = new FtpServer(0); - server.start(); - int port = 0; - while (port == 0) { - Thread.sleep(500); - port = server.getPort(); - } - - String filename = "EncDec.doc"; - URL url = new URL("ftp://localhost:" + port + "/" + - filename); - - URLConnection con = url.openConnection(); - System.out.println("getContent: " + con.getContent()); - System.out.println("getContent-length: " + con.getContentLength()); - - InputStream is = con.getInputStream(); - - /** - * guessContentTypeFromStream method calls mark and reset methods - * on the given stream. Make sure that calling - * guessContentTypeFromStream repeatedly does not affect - * reading from the stream afterwards - */ - System.out.println("Call GuessContentTypeFromStream()" + - " several times.."); - for (int i = 0; i < 5; i++) { - System.out.println((i + 1) + " mime-type: " + - con.guessContentTypeFromStream(is)); - } - - int len = 0; - int c; - while ((c = is.read()) != -1) { - len++; - } - is.close(); - System.out.println("read: " + len + " bytes of the file"); - - // We're done! - server.terminate(); - server.interrupt(); - - // Did we pass ? - if (len != (new File(filename)).length()) { - throw new Exception("Failed to read the file correctly"); - } - System.out.println("PASSED: File read correctly"); - } catch (Exception e) { - e.printStackTrace(); - try { - server.terminate(); - server.interrupt(); - } catch (Exception ex) { - } - throw new RuntimeException("FTP support error: " + e.getMessage()); - } - } -} diff -r a8bbd962f34a -r 41654275896d test/sun/net/www/MarkResetTest.sh --- a/test/sun/net/www/MarkResetTest.sh Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -# -# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# @test -# @bug 4673103 -# @run shell/timeout=140 MarkResetTest.sh -# @summary URLConnection.getContent() hangs over FTP for DOC, PPT, XLS files - -OS=`uname -s` -case "$OS" in - SunOS | Linux | Darwin ) - PS=":" - FS="/" - ;; - CYGWIN* ) - PS=";" - FS="/" - ;; - Windows* ) - PS=";" - FS="\\" - ;; - * ) - echo "Unrecognized system!" - exit 1; - ;; -esac - -${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}MarkResetTest.java - -# ftp server used by the test requires the file to be present -# in this directory -cp ${TESTSRC}${FS}EncDec.doc . - -${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} MarkResetTest diff -r a8bbd962f34a -r 41654275896d test/sun/net/www/http/HttpClient/ProxyTest.java --- a/test/sun/net/www/http/HttpClient/ProxyTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/sun/net/www/http/HttpClient/ProxyTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -161,8 +161,18 @@ } } + private static boolean hasFtp() { + try { + return new java.net.URL("ftp://") != null; + } catch (java.net.MalformedURLException x) { + System.out.println("FTP not supported by this runtime."); + return false; + } + } + public static void main(String[] args) throws Exception { - ProxyTest test = new ProxyTest(); + if (hasFtp()) + new ProxyTest(); } public ProxyTest() throws Exception { diff -r a8bbd962f34a -r 41654275896d test/sun/security/pkcs12/StorePasswordTest.java --- a/test/sun/security/pkcs12/StorePasswordTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/sun/security/pkcs12/StorePasswordTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -47,40 +47,40 @@ new File(KEYSTORE).delete(); - try { + KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(null, null); - KeyStore keystore = KeyStore.getInstance("PKCS12"); - keystore.load(null, null); + // Set entry + keystore.setEntry(ALIAS, + new KeyStore.SecretKeyEntry(convertPassword(USER_PASSWORD)), + new KeyStore.PasswordProtection(PASSWORD)); - // Set entry - keystore.setEntry(ALIAS, - new KeyStore.SecretKeyEntry(convertPassword(USER_PASSWORD)), - new KeyStore.PasswordProtection(PASSWORD)); + try (FileOutputStream outStream = new FileOutputStream(KEYSTORE)) { + System.out.println("Storing keystore to: " + KEYSTORE); + keystore.store(outStream, PASSWORD); + } - System.out.println("Storing keystore to: " + KEYSTORE); - keystore.store(new FileOutputStream(KEYSTORE), PASSWORD); - + try (FileInputStream inStream = new FileInputStream(KEYSTORE)) { System.out.println("Loading keystore from: " + KEYSTORE); - keystore.load(new FileInputStream(KEYSTORE), PASSWORD); + keystore.load(inStream, PASSWORD); System.out.println("Loaded keystore with " + keystore.size() + " entries"); - KeyStore.Entry entry = keystore.getEntry(ALIAS, - new KeyStore.PasswordProtection(PASSWORD)); - System.out.println("Retrieved entry: " + entry); + } + + KeyStore.Entry entry = keystore.getEntry(ALIAS, + new KeyStore.PasswordProtection(PASSWORD)); + System.out.println("Retrieved entry: " + entry); - SecretKey key = (SecretKey) keystore.getKey(ALIAS, PASSWORD); - SecretKeyFactory factory = - SecretKeyFactory.getInstance(key.getAlgorithm()); - PBEKeySpec keySpec = - (PBEKeySpec) factory.getKeySpec(key, PBEKeySpec.class); - char[] pwd = keySpec.getPassword(); - System.out.println("Recovered credential: " + new String(pwd)); + SecretKey key = (SecretKey) keystore.getKey(ALIAS, PASSWORD); + SecretKeyFactory factory = + SecretKeyFactory.getInstance(key.getAlgorithm()); + PBEKeySpec keySpec = + (PBEKeySpec) factory.getKeySpec(key, PBEKeySpec.class); + char[] pwd = keySpec.getPassword(); + System.out.println("Recovered credential: " + new String(pwd)); - if (!Arrays.equals(USER_PASSWORD.toCharArray(), pwd)) { - throw new Exception("Failed to recover the stored password"); - } - } finally { - new File(KEYSTORE).delete(); + if (!Arrays.equals(USER_PASSWORD.toCharArray(), pwd)) { + throw new Exception("Failed to recover the stored password"); } } diff -r a8bbd962f34a -r 41654275896d test/sun/security/pkcs12/StoreSecretKeyTest.java --- a/test/sun/security/pkcs12/StoreSecretKeyTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/sun/security/pkcs12/StoreSecretKeyTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -53,35 +53,34 @@ new File(KEYSTORE).delete(); - try { + KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(null, null); - KeyStore keystore = KeyStore.getInstance("PKCS12"); - keystore.load(null, null); + // Set entry + keystore.setEntry(ALIAS, + new KeyStore.SecretKeyEntry(generateSecretKey("AES", 128)), + new KeyStore.PasswordProtection(PASSWORD)); - // Set entry - keystore.setEntry(ALIAS, - new KeyStore.SecretKeyEntry(generateSecretKey("AES", 128)), - new KeyStore.PasswordProtection(PASSWORD)); + try (FileOutputStream outStream = new FileOutputStream(KEYSTORE)) { + System.out.println("Storing keystore to: " + KEYSTORE); + keystore.store(outStream, PASSWORD); + } - System.out.println("Storing keystore to: " + KEYSTORE); - keystore.store(new FileOutputStream(KEYSTORE), PASSWORD); - + try (FileInputStream inStream = new FileInputStream(KEYSTORE)) { System.out.println("Loading keystore from: " + KEYSTORE); - keystore.load(new FileInputStream(KEYSTORE), PASSWORD); + keystore.load(inStream, PASSWORD); System.out.println("Loaded keystore with " + keystore.size() + " entries"); - KeyStore.Entry entry = keystore.getEntry(ALIAS, - new KeyStore.PasswordProtection(PASSWORD)); - System.out.println("Retrieved entry: " + entry); + } - if (entry instanceof KeyStore.SecretKeyEntry) { - System.out.println("Retrieved secret key entry: " + - entry); - } else { - throw new Exception("Not a secret key entry"); - } - } finally { - new File(KEYSTORE).delete(); + KeyStore.Entry entry = keystore.getEntry(ALIAS, + new KeyStore.PasswordProtection(PASSWORD)); + System.out.println("Retrieved entry: " + entry); + + if (entry instanceof KeyStore.SecretKeyEntry) { + System.out.println("Retrieved secret key entry: " + entry); + } else { + throw new Exception("Not a secret key entry"); } } diff -r a8bbd962f34a -r 41654275896d test/sun/security/pkcs12/StoreTrustedCertTest.java --- a/test/sun/security/pkcs12/StoreTrustedCertTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/sun/security/pkcs12/StoreTrustedCertTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -49,59 +49,57 @@ new File(KEYSTORE).delete(); - try { - KeyStore keystore = KeyStore.getInstance("PKCS12"); - keystore.load(null, null); + KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(null, null); - Certificate cert = loadCertificate(CERT); - Set attributes = new HashSet<>(); - attributes.add(new PKCS12Attribute("1.3.5.7.9", "that's odd")); - attributes.add(new PKCS12Attribute("2.4.6.8.10", "that's even")); + Certificate cert = loadCertificate(CERT); + Set attributes = new HashSet<>(); + attributes.add(new PKCS12Attribute("1.3.5.7.9", "that's odd")); + attributes.add(new PKCS12Attribute("2.4.6.8.10", "that's even")); + + // Set trusted certificate entry + keystore.setEntry(ALIAS, + new KeyStore.TrustedCertificateEntry(cert), null); - // Set trusted certificate entry - keystore.setEntry(ALIAS, - new KeyStore.TrustedCertificateEntry(cert), null); + // Set trusted certificate entry with attributes + keystore.setEntry(ALIAS2, + new KeyStore.TrustedCertificateEntry(cert, attributes), null); - // Set trusted certificate entry with attributes - keystore.setEntry(ALIAS2, - new KeyStore.TrustedCertificateEntry(cert, attributes), null); - + try (FileOutputStream outStream = new FileOutputStream(KEYSTORE)) { System.out.println("Storing keystore to: " + KEYSTORE); - keystore.store(new FileOutputStream(KEYSTORE), PASSWORD); + keystore.store(outStream, PASSWORD); + } + try (FileInputStream inStream = new FileInputStream(KEYSTORE)) { System.out.println("Loading keystore from: " + KEYSTORE); - keystore.load(new FileInputStream(KEYSTORE), PASSWORD); + keystore.load(inStream, PASSWORD); System.out.println("Loaded keystore with " + keystore.size() + " entries"); + } - KeyStore.Entry entry = keystore.getEntry(ALIAS, null); - if (entry instanceof KeyStore.TrustedCertificateEntry) { - System.out.println("Retrieved trusted certificate entry: " + - entry); - } else { - throw new Exception("Not a trusted certificate entry"); - } - System.out.println(); + KeyStore.Entry entry = keystore.getEntry(ALIAS, null); + if (entry instanceof KeyStore.TrustedCertificateEntry) { + System.out.println("Retrieved trusted certificate entry: " + entry); + } else { + throw new Exception("Not a trusted certificate entry"); + } + System.out.println(); - entry = keystore.getEntry(ALIAS2, null); - if (entry instanceof KeyStore.TrustedCertificateEntry) { - KeyStore.TrustedCertificateEntry trustedEntry = - (KeyStore.TrustedCertificateEntry) entry; - Set entryAttributes = - trustedEntry.getAttributes(); + entry = keystore.getEntry(ALIAS2, null); + if (entry instanceof KeyStore.TrustedCertificateEntry) { + KeyStore.TrustedCertificateEntry trustedEntry = + (KeyStore.TrustedCertificateEntry) entry; + Set entryAttributes = + trustedEntry.getAttributes(); - if (entryAttributes.containsAll(attributes)) { - System.out.println("Retrieved trusted certificate entry " + - "with attributes: " + entry); - } else { - throw new Exception("Failed to retrieve entry attributes"); - } + if (entryAttributes.containsAll(attributes)) { + System.out.println("Retrieved trusted certificate entry " + + "with attributes: " + entry); } else { - throw new Exception("Not a trusted certificate entry"); + throw new Exception("Failed to retrieve entry attributes"); } - - } finally { - new File(KEYSTORE).delete(); + } else { + throw new Exception("Not a trusted certificate entry"); } } diff -r a8bbd962f34a -r 41654275896d test/sun/security/util/Oid/S11N.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/util/Oid/S11N.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,246 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4811968 6908628 8006564 + * @run main S11N check + * @summary Serialization compatibility with old versions (and fixes) + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.HashMap; +import java.util.Map; +import sun.misc.BASE64Encoder; +import sun.security.util.ObjectIdentifier; + +public class S11N { + static String[] SMALL= { + "0.0", + "1.1", + "2.2", + "1.2.3456", + "1.2.2147483647.4", + "1.2.268435456.4", + }; + + static String[] HUGE = { + "2.16.764.1.3101555394.1.0.100.2.1", + "1.2.2147483648.4", + "2.3.4444444444444444444444", + "1.2.8888888888888888.33333333333333333.44444444444444", + }; + + // Do not use j.u.Base64, the test needs to run in jdk6 + static BASE64Encoder encoder = new BASE64Encoder() { + @Override + protected int bytesPerLine() { + return 48; + } + }; + + public static void main(String[] args) throws Exception { + if (args[0].equals("check")) { + int version = Integer.valueOf(System.getProperty("java.version") + .split("\\.")[1]); + System.out.println("version is " + version); + if (version >= 7) { + for (String oid: SMALL) { + // 7 -> 7 + check(out(oid), oid); + // 6 -> 7 + check(out6(oid), oid); + } + for (String oid: HUGE) { + // 7 -> 7 + check(out(oid), oid); + } + } else { + for (String oid: SMALL) { + // 6 -> 6 + check(out(oid), oid); + // 7 -> 6 + check(out7(oid), oid); + } + for (String oid: HUGE) { + // 7 -> 6 fails for HUGE oids + boolean ok = false; + try { + check(out7(oid), oid); + ok = true; + } catch (Exception e) { + System.out.println(e); + } + if (ok) { + throw new Exception(); + } + } + } + } else { + // Generates the JDK6 serialized string inside this test, call + // $JDK7/bin/java S11N dump7 + // $JDK6/bin/java S11N dump6 + // and paste the output at the end of this test. + dump(args[0], SMALL); + // For jdk6, the following line will throw an exception, ignore it + dump(args[0], HUGE); + } + } + + // Gets the serialized form for jdk6 + private static byte[] out6(String oid) throws Exception { + return new sun.misc.BASE64Decoder().decodeBuffer(dump6.get(oid)); + } + + // Gets the serialized form for jdk7 + private static byte[] out7(String oid) throws Exception { + return new sun.misc.BASE64Decoder().decodeBuffer(dump7.get(oid)); + } + + // Gets the serialized form for this java + private static byte[] out(String oid) throws Exception { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + new ObjectOutputStream(bout).writeObject(new ObjectIdentifier(oid)); + return bout.toByteArray(); + } + + // Makes sure serialized form can be deserialized + private static void check(byte[] in, String oid) throws Exception { + ObjectIdentifier o = (ObjectIdentifier) ( + new ObjectInputStream(new ByteArrayInputStream(in)).readObject()); + if (!o.toString().equals(oid)) { + throw new Exception("Read Fail " + o + ", not " + oid); + } + } + + // dump serialized form to java code style text + private static void dump(String title, String[] oids) throws Exception { + for (String oid: oids) { + String[] base64 = encoder.encodeBuffer(out(oid)).split("\n"); + System.out.println(" " + title + ".put(\"" + oid + "\","); + for (int i = 0; i dump7 = new HashMap(); + private static Map dump6 = new HashMap(); + + static { + ////////////// PASTE BEGIN ////////////// + dump7.put("0.0", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAAnVyAAJbSU26YCZ26rKlAgAAeHAA" + + "AAACAAAAAAAAAAB1cgACW0Ks8xf4BghU4AIAAHhwAAAAAQB4"); + dump7.put("1.1", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAAnVyAAJbSU26YCZ26rKlAgAAeHAA" + + "AAACAAAAAQAAAAF1cgACW0Ks8xf4BghU4AIAAHhwAAAAASl4"); + dump7.put("2.2", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAAnVyAAJbSU26YCZ26rKlAgAAeHAA" + + "AAACAAAAAgAAAAJ1cgACW0Ks8xf4BghU4AIAAHhwAAAAAVJ4"); + dump7.put("1.2.3456", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAAA3VyAAJbSU26YCZ26rKlAgAAeHAA" + + "AAADAAAAAQAAAAIAAA2AdXIAAltCrPMX+AYIVOACAAB4cAAAAAMqmwB4"); + dump7.put("1.2.2147483647.4", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAABHVyAAJbSU26YCZ26rKlAgAAeHAA" + + "AAAEAAAAAQAAAAJ/////AAAABHVyAAJbQqzzF/gGCFTgAgAAeHAAAAAHKof///9/" + + "BHg="); + dump7.put("1.2.268435456.4", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhwAAAABHVyAAJbSU26YCZ26rKlAgAAeHAA" + + "AAAEAAAAAQAAAAIQAAAAAAAABHVyAAJbQqzzF/gGCFTgAgAAeHAAAAAHKoGAgIAA" + + "BHg="); + dump7.put("2.16.764.1.3101555394.1.0.100.2.1", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/////3NyAD5zdW4uc2VjdXJpdHkudXRp" + + "bC5PYmplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA" + + "AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAADmCFfAGLxvf1QgEAZAIB" + + "eA=="); + dump7.put("1.2.2147483648.4", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/////3NyAD5zdW4uc2VjdXJpdHkudXRp" + + "bC5PYmplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA" + + "AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAAByqIgICAAAR4"); + dump7.put("2.3.4444444444444444444444", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/////3NyAD5zdW4uc2VjdXJpdHkudXRp" + + "bC5PYmplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA" + + "AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAADFOD4e+HpNG968eOHHg="); + dump7.put("1.2.8888888888888888.33333333333333333.44444444444444", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4DAANJAAxjb21wb25lbnRMZW5MAApjb21wb25lbnRzdAASTGphdmEvbGFuZy9P" + + "YmplY3Q7WwAIZW5jb2Rpbmd0AAJbQnhw/////3NyAD5zdW4uc2VjdXJpdHkudXRp" + + "bC5PYmplY3RJZGVudGlmaWVyJEh1Z2VPaWROb3RTdXBwb3J0ZWRCeU9sZEpESwAA" + + "AAAAAAABAgAAeHB1cgACW0Ks8xf4BghU4AIAAHhwAAAAGCqP5Yzbxa6cOLubj9ek" + + "japVio3AusuOHHg="); + + dump6.put("0.0", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAJ1cgAC" + + "W0lNumAmduqypQIAAHhwAAAAAgAAAAAAAAAA"); + dump6.put("1.1", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAJ1cgAC" + + "W0lNumAmduqypQIAAHhwAAAAAgAAAAEAAAAB"); + dump6.put("2.2", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAJ1cgAC" + + "W0lNumAmduqypQIAAHhwAAAAAgAAAAIAAAAC"); + dump6.put("1.2.3456", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAN1cgAC" + + "W0lNumAmduqypQIAAHhwAAAAAwAAAAEAAAACAAANgA=="); + dump6.put("1.2.2147483647.4", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAR1cgAC" + + "W0lNumAmduqypQIAAHhwAAAABAAAAAEAAAACf////wAAAAQ="); + dump6.put("1.2.268435456.4", + "rO0ABXNyACJzdW4uc2VjdXJpdHkudXRpbC5PYmplY3RJZGVudGlmaWVyeLIO7GQX" + + "fy4CAAJJAAxjb21wb25lbnRMZW5bAApjb21wb25lbnRzdAACW0l4cAAAAAR1cgAC" + + "W0lNumAmduqypQIAAHhwAAAABAAAAAEAAAACEAAAAAAAAAQ="); + ////////////// PASTE END ////////////// + } +} diff -r a8bbd962f34a -r 41654275896d test/sun/security/util/Oid/S11N.sh --- a/test/sun/security/util/Oid/S11N.sh Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -# -# 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 -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# @test -# @bug 4811968 6908628 -# @summary Serialization compatibility with old versions (and fix) -# @author Weijun Wang -# -# set a few environment variables so that the shell-script can run stand-alone -# in the source directory - -if [ "${TESTSRC}" = "" ] ; then - TESTSRC="." -fi -if [ "${TESTCLASSES}" = "" ] ; then - TESTCLASSES="." -fi -if [ "${TESTJAVA}" = "" ] ; then - echo "TESTJAVA not set. Test cannot execute." - echo "FAILED!!!" - exit 1 -fi -if [ "${COMPILEJAVA}" = "" ]; then - COMPILEJAVA="${TESTJAVA}" -fi - -# set platform-dependent variables -PF="" - -OS=`uname -s` -case "$OS" in - SunOS ) - FS="/" - ARCH=`isainfo` - case "$ARCH" in - sparc* ) - PF="solaris-sparc" - ;; - i[3-6]86 ) - PF="solaris-i586" - ;; - amd64* ) - PF="solaris-amd64" - ;; - * ) - echo "Unsupported System: Solaris ${ARCH}" - exit 0; - ;; - esac - ;; - Linux ) - ARCH=`uname -m` - FS="/" - case "$ARCH" in - i[3-6]86 ) - PF="linux-i586" - ;; - amd64* | x86_64 ) - PF="linux-amd64" - ;; - * ) - echo "Unsupported System: Linux ${ARCH}" - exit 0; - ;; - esac - ;; - Windows* ) - FS="\\" - PF="windows-i586" - - # 'uname -m' does not give us enough information - - # should rely on $PROCESSOR_IDENTIFIER (as is done in Defs-windows.gmk), - # but JTREG does not pass this env variable when executing a shell script. - # - # execute test program - rely on it to exit if platform unsupported - - ;; - * ) - echo "Unsupported System: ${OS}" - exit 0; - ;; -esac - -echo "===================================================" -echo "Try to set ALT_JAVA_RE_JDK if you see timeout error" -echo "===================================================" - -# the test code - -${COMPILEJAVA}${FS}bin${FS}javac -target 1.4 -source 1.4 \ - -d . ${TESTSRC}${FS}SerialTest.java || exit 10 - -# You can set ALT_JAVA_RE_JDK to another location that contains the -# binaries for older JDK releases. You can set it to a non-existent -# directory to skip the interop tests between different versions. - -if [ "$ALT_JAVA_RE_JDK" = "" ]; then - JAVA_RE_JDK=/java/re/j2se -else - JAVA_RE_JDK=$ALT_JAVA_RE_JDK -fi - -OLDJAVA=" - $JAVA_RE_JDK/1.6.0/latest/binaries/${PF} - $JAVA_RE_JDK/1.5.0/latest/binaries/${PF} - $JAVA_RE_JDK/1.4.2/latest/binaries/${PF} -" - -SMALL=" - 0.0 - 1.1 - 2.2 - 1.2.3456 - 1.2.2147483647.4 - 1.2.268435456.4 -" - -HUGE=" - 2.16.764.1.3101555394.1.0.100.2.1 - 1.2.2147483648.4 - 2.3.4444444444444444444444 - 1.2.888888888888888888.111111111111111.2222222222222.33333333333333333.44444444444444 -" - -for oid in ${SMALL}; do - echo ${oid} - # new -> - ${TESTJAVA}${FS}bin${FS}java SerialTest out ${oid} > tmp.oid.serial || exit 1 - # -> new - ${TESTJAVA}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial || exit 2 - for oldj in ${OLDJAVA}; do - if [ -d ${oldj} ]; then - echo ${oldj} - # -> old - ${oldj}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial || exit 3 - # old -> - ${oldj}${FS}bin${FS}java SerialTest out ${oid} > tmp.oid.serial.old || exit 4 - # -> new - ${TESTJAVA}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial.old || exit 5 - fi - done -done - -for oid in ${HUGE}; do - echo ${oid} - # new -> - ${TESTJAVA}${FS}bin${FS}java SerialTest out ${oid} > tmp.oid.serial || exit 1 - # -> new - ${TESTJAVA}${FS}bin${FS}java SerialTest in ${oid} < tmp.oid.serial || exit 2 - for oldj in ${OLDJAVA}; do - if [ -d ${oldj} ]; then - echo ${oldj} - # -> old - ${oldj}${FS}bin${FS}java SerialTest badin < tmp.oid.serial || exit 3 - fi - done -done - -rm -f tmp.oid.serial -rm -f tmp.oid.serial.old -rm -f SerialTest.class - -for oldj in ${OLDJAVA}; do - if [ ! -d ${oldj} ]; then - echo WARNING: ${oldj} is missing. Test incomplete! > /dev/stderr - fi -done - -exit 0 diff -r a8bbd962f34a -r 41654275896d test/sun/security/util/Oid/SerialTest.java --- a/test/sun/security/util/Oid/SerialTest.java Mon Jan 28 16:29:10 2013 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * read S11.sh - */ -import java.io.*; -import sun.security.util.*; - -/** - * Test OID serialization between versions - * - * java SerialTest out oid // write a OID into System.out - * java SerialTest in oid // read from System.in and compare it with oid - * java SerialTest badin // make sure *cannot* read from System.in - */ -class SerialTest { - public static void main(String[] args) throws Exception { - if (args[0].equals("out")) - out(args[1]); - else if (args[0].equals("in")) - in(args[1]); - else - badin(); - } - - static void in(String oid) throws Exception { - ObjectIdentifier o = (ObjectIdentifier) (new ObjectInputStream(System.in).readObject()); - if (!o.toString().equals(oid)) - throw new Exception("Read Fail " + o + ", not " + oid); - } - - static void badin() throws Exception { - boolean pass = true; - try { - new ObjectInputStream(System.in).readObject(); - } catch (Exception e) { - pass = false; - } - if (pass) throw new Exception("Should fail but not"); - } - - static void out(String oid) throws Exception { - new ObjectOutputStream(System.out).writeObject(new ObjectIdentifier(oid)); - } -} diff -r a8bbd962f34a -r 41654275896d test/sun/text/resources/LocaleData --- a/test/sun/text/resources/LocaleData Mon Jan 28 16:29:10 2013 -0400 +++ b/test/sun/text/resources/LocaleData Mon Feb 04 17:29:58 2013 -0400 @@ -8794,3 +8794,6 @@ FormatData/zh_TW/islamic.DatePatterns/1=GGGGy\u5e74M\u6708d\u65e5 FormatData/zh_TW/islamic.DatePatterns/2=GGGGy/M/d FormatData/zh_TW/islamic.DatePatterns/3=GGGGy/M/d + +# bug 7114053 +LocaleNames/sq/sq=shqip diff -r a8bbd962f34a -r 41654275896d test/sun/text/resources/LocaleDataTest.java --- a/test/sun/text/resources/LocaleDataTest.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/sun/text/resources/LocaleDataTest.java Mon Feb 04 17:29:58 2013 -0400 @@ -35,6 +35,7 @@ * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 * 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495 * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 + * 7114053 * @summary Verify locale data * */ diff -r a8bbd962f34a -r 41654275896d test/tools/launcher/Arrrghs.java --- a/test/tools/launcher/Arrrghs.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/tools/launcher/Arrrghs.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -309,6 +309,7 @@ checkArgumentParsing("../../*", "../../*"); checkArgumentParsing("..\\..\\", "..\\..\\"); checkArgumentParsing("../../", "../../"); + checkArgumentParsing("a b\\ c", "a", "b\\", "c"); } private void initEmptyDir(File emptyDir) throws IOException { diff -r a8bbd962f34a -r 41654275896d test/tools/launcher/VersionCheck.java --- a/test/tools/launcher/VersionCheck.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/tools/launcher/VersionCheck.java Mon Feb 04 17:29:58 2013 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ // tools that do not accept -J-option static final String[] BLACKLIST_JOPTION = { "controlpanel", + "jabswitch", "java-rmi", "java-rmi.cgi", "java", diff -r a8bbd962f34a -r 41654275896d test/tools/pack200/InstructionTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/pack200/InstructionTests.java Mon Feb 04 17:29:58 2013 -0400 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.io.File; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.List; +import static java.nio.file.StandardOpenOption.*; +import java.util.regex.Pattern; + +/* + * @test + * @bug 8003549 + * @summary tests class files instruction formats introduced in JSR-335 + * @compile -XDignore.symbol.file Utils.java InstructionTests.java + * @run main InstructionTests + * @author ksrini + */ +public class InstructionTests { + public static void main(String... args) throws Exception { + testInvokeOpCodes(); + } + /* + * the following should produce invokestatic and invokespecial + * on InterfaceMethodRefs vs. MethodRefs, packer/unpacker should work + */ + static void testInvokeOpCodes() throws Exception { + List scratch = new ArrayList<>(); + final String fname = "A"; + String javaFileName = fname + Utils.JAVA_FILE_EXT; + scratch.add("interface IntIterator {"); + scratch.add(" default void forEach(){}"); + scratch.add(" static void next() {}"); + scratch.add("}"); + scratch.add("class A implements IntIterator {"); + scratch.add("public void forEach(Object o){"); + scratch.add("IntIterator.super.forEach();"); + scratch.add("IntIterator.next();"); + scratch.add("}"); + scratch.add("}"); + File cwd = new File("."); + File javaFile = new File(cwd, javaFileName); + Files.write(javaFile.toPath(), scratch, Charset.defaultCharset(), + CREATE, TRUNCATE_EXISTING); + + // make sure we have -g so that we compare LVT and LNT entries + Utils.compiler("-g", javaFile.getName()); + + // jar the file up + File testjarFile = new File(cwd, "test" + Utils.JAR_FILE_EXT); + Utils.jar("cvf", testjarFile.getName(), "."); + + // pack using --repack + File outjarFile = new File(cwd, "out" + Utils.JAR_FILE_EXT); + scratch.clear(); + scratch.add(Utils.getPack200Cmd()); + scratch.add("-J-ea"); + scratch.add("-J-esa"); + scratch.add("--repack"); + scratch.add(outjarFile.getName()); + scratch.add(testjarFile.getName()); + List output = Utils.runExec(scratch); + // TODO remove this when we get bc escapes working correctly + // this test anyhow would fail at that time + findString("WARNING: Passing.*" + fname + Utils.CLASS_FILE_EXT, + output); + + Utils.doCompareVerify(testjarFile, outjarFile); + } + + static boolean findString(String str, List list) { + Pattern p = Pattern.compile(str); + for (String x : list) { + if (p.matcher(x).matches()) + return true; + } + throw new RuntimeException("Error: " + str + " not found in output"); + } +} diff -r a8bbd962f34a -r 41654275896d test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java --- a/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java Mon Jan 28 16:29:10 2013 -0400 +++ b/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java Mon Feb 04 17:29:58 2013 -0400 @@ -57,8 +57,10 @@ import com.sun.tools.classfile.Opcode; import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute; +import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute; import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute; +import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute; import com.sun.tools.classfile.Signature_attribute; import com.sun.tools.classfile.SourceDebugExtension_attribute; import com.sun.tools.classfile.SourceFile_attribute; @@ -1214,6 +1216,21 @@ p.add(e); return null; } + + /* + * TODO + * add these two for now to keep the compiler happy, we will implement + * these along with the JSR-308 changes. + */ + @Override + public Element visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute rvta, Element p) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Element visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute rita, Element p) { + throw new UnsupportedOperationException("Not supported yet."); + } } class StackMapVisitor implements StackMapTable_attribute.stack_map_frame.Visitor {