提交 0321af12 编写于 作者: V valeriep

Merge

......@@ -209,3 +209,4 @@ ac519af51769e92c51b597a730974e8607357709 jdk8-b83
296676d534c52888c36e305a2bf7f345c4ca70f8 jdk8-b85
7989cd0cc3a9149864589438ee2c949015d8aa9a jdk8-b86
d5228e624826a10ccc5b05f30ad8d839b58fe48d jdk8-b87
8dbb4b159e04de3c447c9242c70505e71f8624c7 jdk8-b88
......@@ -31,13 +31,6 @@ BUILDDIR = ../..
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
ifndef OPENJDK
ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,)
ifneq ("$(ORG_EXISTS)", "")
SCRIPT_SUBDIR = script
endif
endif
# jarsigner is part of JRE
SUBDIRS = java security net/ssl jarsigner
......
#
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
BUILDDIR = ../../..
PACKAGE = com.sun.script
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
AUTO_FILES_JAVA_DIRS = com/sun/script
#
# Files that need to be copied
#
SERVICEDIR = $(CLASSBINDIR)/META-INF/services
FILES_copy = \
$(SERVICEDIR)/javax.script.ScriptEngineFactory
include $(BUILDDIR)/common/Classes.gmk
all: classes copy-files
#
# Copy the service provider configuration file into the resource
# directory.
#
copy-files: $(FILES_copy)
$(SERVICEDIR)/%: $(SHARE_SRC)/classes/com/sun/script/javascript/META-INF/services/%
$(install-file)
.PHONY: copy-files
clean::
$(RM) -r $(CLASSDESTDIR)/com/sun/script/javascript
$(RM) $(FILES_copy)
......@@ -31,12 +31,6 @@ BUILDDIR = ..
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
# Rhino/Mozilla java sources
ORG_EXISTS := $(call DirExists,$(CLOSED_SRC)/share/classes/sun/org,,)
ifneq ("$(ORG_EXISTS)", "")
ORG_SUBDIR = org
endif
# Non windows subdirs
ifneq ($(PLATFORM), windows)
ifndef OPENJDK
......@@ -83,7 +77,7 @@ SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \
$(LWAWT_PRE_SUBDIR) $(DISPLAY_LIBS) $(DGA_SUBDIR) $(LWAWT_SUBDIR) \
jawt font jpeg cmm $(DISPLAY_TOOLS)
SUBDIRS_management = management
SUBDIRS_misc = $(ORG_SUBDIR) rmi tracing
SUBDIRS_misc = rmi tracing
SUBDIRS_tools = native2ascii serialver tools jconsole
ifndef OPENJDK
......
#
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building Mozilla modules
#
BUILDDIR = ../..
PRODUCT = org
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = mozilla
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
$(SUBDIRS-loop)
#
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building Mozilla JavaScript modules
#
BUILDDIR = ../../..
PRODUCT = org
include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = javascript
include $(BUILDDIR)/common/Subdirs.gmk
all build clean clobber::
$(SUBDIRS-loop)
#
# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building all of sun.org.mozilla.javascript.internal.*
#
BUILDDIR = ../../../..
PACKAGE = sun.org.mozilla.javascript.internal
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
AUTO_FILES_JAVA_DIRS = sun/org/mozilla/javascript/internal
RESOURCEDIR = \
$(CLASSDESTDIR)/sun/org/mozilla/javascript/internal/resources
FILES_copy = \
$(RESOURCEDIR)/Messages.properties \
$(RESOURCEDIR)/Messages_fr.properties
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
all: classes copy-files
#
# Copy resource messages file for Rhino JavaScript interpreter
#
copy-files: $(FILES_copy)
$(RESOURCEDIR)/%: $(CLOSED_SRC)/share/classes/sun/org/mozilla/javascript/internal/resources/%
$(install-file)
.PHONY: copy-files
clean clobber::
$(RM) -rf $(CLASSDESTDIR)/sun/org/mozilla/javascript
......@@ -30,7 +30,5 @@ sun.security.krb5.Realm=sun.security.ssl.krb5.KerberosClientKeyExchangeImpl,comp
# Residual references to java.beans.
# The RemoveMethods tool does not yet purge the constant pool.
# Rhino is due to be replaced so not worth addressing this dependency now.
#
java.beans.PropertyChangeListener=java.util.logging.LogManager,sun.org.mozilla.javascript.internal.Context,compact1,compact2,compact3
java.beans.PropertyChangeEvent=sun.org.mozilla.javascript.internal.Context,compact3
java.beans.PropertyChangeListener=java.util.logging.LogManager,compact1,compact2,compact3
......@@ -63,7 +63,12 @@ WIN_AWT_LIB := $(JDK_OUTPUTDIR)/objs/libawt/awt.lib
# Use this variable to set DEBUG_SYMBOLS true on windows for all libraries, but
# not on other platforms.
ifeq ($(OPENJDK_TARGET_OS), windows)
WINDOWS_ONLY := true
DEBUG_ALL_BINARIES := true
endif
# Build everything with debugging on OpenJDK
ifdef OPENJDK
DEBUG_ALL_BINARIES := true
endif
#
......@@ -91,7 +96,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM,\
-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
CFLAGS_windows_debug:=-DLOGGING,\
ARFLAGS:=$(ARFLAGS),\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
else
......@@ -105,7 +111,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFDLIBM_MAC,\
CFLAGS:=$(CFLAGS_JDKLIB) \
-I$(JDK_TOPDIR)/src/share/native/java/lang/fdlibm/include,\
LDFLAGS:=-nostdlib -r -arch x86_64,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfdlibm,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBFDLIBM := $(JDK_OUTPUTDIR)/objs/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX)
$(BUILD_LIBFDLIBM) : $(BUILD_LIBFDLIBM_MAC)
......@@ -257,7 +264,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAVA,\
-D "JDK_FTYPE=0x2L",\
REORDER:=$(LIBJAVA_REORDER), \
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjava,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJAVA)
......@@ -308,7 +315,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE,\
-D "JDK_INTERNAL_NAME=mlib_image" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBMLIB_IMAGE) : $(BUILD_LIBJAVA)
......@@ -431,7 +438,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBMLIB_IMAGE_V,\
$(BUILD_LIBMLIB_LDLIBS) -ljava -ljvm \
$(call SET_SHARED_LIBRARY_ORIGIN),\
LDFLAGS_SUFFIX_solaris:=-lc,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libmlib_image_v,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBMLIB_IMAGE_V): $(BUILD_LIBJAVA)
......@@ -739,7 +747,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT,\
-D "JDK_INTERNAL_NAME=awt" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBAWT) : $(BUILD_LIBJAVA)
......@@ -895,7 +903,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_XAWT,\
-D "JDK_FNAME=xawt.dll" \
-D "JDK_INTERNAL_NAME=xawt" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_xawt))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_xawt,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBAWT_XAWT) : $(BUILD_LIBJAVA)
......@@ -956,7 +965,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBZIP,\
-D "JDK_INTERNAL_NAME=zip" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libzip,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBZIP) : $(BUILD_LIBJAVA)
......@@ -986,7 +995,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK,\
-D "JDK_FNAME=unpack.dll" \
-D "JDK_INTERNAL_NAME=unpack" \
-D "JDK_FTYPE=0x2L",\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBUNPACK) : $(BUILD_LIBJAVA)
......@@ -1100,7 +1109,7 @@ ifeq ($(OPENJDK_TARGET_OS),windows)
-D "JDK_INTERNAL_NAME=dt_shmem" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdt_shmem,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBDT_SHMEM)
......@@ -1134,7 +1143,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJDWP,\
-D "JDK_INTERNAL_NAME=jdwp" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjdwp,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJDWP) : $(BUILD_LIBJAVA)
......@@ -1175,7 +1184,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJAAS,\
-D "JDK_INTERNAL_NAME=$(LIBJAAS_NAME)" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjaas,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJAAS) : $(BUILD_LIBJAVA)
......@@ -1240,7 +1249,7 @@ BUILD_LIBRARIES += $(BUILD_LIBJSDT)
-D "JDK_INTERNAL_NAME=lcms" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/liblcms,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBLCMS)
......@@ -1300,7 +1309,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJPEG,\
-D "JDK_FTYPE=0x2L",\
REORDER:=$(BUILD_LIBJPEG_REORDER),\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjpeg,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJPEG) : $(BUILD_LIBJAVA)
......@@ -1377,7 +1386,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER,\
-D "JDK_INTERNAL_NAME=fontmanager" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libfontmanager,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBFONTMANAGER) : $(BUILD_LIBAWT)
......@@ -1434,7 +1443,7 @@ ifndef OPENJDK
-D "JDK_INTERNAL_NAME=t2k" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libt2k,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
# t2k is linked against fontmanager
$(BUILD_LIBT2K) : $(BUILD_LIBFONTMANAGER)
......@@ -1472,7 +1481,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
-D "JDK_INTERNAL_NAME=jawt" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJAWT) : $(BUILD_LIBAWT)
......@@ -1521,7 +1530,8 @@ else # OPENJDK_TARGET_OS not windows
LDFLAGS_SUFFIX_solaris:=$(JAWT_LIBS) $(LDFLAGS_JDKLIB_SUFFIX) -lXrender,\
LDFLAGS_SUFFIX_macosx:=-Xlinker -rpath -Xlinker @loader_path $(JAWT_LIBS) \
-framework Cocoa $(LDFLAGS_JDKLIB_SUFFIX),\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjawt,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
ifndef BUILD_HEADLESS_ONLY
$(BUILD_LIBJAWT) : $(BUILD_LIBAWT_XAWT)
......@@ -1828,7 +1838,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNET,\
-D "JDK_INTERNAL_NAME=net" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnet,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBNET) : $(BUILD_LIBJAVA)
......@@ -1965,7 +1975,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBNIO,\
-D "JDK_INTERNAL_NAME=nio" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libnio,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBNIO)
......@@ -2002,7 +2012,8 @@ ifeq ($(OPENJDK_TARGET_OS_API),posix)
LDFLAGS_SUFFIX_posix:=-lnio -lnet,\
LDFLAGS_SUFFIX_solaris:=-lsocket -ljava -ljvm -lc,\
LDFLAGS_SUFFIX_macosx:=-ljava -ljvm,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsctp,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBSCTP)
......@@ -2126,7 +2137,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJLI,\
-D "JDK_INTERNAL_NAME=jli" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJLI)
......@@ -2143,7 +2154,8 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
OPTIMIZATION:=HIGH, \
CFLAGS:=$(STATIC_LIBRARY_FLAGS) $(LIBJLI_CFLAGS),\
ARFLAGS:=$(ARFLAGS),\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJLI_STATIC)
......@@ -2161,7 +2173,8 @@ else ifeq ($(OPENJDK_TARGET_OS),macosx)
OPTIMIZATION:=HIGH, \
CFLAGS:=$(CFLAGS_JDKLIB) $(LIBJLI_CFLAGS),\
LDFLAGS:=-nostdlib -r,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjli_static,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(JDK_OUTPUTDIR)/objs/libjli_static.a : $(BUILD_LIBJLI_STATIC)
$(call install-file)
......@@ -2192,7 +2205,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJFR,\
-D "JDK_INTERNAL_NAME=jfr" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjfr,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJFR)
......@@ -2244,7 +2257,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBKCMS,\
-D "JDK_INTERNAL_NAME=kcms" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkcms,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBKCMS) : $(BUILD_LIBJAVA)
......@@ -2279,7 +2292,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBSUNWJDGA, \
LDFLAGS:=$(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_SUFFIX:=-L$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR) -ldga -lX11 $(LIBDL) -lc, \
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunwjdga))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunwjdga,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBSUNWJDGA)
......@@ -2369,7 +2383,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS,\
LDFLAGS_SUFFIX_linux:=-ljvm -lawt -lm $(LIBDL) -ljava,\
LDFLAGS_SUFFIX_solaris:=$(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc,\
LDFLAGS_SUFFIX_macosx:=-ljvm $(LIBCXX) -lawt $(LIBDL) -ljava,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_headless,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBAWT_HEADLESS) : $(BUILD_LIBAWT)
......@@ -2462,7 +2477,7 @@ $(eval $(call SetupNativeCompilation,LIBSPLASHSCREEN,\
-D "JDK_INTERNAL_NAME=splashscreen" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsplashscreen,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(LIBSPLASHSCREEN)
......@@ -2504,7 +2519,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBDCPR,\
-D "JDK_INTERNAL_NAME=dcpr" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libdcpr,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBDCPR) : $(BUILD_LIBJAVA)
......@@ -2538,7 +2553,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PCSC,\
-D "JDK_INTERNAL_NAME=j2pcsc" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pcsc,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJ2PCSC)
......@@ -2560,7 +2575,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2GSS,\
$(call SET_SHARED_LIBRARY_ORIGIN),\
LDFLAGS_SUFFIX:=$(LIBDL),\
LDFLAGS_SUFFIX_solaris:=-lc,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2gss))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2gss,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJ2GSS)
endif
......@@ -2599,7 +2615,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBKRB5,\
-D "JDK_INTERNAL_NAME=$(BUILD_LIBKRB5_NAME)" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libkrb5,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBKRB5)
endif
......@@ -2625,7 +2641,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBSUNMSCAPI,\
-D "JDK_INTERNAL_NAME=sunmscapi" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunmscapi,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBSUNMSCAPI)
endif
......@@ -2657,7 +2673,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11,\
-D "JDK_INTERNAL_NAME=j2pkcs11" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2pkcs11,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBJ2PKCS11)
......@@ -2703,7 +2719,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBSUNEC,\
-D "JDK_INTERNAL_NAME=sunec" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libsunec,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBSUNEC)
endif
......@@ -2847,7 +2863,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND,\
-D "JDK_INTERNAL_NAME=jsound" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsound,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJSOUND) : $(BUILD_LIBJAVA)
......@@ -2882,7 +2898,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDALSA,\
LDFLAGS:=$(LDFLAGS_JDKLIB)\
$(call SET_SHARED_LIBRARY_ORIGIN),\
LDFLAGS_SUFFIX:=-lasound -ljava -ljvm,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundalsa,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJSOUNDALSA) : $(BUILD_LIBJAVA)
......@@ -2915,7 +2932,7 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDDS,\
-D "JDK_INTERNAL_NAME=jsoundds" \
-D "JDK_FTYPE=0x2L",\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjsoundds,\
DEBUG_SYMBOLS:=$(WINDOWS_ONLY)))
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJSOUNDDS) : $(BUILD_LIBJAVA)
......@@ -2940,7 +2957,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2UCRYPTO,\
LDFLAGS:=$(LDFLAGS_JDKLIB),\
LDFLAGS_SUFFIX:=$(LIBDL),\
LDFLAGS_SUFFIX_solaris:=-lc,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libj2ucrypto,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBJ2UCRYPTO) : $(BUILD_LIBJAVA)
......@@ -2970,7 +2988,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAPPLESCRIPTENGINE,\
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-framework JavaNativeFoundation \
$(LDFLAGS_JDKLIB_SUFFIX),\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libAppleScriptEngine,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(BUILD_LIBAPPLESCRIPTENGINE) : $(BUILD_LIBJAVA)
......@@ -3009,7 +3028,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBOSXAPP,\
-framework OpenGL \
-framework IOSurface \
-framework QuartzCore, \
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxapp))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxapp,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBOSXAPP)
......@@ -3049,7 +3069,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBOSX,\
-framework Security \
-framework SystemConfiguration \
$(LDFLAGS_JDKLIB_SUFFIX), \
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosx))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosx,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBOSX)
......@@ -3182,7 +3203,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_LWAWT,\
-framework JavaRuntimeSupport \
-framework OpenGL \
-framework QuartzCore -ljava,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libawt_lwawt,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBAWT_LWAWT)
......@@ -3222,7 +3244,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBOSXUI,\
-framework JavaNativeFoundation \
-framework JavaRuntimeSupport \
-ljava -ljvm,\
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxui))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libosxui,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
BUILD_LIBRARIES += $(BUILD_LIBOSXUI)
......@@ -3262,7 +3285,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC32,\
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-framework JavaNativeFoundation \
-lffi, \
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc32))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc32,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC64,\
LIBRARY:=JObjC,\
......@@ -3286,7 +3310,8 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJOBJC64,\
-F/System/Library/Frameworks/JavaVM.framework/Frameworks \
-framework JavaNativeFoundation \
-lffi, \
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc64))
OBJECT_DIR:=$(JDK_OUTPUTDIR)/objs/libjobjc64,\
DEBUG_SYMBOLS:=$(DEBUG_ALL_BINARIES)))
$(INSTALL_LIBRARIES_HERE)/$(LIBRARY_PREFIX)JObjC$(SHARED_LIBRARY_SUFFIX): $(BUILD_LIBJOBJC32) $(BUILD_LIBJOBJC64)
$(LIPO) -create -output $@ $(BUILD_LIBJOBJC32) $(BUILD_LIBJOBJC64)
......
......@@ -458,24 +458,6 @@ endif # OPENJDK
ifndef OPENJDK
JS_RESOURCES_FILES := Messages.properties Messages_fr.properties
JS_RESOURCES_SRC_DIR := $(JDK_TOPDIR)/src/closed/share/classes/sun/org/mozilla/javascript/internal/resources
JS_RESOURCES_DST_DIR := $(JDK_OUTPUTDIR)/classes/sun/org/mozilla/javascript/internal/resources
JS_RESOURCES_SRC := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_SRC_DIR)/$(F))
JS_RESOURCES_DST := $(foreach F,$(JS_RESOURCES_FILES),$(JS_RESOURCES_DST_DIR)/$(F))
$(JS_RESOURCES_DST_DIR)/% : $(JS_RESOURCES_SRC_DIR)/%
$(call install-file)
COPY_FILES += $(JS_RESOURCES_DST)
endif
##########################################################################################
ifndef OPENJDK
#
# Solaris X11 Direct Graphics Access library
#
......
......@@ -172,10 +172,6 @@ ifneq ($(ALL_META-INF_DIRS_targetapi),)
else
ALL_META-INF_DIRS:=$(ALL_META-INF_DIRS_share)
endif
# Filter out META-INF dirs that shouldn't be included
ifdef OPENJDK
ALL_META-INF_DIRS:=$(filter-out %com/sun/script/javascript/META-INF,$(ALL_META-INF_DIRS))
endif
ifndef OPENJDK
ALL_META-INF_DIRS += $(JDK_TOPDIR)/src/closed/share/classes/sun/java2d/cmm/kcms/META-INF
......
......@@ -86,10 +86,15 @@ ifneq ($(COMPILE_TYPE),cross)
$(MKDIR) -p $(@D)
$(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $*
# use -m32/-m64 only if the compiler supports it
ifeq ($(COMPILER_SUPPORTS_TARGET_BITS_FLAG),true)
MEMORY_MODEL_FLAG="-m$*"
endif
# Compile the C code into an executable.
$(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c
$(MKDIR) -p $(@D)
(cd $(@D) && $(CC) -m$* -o $@ $< \
(cd $(@D) && $(CC) $(MEMORY_MODEL_FLAG) -o $@ $< \
$(X_CFLAGS) \
$(X_LIBS) \
-I$(JDK_OUTPUTDIR)/include \
......
......@@ -352,16 +352,22 @@ ifneq ($(OPENJDK_TARGET_OS),windows)
JDK_MAN_PAGES += jvisualvm.1
endif
ifndef OPENJDK
MAN_SRC_BASEDIR:=$(JDK_TOPDIR)/src/closed
else
MAN_SRC_BASEDIR:=$(JDK_TOPDIR)/src
endif
ifeq ($(OPENJDK_TARGET_OS), linux)
MAN_SRC_DIR:=$(JDK_TOPDIR)/src/linux/doc
MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/linux/doc
MAN1_SUBDIR:=man
endif
ifeq ($(OPENJDK_TARGET_OS), solaris)
MAN_SRC_DIR:=$(JDK_TOPDIR)/src/solaris/doc
MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/solaris/doc
MAN1_SUBDIR:=sun/man/man1
endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
MAN_SRC_DIR:=$(JDK_TOPDIR)/src/bsd/doc
MAN_SRC_DIR:=$(MAN_SRC_BASEDIR)/bsd/doc
MAN1_SUBDIR:=man
JDK_MAN_PAGES := $(filter-out jcmd.1, $(JDK_MAN_PAGES))
JDK_MAN_PAGES := $(filter-out jvisualvm.1, $(JDK_MAN_PAGES))
......
......@@ -57,6 +57,7 @@ PROFILE_1_RTJAR_INCLUDE_PACKAGES := \
java/time \
java/util \
javax/net \
javax/script \
javax/security \
jdk \
sun/invoke \
......@@ -111,7 +112,6 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
com/sun/nio/sctp \
com/sun/org/apache/xml/internal/security \
com/sun/rowset \
com/sun/script \
com/sun/security/auth \
com/sun/security/jgss \
com/sun/security/ntlm \
......@@ -125,7 +125,6 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
javax/lang/model \
javax/management \
javax/naming \
javax/script \
javax/security/auth/kerberos \
javax/security/sasl \
javax/smartcardio \
......@@ -140,7 +139,6 @@ PROFILE_3_RTJAR_INCLUDE_PACKAGES := \
sun/net/www/protocol/http/ntlm \
sun/net/www/protocol/http/spnego \
sun/nio/ch/sctp \
sun/org/mozilla \
sun/security/acl \
sun/security/jgss \
sun/security/krb5 \
......@@ -161,10 +159,6 @@ PROFILE_3_RTJAR_EXCLUDE_TYPES := \
javax/management/remote/rmi/_RMIServerImpl_Tie.class \
javax/management/remote/rmi/_RMIServer_Stub.class
PROFILE_3_INCLUDE_METAINF_SERVICES := \
META-INF/services/javax.script.ScriptEngineFactory
FULL_JRE_RTJAR_INCLUDE_PACKAGES := \
com/oracle \
com/sun/accessibility/internal/resources \
......
......@@ -35,10 +35,18 @@ import java.util.Objects;
import sun.java2d.opengl.CGLGraphicsConfig;
public final class CGraphicsDevice extends GraphicsDevice {
public final class CGraphicsDevice extends GraphicsDevice
implements DisplayChangedListener {
// CoreGraphics display ID
private final int displayID;
/**
* CoreGraphics display ID. This identifier can become non-valid at any time
* therefore methods, which is using this id should be ready to it.
*/
private volatile int displayID;
private volatile Insets screenInsets;
private volatile double xResolution;
private volatile double yResolution;
private volatile int scale;
// Array of all GraphicsConfig instances for this device
private final GraphicsConfiguration[] configs;
......@@ -51,7 +59,7 @@ public final class CGraphicsDevice extends GraphicsDevice {
// Save/restore DisplayMode for the Full Screen mode
private DisplayMode originalMode;
public CGraphicsDevice(int displayID) {
public CGraphicsDevice(final int displayID) {
this.displayID = displayID;
configs = new GraphicsConfiguration[] {
CGLGraphicsConfig.getConfig(this, 0)
......@@ -89,7 +97,7 @@ public final class CGraphicsDevice extends GraphicsDevice {
*/
@Override
public String getIDstring() {
return "Display " + this.displayID;
return "Display " + displayID;
}
/**
......@@ -104,15 +112,37 @@ public final class CGraphicsDevice extends GraphicsDevice {
}
public double getXResolution() {
return nativeGetXResolution(displayID);
return xResolution;
}
public double getYResolution() {
return nativeGetYResolution(displayID);
return yResolution;
}
public Insets getScreenInsets() {
return nativeGetScreenInsets(displayID);
return screenInsets;
}
public int getScaleFactor() {
return scale;
}
public void invalidate(final int defaultDisplayID) {
displayID = defaultDisplayID;
}
@Override
public void displayChanged() {
xResolution = nativeGetXResolution(displayID);
yResolution = nativeGetYResolution(displayID);
screenInsets = nativeGetScreenInsets(displayID);
scale = (int) nativeGetScaleFactor(displayID);
//TODO configs/fullscreenWindow/modes?
}
@Override
public void paletteChanged() {
// devices do not need to react to this event.
}
/**
......@@ -219,10 +249,6 @@ public final class CGraphicsDevice extends GraphicsDevice {
return nativeGetDisplayModes(displayID);
}
public int getScaleFactor() {
return (int) nativeGetScaleFactor(displayID);
}
private static native double nativeGetScaleFactor(int displayID);
private static native void nativeSetDisplayMode(int displayID, int w, int h, int bpp, int refrate);
......
/*
* 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
......@@ -26,19 +26,20 @@
package sun.awt;
import java.awt.*;
import java.awt.print.*;
import java.util.*;
import sun.java2d.*;
/**
* This is an implementation of a GraphicsEnvironment object for the default local GraphicsEnvironment used by the Java
* Runtime Environment for Mac OS X GUI environments.
* This is an implementation of a GraphicsEnvironment object for the default
* local GraphicsEnvironment used by the Java Runtime Environment for Mac OS X
* GUI environments.
*
* @see GraphicsDevice
* @see GraphicsConfiguration
*/
public class CGraphicsEnvironment extends SunGraphicsEnvironment {
public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
// Global initialization of the Cocoa runtime.
private static native void initCocoa();
......@@ -53,7 +54,8 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
private static native int getMainDisplayID();
/**
* Noop function that just acts as an entry point for someone to force a static initialization of this class.
* Noop function that just acts as an entry point for someone to force a
* static initialization of this class.
*/
public static void init() { }
......@@ -78,8 +80,9 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
}
/**
* Register the instance with CGDisplayRegisterReconfigurationCallback()
* The registration uses a weak global reference -- if our instance is garbage collected, the reference will be dropped.
* Register the instance with CGDisplayRegisterReconfigurationCallback().
* The registration uses a weak global reference -- if our instance is
* garbage collected, the reference will be dropped.
*
* @return Return the registration context (a pointer).
*/
......@@ -91,7 +94,7 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
private native void deregisterDisplayReconfiguration(long context);
/** Available CoreGraphics displays. */
private final Map<Integer, CGraphicsDevice> devices = new HashMap<Integer, CGraphicsDevice>();
private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);
/** Reference to the display reconfiguration callback context. */
private final long displayReconfigContext;
......@@ -118,11 +121,18 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
/**
* Called by the CoreGraphics Display Reconfiguration Callback.
*
* @param displayId
* CoreGraphics displayId
* @param displayId CoreGraphics displayId
* @param removed true if displayId was removed, false otherwise.
*/
void _displayReconfiguration(long displayId) {
displayChanged();
void _displayReconfiguration(final int displayId, final boolean removed) {
synchronized (this) {
if (removed && devices.containsKey(displayId)) {
final CGraphicsDevice gd = devices.remove(displayId);
gd.invalidate(getMainDisplayID());
gd.displayChanged();
}
}
initDevices();
}
@Override
......@@ -135,31 +145,30 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
}
/**
* (Re)create all CGraphicsDevices
*
* @return
* (Re)create all CGraphicsDevices, reuses a devices if it is possible.
*/
private synchronized void initDevices() {
devices.clear();
int mainID = getMainDisplayID();
// initialization of the graphics device may change
// list of displays on hybrid systems via an activation
// of discrete video.
// So, we initialize the main display first, and then
// retrieve actual list of displays.
CGraphicsDevice mainDevice = new CGraphicsDevice(mainID);
final int[] displayIDs = getDisplayIDs();
private void initDevices() {
synchronized (this) {
final Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
devices.clear();
int mainID = getMainDisplayID();
// initialization of the graphics device may change
// list of displays on hybrid systems via an activation
// of discrete video.
// So, we initialize the main display first, and then
// retrieve actual list of displays.
if (!old.containsKey(mainID)) {
old.put(mainID, new CGraphicsDevice(mainID));
}
for (int displayID : displayIDs) {
if (displayID != mainID) {
devices.put(displayID, new CGraphicsDevice(displayID));
} else {
devices.put(mainID, mainDevice);
for (final int id : getDisplayIDs()) {
devices.put(id, old.containsKey(id) ? old.get(id)
: new CGraphicsDevice(id));
}
}
displayChanged();
}
@Override
......@@ -167,7 +176,7 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
final int mainDisplayID = getMainDisplayID();
CGraphicsDevice d = devices.get(mainDisplayID);
if (d == null) {
// we do not exepct that this may happen, the only responce
// we do not expect that this may happen, the only response
// is to re-initialize the list of devices
initDevices();
......
......@@ -87,18 +87,22 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
private final T target;
// Container peer. It may not be the peer of the target's direct
// parent, for example, in the case of hw/lw mixing. However,
// let's skip this scenario for the time being. We also assume
// the container peer is not null, which might also be false if
// addNotify() is called for a component outside of the hierarchy.
// The exception is LWWindowPeers: their parents are always null
private LWContainerPeer containerPeer;
// Handy reference to the top-level window peer. Window peer is
// borrowed from the containerPeer in constructor, and should also
// be updated when the component is reparented to another container
private LWWindowPeer windowPeer;
/**
* Container peer. It may not be the peer of the target's direct parent, for
* example, in the case of hw/lw mixing. However, let's skip this scenario
* for the time being. We also assume the container peer is not null, which
* might also be false if addNotify() is called for a component outside of
* the hierarchy. The exception is LWWindowPeers: their containers are
* always null
*/
private final LWContainerPeer containerPeer;
/**
* Handy reference to the top-level window peer. Window peer is borrowed
* from the containerPeer in constructor, and should also be updated when
* the component is reparented to another container
*/
private final LWWindowPeer windowPeer;
private final AtomicBoolean disposed = new AtomicBoolean(false);
......@@ -183,13 +187,13 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
this.target = target;
this.platformComponent = platformComponent;
initializeContainerPeer();
// Container peer is always null for LWWindowPeers, so
// windowPeer is always null for them as well. On the other
// hand, LWWindowPeer shouldn't use windowPeer at all
if (containerPeer != null) {
windowPeer = containerPeer.getWindowPeerOrSelf();
}
final Container container = SunToolkit.getNativeContainer(target);
containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(container);
windowPeer = containerPeer != null ? containerPeer.getWindowPeerOrSelf()
: null;
// don't bother about z-order here as updateZOrder()
// will be called from addNotify() later anyway
if (containerPeer != null) {
......@@ -356,15 +360,6 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
return containerPeer;
}
// Just a helper method
// Overridden in LWWindowPeer to skip containerPeer initialization
protected void initializeContainerPeer() {
Container parent = LWToolkit.getNativeContainer(target);
if (parent != null) {
containerPeer = (LWContainerPeer) LWToolkit.targetToPeer(parent);
}
}
public PlatformWindow getPlatformWindow() {
LWWindowPeer windowPeer = getWindowPeer();
return windowPeer.getPlatformWindow();
......
......@@ -41,7 +41,7 @@ import sun.util.logging.PlatformLogger;
public class LWWindowPeer
extends LWContainerPeer<Window, JComponent>
implements WindowPeer, FramePeer, DialogPeer, FullScreenCapable
implements FramePeer, DialogPeer, FullScreenCapable, DisplayChangedListener
{
public static enum PeerType {
SIMPLEWINDOW,
......@@ -189,6 +189,7 @@ public class LWWindowPeer
if (getSurfaceData() == null) {
replaceSurfaceData(false);
}
activateDisplayListener();
}
// Just a helper method
......@@ -201,15 +202,11 @@ public class LWWindowPeer
return this;
}
@Override
protected void initializeContainerPeer() {
// No-op as LWWindowPeer doesn't have any containerPeer
}
// ---- PEER METHODS ---- //
@Override
protected void disposeImpl() {
deactivateDisplayListener();
SurfaceData oldData = getSurfaceData();
synchronized (surfaceDataLock){
surfaceData = null;
......@@ -880,6 +877,18 @@ public class LWWindowPeer
// ---- UTILITY METHODS ---- //
private void activateDisplayListener() {
final GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
((SunGraphicsEnvironment) ge).addDisplayChangedListener(this);
}
private void deactivateDisplayListener() {
final GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
((SunGraphicsEnvironment) ge).removeDisplayChangedListener(this);
}
private void postWindowStateChangedEvent(int newWindowState) {
if (getTarget() instanceof Frame) {
AWTAccessor.getFrameAccessor().setExtendedState(
......@@ -941,7 +950,6 @@ public class LWWindowPeer
graphicsDevice = newGraphicsDevice;
}
// TODO: DisplayChangedListener stuff
final GraphicsConfiguration newGC = newGraphicsDevice.getDefaultConfiguration();
if (!setGraphicsConfig(newGC)) return false;
......@@ -954,6 +962,20 @@ public class LWWindowPeer
return true;
}
@Override
public final void displayChanged() {
updateGraphicsDevice();
// Replace surface unconditionally, because internal state of the
// GraphicsDevice could be changed.
replaceSurfaceData();
repaintPeer();
}
@Override
public final void paletteChanged() {
// components do not need to react to this event.
}
/*
* May be called by delegate to provide SD to Java2D code.
*/
......
......@@ -32,6 +32,7 @@ import java.awt.peer.WindowPeer;
import java.beans.*;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Objects;
import javax.swing.*;
......@@ -916,9 +917,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
final Rectangle oldB = nativeBounds;
nativeBounds = new Rectangle(x, y, width, height);
final GraphicsConfiguration oldGC = peer.getGraphicsConfiguration();
peer.notifyReshape(x, y, width, height);
final GraphicsConfiguration newGC = peer.getGraphicsConfiguration();
// System-dependent appearance optimization.
if ((byUser && !oldB.getSize().equals(nativeBounds.getSize()))
|| isFullScreenAnimationOn) {
|| isFullScreenAnimationOn || !Objects.equals(newGC, oldGC)) {
flushBuffers();
}
}
......
/*
* 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
......@@ -35,5 +35,6 @@ void SendAdditionalJavaEvents(JNIEnv *env, NSEvent *nsEvent, jobject peer);
jint GetJavaMouseModifiers(NSInteger button, NSUInteger modifierFlags);
jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods);
NSUInteger JavaModifiersToNsKeyModifiers(jint javaModifiers, BOOL isExtMods);
unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers);
#endif /* __AWTEVENT_H */
/*
* 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
......@@ -341,8 +341,7 @@ const charTable[] = {
{0, 0, 0}
};
static unichar
NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
unichar NsCharToJavaChar(unichar nsChar, NSUInteger modifiers)
{
const struct _char *cur;
// Mask off just the keyboard modifiers from the event modifier mask.
......
......@@ -124,10 +124,11 @@ static void displaycb_handle
jobject graphicsEnv = [wrapper jObjectWithEnv:env];
if (graphicsEnv == NULL) return; // ref already GC'd
static JNF_CLASS_CACHE(jc_CGraphicsEnvironment, "sun/awt/CGraphicsEnvironment");
static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(J)V");
JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration);
static JNF_MEMBER_CACHE(jm_displayReconfiguration, jc_CGraphicsEnvironment, "_displayReconfiguration", "(IZ)V");
JNFCallVoidMethod(env, graphicsEnv, jm_displayReconfiguration,
(jint) display,
(jboolean) flags & kCGDisplayRemoveFlag);
});
}
......
/*
* 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
......@@ -71,12 +71,21 @@ AWT_ASSERT_APPKIT_THREAD;
JNF_COCOA_ENTER(env);
// If we are called as a result of user pressing a shorcut, do nothing,
// because AVTView has already sent corresponding key event to the Java
// because AVTView has already sent corresponding key event to the Java
// layer from performKeyEquivalent
NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
if ([currEvent type] == NSKeyDown) {
NSString *menuKey = [sender keyEquivalent];
NSString *eventKey = [currEvent charactersIgnoringModifiers];
// Apple uses characters from private Unicode range for some of the
// keys, so we need to do the same translation here that we do
// for the regular key down events
if ([eventKey length] == 1) {
unichar ch = NsCharToJavaChar([eventKey characterAtIndex:0], 0);
eventKey = [NSString stringWithCharacters: &ch length: 1];
}
if ([menuKey isEqualToString:eventKey]) {
return;
}
......
......@@ -143,6 +143,8 @@ void JavaCT_DrawGlyphVector
CGContextRef cgRef = qsdo->cgRef;
CGAffineTransform ctmText = CGContextGetTextMatrix(cgRef);
BOOL saved = false;
/* Save and restore of graphics context is done before the iteration.
This seems to work using our test case (see bug ID 7158350) so we are restoring it at
the end of the for loop. If we find out that save/restore outside the loop
......@@ -175,10 +177,19 @@ void JavaCT_DrawGlyphVector
CFRelease(fallback);
if (cgFallback) {
if (!saved) {
CGContextSaveGState(cgRef);
saved = true;
}
CGContextSetFont(cgRef, cgFallback);
CFRelease(cgFallback);
}
}
} else {
if (saved) {
CGContextRestoreGState(cgRef);
saved = false;
}
}
// if we have per-glyph transformations
......
......@@ -316,7 +316,10 @@ AWT_ASSERT_APPKIT_THREAD;
// its finishLaunching has initialized it.
// ApplicationDelegate is the support code for com.apple.eawt.
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]);
id<NSApplicationDelegate> delegate = [ApplicationDelegate sharedDelegate];
if (delegate != nil) {
OSXAPP_SetApplicationDelegate(delegate);
}
}];
}
......
......@@ -216,7 +216,11 @@ Java_sun_java2d_opengl_CGLLayer_nativeSetScale
{
JNF_COCOA_ENTER(env);
CGLLayer *layer = jlong_to_ptr(layerPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
// We always call all setXX methods asynchronously, exception is only in
// this method where we need to change native texture size and layer's scale
// in one call on appkit, otherwise we'll get window's contents blinking,
// during screen-2-screen moving.
[ThreadUtilities performOnMainThreadWaiting:[NSThread isMainThread] block:^(){
layer.contentsScale = scale;
}];
JNF_COCOA_EXIT(env);
......
/*
* Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 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
......@@ -149,12 +149,15 @@ static int KnownVMIndex(const char* name);
static void FreeKnownVMs();
static jboolean IsWildCardEnabled();
#define ARG_CHECK(n, f, a) if (n < 1) { \
JLI_ReportErrorMessage(f, a); \
printUsage = JNI_TRUE; \
*pret = 1; \
return JNI_TRUE; \
}
#define ARG_CHECK(AC_arg_count, AC_failure_message, AC_questionable_arg) \
do { \
if (AC_arg_count < 1) { \
JLI_ReportErrorMessage(AC_failure_message, AC_questionable_arg); \
printUsage = JNI_TRUE; \
*pret = 1; \
return JNI_TRUE; \
} \
} while (JNI_FALSE)
/*
* Running Java code in primordial thread caused many problems. We will
......@@ -310,29 +313,37 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
* mainThread.isAlive() to work as expected.
*/
#define LEAVE() \
if ((*vm)->DetachCurrentThread(vm) != 0) { \
JLI_ReportErrorMessage(JVM_ERROR2); \
ret = 1; \
} \
(*vm)->DestroyJavaVM(vm); \
return ret \
#define CHECK_EXCEPTION_NULL_LEAVE(e) \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
LEAVE(); \
} \
if ((e) == NULL) { \
JLI_ReportErrorMessage(JNI_ERROR); \
LEAVE(); \
}
#define CHECK_EXCEPTION_LEAVE(rv) \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
ret = (rv); \
LEAVE(); \
}
do { \
if ((*vm)->DetachCurrentThread(vm) != JNI_OK) { \
JLI_ReportErrorMessage(JVM_ERROR2); \
ret = 1; \
} \
if (JNI_TRUE) { \
(*vm)->DestroyJavaVM(vm); \
return ret; \
} \
} while (JNI_FALSE)
#define CHECK_EXCEPTION_NULL_LEAVE(CENL_exception) \
do { \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
LEAVE(); \
} \
if ((CENL_exception) == NULL) { \
JLI_ReportErrorMessage(JNI_ERROR); \
LEAVE(); \
} \
} while (JNI_FALSE)
#define CHECK_EXCEPTION_LEAVE(CEL_return_value) \
do { \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
ret = (CEL_return_value); \
LEAVE(); \
} \
} while (JNI_FALSE)
int JNICALL
JavaMain(void * _args)
......@@ -434,7 +445,7 @@ JavaMain(void * _args)
* consistent in the UI we need to track and report the application main class.
*/
appClass = GetApplicationClass(env);
NULL_CHECK(appClass);
NULL_CHECK_RETURN_VALUE(appClass, -1);
/*
* PostJVMInit uses the class name as the application name for GUI purposes,
* for example, on OSX this sets the application name in the menu bar for
......
/*
* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
......@@ -242,14 +242,18 @@ typedef struct {
InvocationFunctions ifn;
} JavaMainArgs;
#define NULL_CHECK0(e) if ((e) == 0) { \
JLI_ReportErrorMessage(JNI_ERROR); \
return 0; \
}
#define NULL_CHECK_RETURN_VALUE(NCRV_check_pointer, NCRV_return_value) \
do { \
if ((NCRV_check_pointer) == NULL) { \
JLI_ReportErrorMessage(JNI_ERROR); \
return NCRV_return_value; \
} \
} while (JNI_FALSE)
#define NULL_CHECK(e) if ((e) == 0) { \
JLI_ReportErrorMessage(JNI_ERROR); \
return; \
}
#define NULL_CHECK0(NC0_check_pointer) \
NULL_CHECK_RETURN_VALUE(NC0_check_pointer, 0)
#define NULL_CHECK(NC_check_pointer) \
NULL_CHECK_RETURN_VALUE(NC_check_pointer, )
#endif /* _JAVA_H_ */
/*
* 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
......@@ -136,8 +136,10 @@ WildcardIterator_for(const char *wildcard)
{
WildcardIterator it = NEW_(WildcardIterator);
HANDLE handle = FindFirstFile(wildcard, &find_data);
if (handle == INVALID_HANDLE_VALUE)
if (handle == INVALID_HANDLE_VALUE) {
JLI_MemFree(it);
return NULL;
}
it->handle = handle;
it->firstFile = find_data.cFileName;
return it;
......
......@@ -102,7 +102,7 @@ public class DnsContext extends ComponentDirContext {
this.domain = new DnsName(domain.endsWith(".")
? domain
: domain + ".");
this.servers = servers;
this.servers = (servers == null) ? null : servers.clone();
this.environment = (Hashtable<Object,Object>) environment.clone();
envShared = false;
parentIsDns = false;
......@@ -129,11 +129,11 @@ public class DnsContext extends ComponentDirContext {
* no conflict.
*/
private DnsContext(DnsContext ctx) {
environment = ctx.environment;
environment = ctx.environment; // shared environment, copy-on-write
envShared = ctx.envShared = true;
parentIsDns = ctx.parentIsDns;
domain = ctx.domain;
servers = ctx.servers;
servers = ctx.servers; // shared servers, no write operation
resolver = ctx.resolver;
authoritative = ctx.authoritative;
recursion = ctx.recursion;
......
......@@ -81,7 +81,7 @@ public class BasicControl implements Control {
this.id = id;
this.criticality = criticality;
if (value != null) {
this.value = value;
this.value = value.clone();
}
}
......
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import sun.org.mozilla.javascript.internal.*;
import javax.script.*;
import java.util.*;
/**
* ExternalScriptable is an implementation of Scriptable
* backed by a JSR 223 ScriptContext instance.
*
* @author Mike Grogan
* @author A. Sundararajan
* @since 1.6
*/
final class ExternalScriptable implements Scriptable {
/* Underlying ScriptContext that we use to store
* named variables of this scope.
*/
private ScriptContext context;
/* JavaScript allows variables to be named as numbers (indexed
* properties). This way arrays, objects (scopes) are treated uniformly.
* Note that JSR 223 API supports only String named variables and
* so we can't store these in Bindings. Also, JavaScript allows name
* of the property name to be even empty String! Again, JSR 223 API
* does not support empty name. So, we use the following fallback map
* to store such variables of this scope. This map is not exposed to
* JSR 223 API. We can just script objects "as is" and need not convert.
*/
private Map<Object, Object> indexedProps;
// my prototype
private Scriptable prototype;
// my parent scope, if any
private Scriptable parent;
ExternalScriptable(ScriptContext context) {
this(context, new HashMap<Object, Object>());
}
ExternalScriptable(ScriptContext context, Map<Object, Object> indexedProps) {
if (context == null) {
throw new NullPointerException("context is null");
}
this.context = context;
this.indexedProps = indexedProps;
}
ScriptContext getContext() {
return context;
}
private boolean isEmpty(String name) {
return name.equals("");
}
/**
* Return the name of the class.
*/
public String getClassName() {
return "Global";
}
/**
* Returns the value of the named property or NOT_FOUND.
*
* If the property was created using defineProperty, the
* appropriate getter method is called.
*
* @param name the name of the property
* @param start the object in which the lookup began
* @return the value of the property (may be null), or NOT_FOUND
*/
public synchronized Object get(String name, Scriptable start) {
if (isEmpty(name)) {
if (indexedProps.containsKey(name)) {
return indexedProps.get(name);
} else {
return NOT_FOUND;
}
} else {
synchronized (context) {
int scope = context.getAttributesScope(name);
if (scope != -1) {
Object value = context.getAttribute(name, scope);
return Context.javaToJS(value, this);
} else {
return NOT_FOUND;
}
}
}
}
/**
* Returns the value of the indexed property or NOT_FOUND.
*
* @param index the numeric index for the property
* @param start the object in which the lookup began
* @return the value of the property (may be null), or NOT_FOUND
*/
public synchronized Object get(int index, Scriptable start) {
Integer key = new Integer(index);
if (indexedProps.containsKey(index)) {
return indexedProps.get(key);
} else {
return NOT_FOUND;
}
}
/**
* Returns true if the named property is defined.
*
* @param name the name of the property
* @param start the object in which the lookup began
* @return true if and only if the property was found in the object
*/
public synchronized boolean has(String name, Scriptable start) {
if (isEmpty(name)) {
return indexedProps.containsKey(name);
} else {
synchronized (context) {
return context.getAttributesScope(name) != -1;
}
}
}
/**
* Returns true if the property index is defined.
*
* @param index the numeric index for the property
* @param start the object in which the lookup began
* @return true if and only if the property was found in the object
*/
public synchronized boolean has(int index, Scriptable start) {
Integer key = new Integer(index);
return indexedProps.containsKey(key);
}
/**
* Sets the value of the named property, creating it if need be.
*
* @param name the name of the property
* @param start the object whose property is being set
* @param value value to set the property to
*/
public void put(String name, Scriptable start, Object value) {
if (start == this) {
synchronized (this) {
if (isEmpty(name)) {
indexedProps.put(name, value);
} else {
synchronized (context) {
int scope = context.getAttributesScope(name);
if (scope == -1) {
scope = ScriptContext.ENGINE_SCOPE;
}
context.setAttribute(name, jsToJava(value), scope);
}
}
}
} else {
start.put(name, start, value);
}
}
/**
* Sets the value of the indexed property, creating it if need be.
*
* @param index the numeric index for the property
* @param start the object whose property is being set
* @param value value to set the property to
*/
public void put(int index, Scriptable start, Object value) {
if (start == this) {
synchronized (this) {
indexedProps.put(new Integer(index), value);
}
} else {
start.put(index, start, value);
}
}
/**
* Removes a named property from the object.
*
* If the property is not found, no action is taken.
*
* @param name the name of the property
*/
public synchronized void delete(String name) {
if (isEmpty(name)) {
indexedProps.remove(name);
} else {
synchronized (context) {
int scope = context.getAttributesScope(name);
if (scope != -1) {
context.removeAttribute(name, scope);
}
}
}
}
/**
* Removes the indexed property from the object.
*
* If the property is not found, no action is taken.
*
* @param index the numeric index for the property
*/
public void delete(int index) {
indexedProps.remove(new Integer(index));
}
/**
* Get the prototype of the object.
* @return the prototype
*/
public Scriptable getPrototype() {
return prototype;
}
/**
* Set the prototype of the object.
* @param prototype the prototype to set
*/
public void setPrototype(Scriptable prototype) {
this.prototype = prototype;
}
/**
* Get the parent scope of the object.
* @return the parent scope
*/
public Scriptable getParentScope() {
return parent;
}
/**
* Set the parent scope of the object.
* @param parent the parent scope to set
*/
public void setParentScope(Scriptable parent) {
this.parent = parent;
}
/**
* Get an array of property ids.
*
* Not all property ids need be returned. Those properties
* whose ids are not returned are considered non-enumerable.
*
* @return an array of Objects. Each entry in the array is either
* a java.lang.String or a java.lang.Number
*/
public synchronized Object[] getIds() {
String[] keys = getAllKeys();
int size = keys.length + indexedProps.size();
Object[] res = new Object[size];
System.arraycopy(keys, 0, res, 0, keys.length);
int i = keys.length;
// now add all indexed properties
for (Object index : indexedProps.keySet()) {
res[i++] = index;
}
return res;
}
/**
* Get the default value of the object with a given hint.
* The hints are String.class for type String, Number.class for type
* Number, Scriptable.class for type Object, and Boolean.class for
* type Boolean. <p>
*
* A <code>hint</code> of null means "no hint".
*
* See ECMA 8.6.2.6.
*
* @param hint the type hint
* @return the default value
*/
public Object getDefaultValue(Class typeHint) {
for (int i=0; i < 2; i++) {
boolean tryToString;
if (typeHint == ScriptRuntime.StringClass) {
tryToString = (i == 0);
} else {
tryToString = (i == 1);
}
String methodName;
Object[] args;
if (tryToString) {
methodName = "toString";
args = ScriptRuntime.emptyArgs;
} else {
methodName = "valueOf";
args = new Object[1];
String hint;
if (typeHint == null) {
hint = "undefined";
} else if (typeHint == ScriptRuntime.StringClass) {
hint = "string";
} else if (typeHint == ScriptRuntime.ScriptableClass) {
hint = "object";
} else if (typeHint == ScriptRuntime.FunctionClass) {
hint = "function";
} else if (typeHint == ScriptRuntime.BooleanClass
|| typeHint == Boolean.TYPE)
{
hint = "boolean";
} else if (typeHint == ScriptRuntime.NumberClass ||
typeHint == ScriptRuntime.ByteClass ||
typeHint == Byte.TYPE ||
typeHint == ScriptRuntime.ShortClass ||
typeHint == Short.TYPE ||
typeHint == ScriptRuntime.IntegerClass ||
typeHint == Integer.TYPE ||
typeHint == ScriptRuntime.FloatClass ||
typeHint == Float.TYPE ||
typeHint == ScriptRuntime.DoubleClass ||
typeHint == Double.TYPE)
{
hint = "number";
} else {
throw Context.reportRuntimeError(
"Invalid JavaScript value of type " +
typeHint.toString());
}
args[0] = hint;
}
Object v = ScriptableObject.getProperty(this, methodName);
if (!(v instanceof Function))
continue;
Function fun = (Function) v;
Context cx = RhinoScriptEngine.enterContext();
try {
v = fun.call(cx, fun.getParentScope(), this, args);
} finally {
cx.exit();
}
if (v != null) {
if (!(v instanceof Scriptable)) {
return v;
}
if (typeHint == ScriptRuntime.ScriptableClass
|| typeHint == ScriptRuntime.FunctionClass)
{
return v;
}
if (tryToString && v instanceof Wrapper) {
// Let a wrapped java.lang.String pass for a primitive
// string.
Object u = ((Wrapper)v).unwrap();
if (u instanceof String)
return u;
}
}
}
// fall through to error
String arg = (typeHint == null) ? "undefined" : typeHint.getName();
throw Context.reportRuntimeError(
"Cannot find default value for object " + arg);
}
/**
* Implements the instanceof operator.
*
* @param instance The value that appeared on the LHS of the instanceof
* operator
* @return true if "this" appears in value's prototype chain
*
*/
public boolean hasInstance(Scriptable instance) {
// Default for JS objects (other than Function) is to do prototype
// chasing.
Scriptable proto = instance.getPrototype();
while (proto != null) {
if (proto.equals(this)) return true;
proto = proto.getPrototype();
}
return false;
}
private String[] getAllKeys() {
ArrayList<String> list = new ArrayList<String>();
synchronized (context) {
for (int scope : context.getScopes()) {
Bindings bindings = context.getBindings(scope);
if (bindings != null) {
list.ensureCapacity(bindings.size());
for (String key : bindings.keySet()) {
list.add(key);
}
}
}
}
String[] res = new String[list.size()];
list.toArray(res);
return res;
}
/**
* We convert script values to the nearest Java value.
* We unwrap wrapped Java objects so that access from
* Bindings.get() would return "workable" value for Java.
* But, at the same time, we need to make few special cases
* and hence the following function is used.
*/
private Object jsToJava(Object jsObj) {
if (jsObj instanceof Wrapper) {
Wrapper njb = (Wrapper) jsObj;
/* importClass feature of ImporterTopLevel puts
* NativeJavaClass in global scope. If we unwrap
* it, importClass won't work.
*/
if (njb instanceof NativeJavaClass) {
return njb;
}
/* script may use Java primitive wrapper type objects
* (such as java.lang.Integer, java.lang.Boolean etc)
* explicitly. If we unwrap, then these script objects
* will become script primitive types. For example,
*
* var x = new java.lang.Double(3.0); print(typeof x);
*
* will print 'number'. We don't want that to happen.
*/
Object obj = njb.unwrap();
if (obj instanceof Number || obj instanceof String ||
obj instanceof Boolean || obj instanceof Character) {
// special type wrapped -- we just leave it as is.
return njb;
} else {
// return unwrapped object for any other object.
return obj;
}
} else { // not-a-Java-wrapper
return jsObj;
}
}
}
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import sun.org.mozilla.javascript.internal.*;
import java.util.*;
/**
* JSAdapter is java.lang.reflect.Proxy equivalent for JavaScript. JSAdapter
* calls specially named JavaScript methods on an adaptee object when property
* access is attempted on it.
*
* Example:
*
* var y = {
* __get__ : function (name) { ... }
* __has__ : function (name) { ... }
* __put__ : function (name, value) {...}
* __delete__ : function (name) { ... }
* __getIds__ : function () { ... }
* };
*
* var x = new JSAdapter(y);
*
* x.i; // calls y.__get__
* i in x; // calls y.__has__
* x.p = 10; // calls y.__put__
* delete x.p; // calls y.__delete__
* for (i in x) { print(i); } // calls y.__getIds__
*
* If a special JavaScript method is not found in the adaptee, then JSAdapter
* forwards the property access to the adaptee itself.
*
* JavaScript caller of adapter object is isolated from the fact that
* the property access/mutation/deletion are really calls to
* JavaScript methods on adaptee. Use cases include 'smart'
* properties, property access tracing/debugging, encaptulation with
* easy client access - in short JavaScript becomes more "Self" like.
*
* Note that Rhino already supports special properties like __proto__
* (to set, get prototype), __parent__ (to set, get parent scope). We
* follow the same double underscore nameing convention here. Similarly
* the name JSAdapter is derived from JavaAdapter -- which is a facility
* to extend, implement Java classes/interfaces by JavaScript.
*
* @author A. Sundararajan
* @since 1.6
*/
public final class JSAdapter implements Scriptable, Function {
private JSAdapter(Scriptable obj) {
setAdaptee(obj);
}
// initializer to setup JSAdapter prototype in the given scope
public static void init(Context cx, Scriptable scope, boolean sealed)
throws RhinoException {
JSAdapter obj = new JSAdapter(cx.newObject(scope));
obj.setParentScope(scope);
obj.setPrototype(getFunctionPrototype(scope));
obj.isPrototype = true;
ScriptableObject.defineProperty(scope, "JSAdapter", obj,
ScriptableObject.DONTENUM);
}
public String getClassName() {
return "JSAdapter";
}
public Object get(String name, Scriptable start) {
Function func = getAdapteeFunction(GET_PROP);
if (func != null) {
return call(func, new Object[] { name });
} else {
start = getAdaptee();
return start.get(name, start);
}
}
public Object get(int index, Scriptable start) {
Function func = getAdapteeFunction(GET_PROP);
if (func != null) {
return call(func, new Object[] { new Integer(index) });
} else {
start = getAdaptee();
return start.get(index, start);
}
}
public boolean has(String name, Scriptable start) {
Function func = getAdapteeFunction(HAS_PROP);
if (func != null) {
Object res = call(func, new Object[] { name });
return Context.toBoolean(res);
} else {
start = getAdaptee();
return start.has(name, start);
}
}
public boolean has(int index, Scriptable start) {
Function func = getAdapteeFunction(HAS_PROP);
if (func != null) {
Object res = call(func, new Object[] { new Integer(index) });
return Context.toBoolean(res);
} else {
start = getAdaptee();
return start.has(index, start);
}
}
public void put(String name, Scriptable start, Object value) {
if (start == this) {
Function func = getAdapteeFunction(PUT_PROP);
if (func != null) {
call(func, new Object[] { name, value });
} else {
start = getAdaptee();
start.put(name, start, value);
}
} else {
start.put(name, start, value);
}
}
public void put(int index, Scriptable start, Object value) {
if (start == this) {
Function func = getAdapteeFunction(PUT_PROP);
if( func != null) {
call(func, new Object[] { new Integer(index), value });
} else {
start = getAdaptee();
start.put(index, start, value);
}
} else {
start.put(index, start, value);
}
}
public void delete(String name) {
Function func = getAdapteeFunction(DEL_PROP);
if (func != null) {
call(func, new Object[] { name });
} else {
getAdaptee().delete(name);
}
}
public void delete(int index) {
Function func = getAdapteeFunction(DEL_PROP);
if (func != null) {
call(func, new Object[] { new Integer(index) });
} else {
getAdaptee().delete(index);
}
}
public Scriptable getPrototype() {
return prototype;
}
public void setPrototype(Scriptable prototype) {
this.prototype = prototype;
}
public Scriptable getParentScope() {
return parent;
}
public void setParentScope(Scriptable parent) {
this.parent = parent;
}
public Object[] getIds() {
Function func = getAdapteeFunction(GET_PROPIDS);
if (func != null) {
Object val = call(func, new Object[0]);
// in most cases, adaptee would return native JS array
if (val instanceof NativeArray) {
NativeArray array = (NativeArray) val;
Object[] res = new Object[(int)array.getLength()];
for (int index = 0; index < res.length; index++) {
res[index] = mapToId(array.get(index, array));
}
return res;
} else if (val instanceof NativeJavaArray) {
// may be attempt wrapped Java array
Object tmp = ((NativeJavaArray)val).unwrap();
Object[] res;
if (tmp.getClass() == Object[].class) {
Object[] array = (Object[]) tmp;
res = new Object[array.length];
for (int index = 0; index < array.length; index++) {
res[index] = mapToId(array[index]);
}
} else {
// just return an empty array
res = Context.emptyArgs;
}
return res;
} else {
// some other return type, just return empty array
return Context.emptyArgs;
}
} else {
return getAdaptee().getIds();
}
}
public boolean hasInstance(Scriptable scriptable) {
if (scriptable instanceof JSAdapter) {
return true;
} else {
Scriptable proto = scriptable.getPrototype();
while (proto != null) {
if (proto.equals(this)) return true;
proto = proto.getPrototype();
}
return false;
}
}
public Object getDefaultValue(Class hint) {
return getAdaptee().getDefaultValue(hint);
}
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
throws RhinoException {
if (isPrototype) {
return construct(cx, scope, args);
} else {
Scriptable tmp = getAdaptee();
if (tmp instanceof Function) {
return ((Function)tmp).call(cx, scope, tmp, args);
} else {
throw Context.reportRuntimeError("TypeError: not a function");
}
}
}
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
throws RhinoException {
if (isPrototype) {
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
JSAdapter newObj;
if (args.length > 0) {
newObj = new JSAdapter(Context.toObject(args[0], topLevel));
} else {
throw Context.reportRuntimeError("JSAdapter requires adaptee");
}
return newObj;
} else {
Scriptable tmp = getAdaptee();
if (tmp instanceof Function) {
return ((Function)tmp).construct(cx, scope, args);
} else {
throw Context.reportRuntimeError("TypeError: not a constructor");
}
}
}
public Scriptable getAdaptee() {
return adaptee;
}
public void setAdaptee(Scriptable adaptee) {
if (adaptee == null) {
throw new NullPointerException("adaptee can not be null");
}
this.adaptee = adaptee;
}
//-- internals only below this point
// map a property id. Property id can only be an Integer or String
private Object mapToId(Object tmp) {
if (tmp instanceof Double) {
return new Integer(((Double)tmp).intValue());
} else {
return Context.toString(tmp);
}
}
private static Scriptable getFunctionPrototype(Scriptable scope) {
return ScriptableObject.getFunctionPrototype(scope);
}
private Function getAdapteeFunction(String name) {
Object o = ScriptableObject.getProperty(getAdaptee(), name);
return (o instanceof Function)? (Function)o : null;
}
private Object call(Function func, Object[] args) {
Context cx = Context.getCurrentContext();
Scriptable thisObj = getAdaptee();
Scriptable scope = func.getParentScope();
try {
return func.call(cx, scope, thisObj, args);
} catch (RhinoException re) {
throw Context.reportRuntimeError(re.getMessage());
}
}
private Scriptable prototype;
private Scriptable parent;
private Scriptable adaptee;
private boolean isPrototype;
// names of adaptee JavaScript functions
private static final String GET_PROP = "__get__";
private static final String HAS_PROP = "__has__";
private static final String PUT_PROP = "__put__";
private static final String DEL_PROP = "__delete__";
private static final String GET_PROPIDS = "__getIds__";
}
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import javax.script.Invocable;
import sun.org.mozilla.javascript.internal.*;
/**
* This class implements Rhino-like JavaAdapter to help implement a Java
* interface in JavaScript. We support this using Invocable.getInterface.
* Using this JavaAdapter, script author could write:
*
* var r = new java.lang.Runnable() {
* run: function() { script... }
* };
*
* r.run();
* new java.lang.Thread(r).start();
*
* Note that Rhino's JavaAdapter support allows extending a Java class and/or
* implementing one or more interfaces. This JavaAdapter implementation does
* not support these.
*
* @author A. Sundararajan
* @since 1.6
*/
final class JavaAdapter extends ScriptableObject implements Function {
private JavaAdapter(Invocable engine) {
this.engine = engine;
}
static void init(Context cx, Scriptable scope, boolean sealed)
throws RhinoException {
RhinoTopLevel topLevel = (RhinoTopLevel) scope;
Invocable engine = topLevel.getScriptEngine();
JavaAdapter obj = new JavaAdapter(engine);
obj.setParentScope(scope);
obj.setPrototype(getFunctionPrototype(scope));
/*
* Note that we can't use defineProperty. A property of this
* name is already defined in Context.initStandardObjects. We
* simply overwrite the property value!
*/
ScriptableObject.putProperty(topLevel, "JavaAdapter", obj);
}
public String getClassName() {
return "JavaAdapter";
}
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args) throws RhinoException {
return construct(cx, scope, args);
}
public Scriptable construct(Context cx, Scriptable scope, Object[] args)
throws RhinoException {
if (args.length == 2) {
Class<?> clazz = null;
Object obj1 = args[0];
if (obj1 instanceof Wrapper) {
Object o = ((Wrapper)obj1).unwrap();
if (o instanceof Class && ((Class)o).isInterface()) {
clazz = (Class) o;
}
} else if (obj1 instanceof Class) {
if (((Class)obj1).isInterface()) {
clazz = (Class) obj1;
}
}
if (clazz == null) {
throw Context.reportRuntimeError("JavaAdapter: first arg should be interface Class");
}
Scriptable topLevel = ScriptableObject.getTopLevelScope(scope);
return cx.toObject(engine.getInterface(args[1], clazz), topLevel);
} else {
throw Context.reportRuntimeError("JavaAdapter requires two arguments");
}
}
private Invocable engine;
}
#script engines supported
com.sun.script.javascript.RhinoScriptEngineFactory #javascript
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import com.sun.script.util.*;
import javax.script.*;
import sun.org.mozilla.javascript.internal.*;
import java.lang.reflect.Method;
import java.io.*;
import java.util.*;
/**
* Implementation of <code>ScriptEngine</code> using the Mozilla Rhino
* interpreter.
*
* @author Mike Grogan
* @author A. Sundararajan
* @since 1.6
*/
public final class RhinoScriptEngine extends AbstractScriptEngine
implements Invocable, Compilable {
private static final boolean DEBUG = false;
/* Scope where standard JavaScript objects and our
* extensions to it are stored. Note that these are not
* user defined engine level global variables. These are
* variables have to be there on all compliant ECMAScript
* scopes. We put these standard objects in this top level.
*/
private RhinoTopLevel topLevel;
/* map used to store indexed properties in engine scope
* refer to comment on 'indexedProps' in ExternalScriptable.java.
*/
private Map<Object, Object> indexedProps;
private ScriptEngineFactory factory;
private InterfaceImplementor implementor;
private static final int languageVersion = getLanguageVersion();
private static final int optimizationLevel = getOptimizationLevel();
static {
ContextFactory.initGlobal(new ContextFactory() {
protected Context makeContext() {
Context cx = super.makeContext();
cx.setLanguageVersion(languageVersion);
cx.setOptimizationLevel(optimizationLevel);
cx.setClassShutter(RhinoClassShutter.getInstance());
cx.setWrapFactory(RhinoWrapFactory.getInstance());
return cx;
}
});
}
private static final String RHINO_JS_VERSION = "rhino.js.version";
private static int getLanguageVersion() {
int version;
String tmp = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(RHINO_JS_VERSION));
if (tmp != null) {
version = Integer.parseInt((String)tmp);
} else {
version = Context.VERSION_1_8;
}
return version;
}
private static final String RHINO_OPT_LEVEL = "rhino.opt.level";
private static int getOptimizationLevel() {
int optLevel = -1;
// disable optimizer under security manager, for now.
if (System.getSecurityManager() == null) {
optLevel = Integer.getInteger(RHINO_OPT_LEVEL, -1);
}
return optLevel;
}
/**
* Creates a new instance of RhinoScriptEngine
*/
public RhinoScriptEngine() {
Context cx = enterContext();
try {
topLevel = new RhinoTopLevel(cx, this);
} finally {
cx.exit();
}
indexedProps = new HashMap<Object, Object>();
//construct object used to implement getInterface
implementor = new InterfaceImplementor(this) {
protected boolean isImplemented(Object thiz, Class<?> iface) {
Context cx = enterContext();
try {
if (thiz != null && !(thiz instanceof Scriptable)) {
thiz = cx.toObject(thiz, topLevel);
}
Scriptable engineScope = getRuntimeScope(context);
Scriptable localScope = (thiz != null)? (Scriptable) thiz :
engineScope;
for (Method method : iface.getMethods()) {
// ignore methods of java.lang.Object class
if (method.getDeclaringClass() == Object.class) {
continue;
}
Object obj = ScriptableObject.getProperty(localScope, method.getName());
if (! (obj instanceof Function)) {
return false;
}
}
return true;
} finally {
cx.exit();
}
}
protected Object convertResult(Method method, Object res)
throws ScriptException {
Class desiredType = method.getReturnType();
if (desiredType == Void.TYPE) {
return null;
} else {
return Context.jsToJava(res, desiredType);
}
}
};
}
public Object eval(Reader reader, ScriptContext ctxt)
throws ScriptException {
Object ret;
Context cx = enterContext();
try {
Scriptable scope = getRuntimeScope(ctxt);
String filename = (String) get(ScriptEngine.FILENAME);
filename = filename == null ? "<Unknown source>" : filename;
ret = cx.evaluateReader(scope, reader, filename , 1, null);
} catch (RhinoException re) {
if (DEBUG) re.printStackTrace();
int line = (line = re.lineNumber()) == 0 ? -1 : line;
String msg;
if (re instanceof JavaScriptException) {
msg = String.valueOf(((JavaScriptException)re).getValue());
} else {
msg = re.toString();
}
ScriptException se = new ScriptException(msg, re.sourceName(), line);
se.initCause(re);
throw se;
} catch (IOException ee) {
throw new ScriptException(ee);
} finally {
cx.exit();
}
return unwrapReturnValue(ret);
}
public Object eval(String script, ScriptContext ctxt) throws ScriptException {
if (script == null) {
throw new NullPointerException("null script");
}
return eval(new StringReader(script) , ctxt);
}
public ScriptEngineFactory getFactory() {
if (factory != null) {
return factory;
} else {
return new RhinoScriptEngineFactory();
}
}
public Bindings createBindings() {
return new SimpleBindings();
}
//Invocable methods
public Object invokeFunction(String name, Object... args)
throws ScriptException, NoSuchMethodException {
return invoke(null, name, args);
}
public Object invokeMethod(Object thiz, String name, Object... args)
throws ScriptException, NoSuchMethodException {
if (thiz == null) {
throw new IllegalArgumentException("script object can not be null");
}
return invoke(thiz, name, args);
}
private Object invoke(Object thiz, String name, Object... args)
throws ScriptException, NoSuchMethodException {
Context cx = enterContext();
try {
if (name == null) {
throw new NullPointerException("method name is null");
}
if (thiz != null && !(thiz instanceof Scriptable)) {
thiz = cx.toObject(thiz, topLevel);
}
Scriptable engineScope = getRuntimeScope(context);
Scriptable localScope = (thiz != null)? (Scriptable) thiz :
engineScope;
Object obj = ScriptableObject.getProperty(localScope, name);
if (! (obj instanceof Function)) {
throw new NoSuchMethodException("no such method: " + name);
}
Function func = (Function) obj;
Scriptable scope = func.getParentScope();
if (scope == null) {
scope = engineScope;
}
Object result = func.call(cx, scope, localScope,
wrapArguments(args));
return unwrapReturnValue(result);
} catch (RhinoException re) {
if (DEBUG) re.printStackTrace();
int line = (line = re.lineNumber()) == 0 ? -1 : line;
ScriptException se = new ScriptException(re.toString(), re.sourceName(), line);
se.initCause(re);
throw se;
} finally {
cx.exit();
}
}
public <T> T getInterface(Class<T> clasz) {
try {
return implementor.getInterface(null, clasz);
} catch (ScriptException e) {
return null;
}
}
public <T> T getInterface(Object thiz, Class<T> clasz) {
if (thiz == null) {
throw new IllegalArgumentException("script object can not be null");
}
try {
return implementor.getInterface(thiz, clasz);
} catch (ScriptException e) {
return null;
}
}
private static final String printSource =
"function print(str, newline) { \n" +
" if (typeof(str) == 'undefined') { \n" +
" str = 'undefined'; \n" +
" } else if (str == null) { \n" +
" str = 'null'; \n" +
" } \n" +
" var out = context.getWriter(); \n" +
" if (!(out instanceof java.io.PrintWriter))\n" +
" out = new java.io.PrintWriter(out); \n" +
" out.print(String(str)); \n" +
" if (newline) out.print('\\n'); \n" +
" out.flush(); \n" +
"}\n" +
"function println(str) { \n" +
" print(str, true); \n" +
"}";
Scriptable getRuntimeScope(ScriptContext ctxt) {
if (ctxt == null) {
throw new NullPointerException("null script context");
}
// we create a scope for the given ScriptContext
Scriptable newScope = new ExternalScriptable(ctxt, indexedProps);
// Set the prototype of newScope to be 'topLevel' so that
// JavaScript standard objects are visible from the scope.
newScope.setPrototype(topLevel);
// define "context" variable in the new scope
newScope.put("context", newScope, ctxt);
// define "print", "println" functions in the new scope
Context cx = enterContext();
try {
cx.evaluateString(newScope, printSource, "print", 1, null);
} finally {
cx.exit();
}
return newScope;
}
//Compilable methods
public CompiledScript compile(String script) throws ScriptException {
return compile(new StringReader(script));
}
public CompiledScript compile(java.io.Reader script) throws ScriptException {
CompiledScript ret = null;
Context cx = enterContext();
try {
String fileName = (String) get(ScriptEngine.FILENAME);
if (fileName == null) {
fileName = "<Unknown Source>";
}
Scriptable scope = getRuntimeScope(context);
Script scr = cx.compileReader(scope, script, fileName, 1, null);
ret = new RhinoCompiledScript(this, scr);
} catch (Exception e) {
if (DEBUG) e.printStackTrace();
throw new ScriptException(e);
} finally {
cx.exit();
}
return ret;
}
//package-private helpers
static Context enterContext() {
// call this always so that initializer of this class runs
// and initializes custom wrap factory and class shutter.
return Context.enter();
}
void setEngineFactory(ScriptEngineFactory fac) {
factory = fac;
}
Object[] wrapArguments(Object[] args) {
if (args == null) {
return Context.emptyArgs;
}
Object[] res = new Object[args.length];
for (int i = 0; i < res.length; i++) {
res[i] = Context.javaToJS(args[i], topLevel);
}
return res;
}
Object unwrapReturnValue(Object result) {
if (result instanceof Wrapper) {
result = ( (Wrapper) result).unwrap();
}
return result instanceof Undefined ? null : result;
}
/*
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.out.println("No file specified");
return;
}
InputStreamReader r = new InputStreamReader(new FileInputStream(args[0]));
ScriptEngine engine = new RhinoScriptEngine();
engine.put("x", "y");
engine.put(ScriptEngine.FILENAME, args[0]);
engine.eval(r);
System.out.println(engine.get("x"));
}
*/
}
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import javax.script.*;
import java.util.*;
import sun.org.mozilla.javascript.internal.*;
import com.sun.script.util.*;
/**
* Factory to create RhinoScriptEngine
*
* @author Mike Grogan
* @since 1.6
*/
public class RhinoScriptEngineFactory extends ScriptEngineFactoryBase {
public RhinoScriptEngineFactory() {
}
public List<String> getExtensions() {
return extensions;
}
public List<String> getMimeTypes() {
return mimeTypes;
}
public List<String> getNames() {
return names;
}
public Object getParameter(String key) {
if (key.equals(ScriptEngine.NAME)) {
return "javascript";
} else if (key.equals(ScriptEngine.ENGINE)) {
return "Mozilla Rhino";
} else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
return "1.7 release 3 PRERELEASE";
} else if (key.equals(ScriptEngine.LANGUAGE)) {
return "ECMAScript";
} else if (key.equals(ScriptEngine.LANGUAGE_VERSION)) {
return "1.8";
} else if (key.equals("THREADING")) {
return "MULTITHREADED";
} else {
throw new IllegalArgumentException("Invalid key");
}
}
public ScriptEngine getScriptEngine() {
RhinoScriptEngine ret = new RhinoScriptEngine();
ret.setEngineFactory(this);
return ret;
}
public String getMethodCallSyntax(String obj, String method, String... args) {
String ret = obj + "." + method + "(";
int len = args.length;
if (len == 0) {
ret += ")";
return ret;
}
for (int i = 0; i < len; i++) {
ret += args[i];
if (i != len - 1) {
ret += ",";
} else {
ret += ")";
}
}
return ret;
}
public String getOutputStatement(String toDisplay) {
StringBuffer buf = new StringBuffer();
int len = toDisplay.length();
buf.append("print(\"");
for (int i = 0; i < len; i++) {
char ch = toDisplay.charAt(i);
switch (ch) {
case '"':
buf.append("\\\"");
break;
case '\\':
buf.append("\\\\");
break;
default:
buf.append(ch);
break;
}
}
buf.append("\")");
return buf.toString();
}
public String getProgram(String... statements) {
int len = statements.length;
String ret = "";
for (int i = 0; i < len; i++) {
ret += statements[i] + ";";
}
return ret;
}
/*
public static void main(String[] args) {
RhinoScriptEngineFactory fact = new RhinoScriptEngineFactory();
System.out.println(fact.getParameter(ScriptEngine.ENGINE_VERSION));
}
*/
private static List<String> names;
private static List<String> mimeTypes;
private static List<String> extensions;
static {
names = new ArrayList<String>(6);
names.add("js");
names.add("rhino");
names.add("JavaScript");
names.add("javascript");
names.add("ECMAScript");
names.add("ecmascript");
names = Collections.unmodifiableList(names);
mimeTypes = new ArrayList<String>(4);
mimeTypes.add("application/javascript");
mimeTypes.add("application/ecmascript");
mimeTypes.add("text/javascript");
mimeTypes.add("text/ecmascript");
mimeTypes = Collections.unmodifiableList(mimeTypes);
extensions = new ArrayList<String>(1);
extensions.add("js");
extensions = Collections.unmodifiableList(extensions);
}
}
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import sun.org.mozilla.javascript.internal.*;
import javax.script.*;
/**
* This class serves as top level scope for Rhino. This class adds
* 3 top level functions (bindings, scope, sync) and two constructors
* (JSAdapter, JavaAdapter).
*
* @author A. Sundararajan
* @since 1.6
*/
public final class RhinoTopLevel extends ImporterTopLevel {
RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
super(cx);
this.engine = engine;
// initialize JSAdapter lazily. Reduces footprint & startup time.
new LazilyLoadedCtor(this, "JSAdapter",
"com.sun.script.javascript.JSAdapter",
false);
/*
* initialize JavaAdapter. We can't lazy initialize this because
* lazy initializer attempts to define a new property. But, JavaAdapter
* is an exisiting property that we overwrite.
*/
JavaAdapter.init(cx, this, false);
// add top level functions
String names[] = { "bindings", "scope", "sync" };
defineFunctionProperties(names, RhinoTopLevel.class,
ScriptableObject.DONTENUM);
}
/**
* The bindings function takes a JavaScript scope object
* of type ExternalScriptable and returns the underlying Bindings
* instance.
*
* var page = scope(pageBindings);
* with (page) {
* // code that uses page scope
* }
* var b = bindings(page);
* // operate on bindings here.
*/
public static Object bindings(Context cx, Scriptable thisObj, Object[] args,
Function funObj) {
if (args.length == 1) {
Object arg = args[0];
if (arg instanceof Wrapper) {
arg = ((Wrapper)arg).unwrap();
}
if (arg instanceof ExternalScriptable) {
ScriptContext ctx = ((ExternalScriptable)arg).getContext();
Bindings bind = ctx.getBindings(ScriptContext.ENGINE_SCOPE);
return Context.javaToJS(bind,
ScriptableObject.getTopLevelScope(thisObj));
}
}
return cx.getUndefinedValue();
}
/**
* The scope function creates a new JavaScript scope object
* with given Bindings object as backing store. This can be used
* to create a script scope based on arbitrary Bindings instance.
* For example, in webapp scenario, a 'page' level Bindings instance
* may be wrapped as a scope and code can be run in JavaScripe 'with'
* statement:
*
* var page = scope(pageBindings);
* with (page) {
* // code that uses page scope
* }
*/
public static Object scope(Context cx, Scriptable thisObj, Object[] args,
Function funObj) {
if (args.length == 1) {
Object arg = args[0];
if (arg instanceof Wrapper) {
arg = ((Wrapper)arg).unwrap();
}
if (arg instanceof Bindings) {
ScriptContext ctx = new SimpleScriptContext();
ctx.setBindings((Bindings)arg, ScriptContext.ENGINE_SCOPE);
Scriptable res = new ExternalScriptable(ctx);
res.setPrototype(ScriptableObject.getObjectPrototype(thisObj));
res.setParentScope(ScriptableObject.getTopLevelScope(thisObj));
return res;
}
}
return cx.getUndefinedValue();
}
/**
* The sync function creates a synchronized function (in the sense
* of a Java synchronized method) from an existing function. The
* new function synchronizes on the <code>this</code> object of
* its invocation.
* js> var o = { f : sync(function(x) {
* print("entry");
* Packages.java.lang.Thread.sleep(x*1000);
* print("exit");
* })};
* js> thread(function() {o.f(5);});
* entry
* js> thread(function() {o.f(5);});
* js>
* exit
* entry
* exit
*/
public static Object sync(Context cx, Scriptable thisObj, Object[] args,
Function funObj) {
if (args.length == 1 && args[0] instanceof Function) {
return new Synchronizer((Function)args[0]);
} else {
throw Context.reportRuntimeError("wrong argument(s) for sync");
}
}
RhinoScriptEngine getScriptEngine() {
return engine;
}
private RhinoScriptEngine engine;
}
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.javascript;
import java.lang.reflect.*;
import static sun.security.util.SecurityConstants.*;
import sun.org.mozilla.javascript.internal.*;
/**
* This wrap factory is used for security reasons. JSR 223 script
* engine interface and JavaScript engine classes are run as bootstrap
* classes. For example, java.lang.Class.forName method (when called without
* class loader) uses caller's class loader. This may be exploited by script
* authors to access classes otherwise not accessible. For example,
* classes in sun.* namespace are normally not accessible to untrusted
* code and hence should not be accessible to JavaScript run from
* untrusted code.
*
* @author A. Sundararajan
* @since 1.6
*/
final class RhinoWrapFactory extends WrapFactory {
private RhinoWrapFactory() {}
private static RhinoWrapFactory theInstance;
static synchronized WrapFactory getInstance() {
if (theInstance == null) {
theInstance = new RhinoWrapFactory();
}
return theInstance;
}
// We use instance of this class to wrap security sensitive
// Java object. Please refer below.
private static class RhinoJavaObject extends NativeJavaObject {
RhinoJavaObject(Scriptable scope, Object obj, Class type) {
// we pass 'null' to object. NativeJavaObject uses
// passed 'type' to reflect fields and methods when
// object is null.
super(scope, null, type);
// Now, we set actual object. 'javaObject' is protected
// field of NativeJavaObject.
javaObject = obj;
}
}
public Scriptable wrapAsJavaObject(Context cx, Scriptable scope,
Object javaObject, Class staticType) {
SecurityManager sm = System.getSecurityManager();
ClassShutter classShutter = RhinoClassShutter.getInstance();
if (javaObject instanceof ClassLoader) {
// Check with Security Manager whether we can expose a
// ClassLoader...
if (sm != null) {
sm.checkPermission(GET_CLASSLOADER_PERMISSION);
}
// if we fall through here, check permission succeeded.
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
} else {
String name = null;
if (javaObject instanceof Class) {
name = ((Class)javaObject).getName();
} else if (javaObject instanceof Member) {
Member member = (Member) javaObject;
// Check member access. Don't allow reflective access to
// non-public members. Note that we can't call checkMemberAccess
// because that expects exact stack depth!
if (sm != null && !Modifier.isPublic(member.getModifiers())) {
return null;
}
name = member.getDeclaringClass().getName();
}
// Now, make sure that no ClassShutter prevented Class or Member
// of it is accessed reflectively. Note that ClassShutter may
// prevent access to a class, even though SecurityManager permit.
if (name != null) {
if (!classShutter.visibleToScripts(name)) {
return null;
} else {
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
}
}
}
// we have got some non-reflective object.
Class dynamicType = javaObject.getClass();
String name = dynamicType.getName();
if (!classShutter.visibleToScripts(name)) {
// Object of some sensitive class (such as sun.net.www.*
// objects returned from public method of java.net.URL class.
// We expose this object as though it is an object of some
// super class that is safe for access.
Class type = null;
// Whenever a Java Object is wrapped, we are passed with a
// staticType which is the type found from environment. For
// example, method return type known from signature. The dynamic
// type would be the actual Class of the actual returned object.
// If the staticType is an interface, we just use that type.
if (staticType != null && staticType.isInterface()) {
type = staticType;
} else {
// dynamicType is always a class type and never an interface.
// find an accessible super class of the dynamic type.
while (dynamicType != null) {
dynamicType = dynamicType.getSuperclass();
name = dynamicType.getName();
if (classShutter.visibleToScripts(name)) {
type = dynamicType; break;
}
}
// atleast java.lang.Object has to be accessible. So, when
// we reach here, type variable should not be null.
assert type != null:
"even java.lang.Object is not accessible?";
}
// create custom wrapper with the 'safe' type.
return new RhinoJavaObject(scope, javaObject, type);
} else {
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
}
}
}
/*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.script.util;
import javax.script.*;
import java.lang.reflect.*;
import java.security.*;
/*
* java.lang.reflect.Proxy based interface implementor. This is meant
* to be used to implement Invocable.getInterface.
*
* @author Mike Grogan
* @since 1.6
*/
public class InterfaceImplementor {
private Invocable engine;
/** Creates a new instance of Invocable */
public InterfaceImplementor(Invocable engine) {
this.engine = engine;
}
private final class InterfaceImplementorInvocationHandler
implements InvocationHandler {
private Object thiz;
private AccessControlContext accCtxt;
public InterfaceImplementorInvocationHandler(Object thiz,
AccessControlContext accCtxt) {
this.thiz = thiz;
this.accCtxt = accCtxt;
}
public Object invoke(Object proxy , Method method, Object[] args)
throws java.lang.Throwable {
// give chance to convert input args
args = convertArguments(method, args);
Object result;
final Method m = method;
final Object[] a = args;
result = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
if (thiz == null) {
return engine.invokeFunction(m.getName(), a);
} else {
return engine.invokeMethod(thiz, m.getName(), a);
}
}
}, accCtxt);
// give chance to convert the method result
return convertResult(method, result);
}
}
public <T> T getInterface(Object thiz, Class<T> iface)
throws ScriptException {
if (iface == null || !iface.isInterface()) {
throw new IllegalArgumentException("interface Class expected");
}
if (! isImplemented(thiz, iface)) {
return null;
}
AccessControlContext accCtxt = AccessController.getContext();
return iface.cast(Proxy.newProxyInstance(iface.getClassLoader(),
new Class[]{iface},
new InterfaceImplementorInvocationHandler(thiz, accCtxt)));
}
protected boolean isImplemented(Object thiz, Class<?> iface) {
return true;
}
// called to convert method result after invoke
protected Object convertResult(Method method, Object res)
throws ScriptException {
// default is identity conversion
return res;
}
// called to convert method arguments before invoke
protected Object[] convertArguments(Method method, Object[] args)
throws ScriptException {
// default is identity conversion
return args;
}
}
......@@ -1051,11 +1051,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
return parent;
}
// This method is overriden in the Window class to return null,
// This method is overridden in the Window class to return null,
// because the parent field of the Window object contains
// the owner of the window, not its parent.
Container getContainer() {
return getParent();
return getParent_NoClientCode();
}
/**
......@@ -8194,10 +8194,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
* Fetches the native container somewhere higher up in the component
* tree that contains this component.
*/
Container getNativeContainer() {
Container p = parent;
final Container getNativeContainer() {
Container p = getContainer();
while (p != null && p.peer instanceof LightweightPeer) {
p = p.getParent_NoClientCode();
p = p.getContainer();
}
return p;
}
......
......@@ -3914,7 +3914,7 @@ public class Window extends Container implements Accessible {
// ************************** MIXING CODE *******************************
// A window has a parent, but it does NOT have a container
// A window has an owner, but it does NOT have a container
@Override
final Container getContainer() {
return null;
......
......@@ -604,7 +604,7 @@ public class XMLEncoder extends Encoder implements AutoCloseable {
return;
}
Class<?> primitiveType = ReflectionUtils.primitiveTypeFor(value.getClass());
Class<?> primitiveType = primitiveTypeFor(value.getClass());
if (primitiveType != null && target == value.getClass() &&
methodName.equals("new")) {
String primitiveTypeName = primitiveType.getName();
......@@ -778,4 +778,18 @@ public class XMLEncoder extends Encoder implements AutoCloseable {
indentation--;
writeln("</" + tag + ">");
}
@SuppressWarnings("rawtypes")
static Class primitiveTypeFor(Class wrapper) {
if (wrapper == Boolean.class) return Boolean.TYPE;
if (wrapper == Byte.class) return Byte.TYPE;
if (wrapper == Character.class) return Character.TYPE;
if (wrapper == Short.class) return Short.TYPE;
if (wrapper == Integer.class) return Integer.TYPE;
if (wrapper == Long.class) return Long.TYPE;
if (wrapper == Float.class) return Float.TYPE;
if (wrapper == Double.class) return Double.TYPE;
if (wrapper == Void.class) return Void.TYPE;
return null;
}
}
......@@ -236,6 +236,8 @@ import java.util.Objects;
assert(MethodHandleNatives.refKindIsMethod(refKind));
if (clazz.isInterface())
assert(refKind == REF_invokeInterface ||
refKind == REF_invokeStatic ||
refKind == REF_invokeSpecial ||
refKind == REF_invokeVirtual && isObjectPublicMethod());
} else {
assert(false);
......@@ -268,7 +270,7 @@ import java.util.Objects;
assert(refKind == REF_invokeSpecial) : this;
return true;
}
assert(false) : this;
assert(false) : this+" != "+MethodHandleNatives.refKindName((byte)originalRefKind);
return true;
}
private boolean staticIsConsistent() {
......@@ -485,14 +487,19 @@ import java.util.Objects;
if (this.type == null)
this.type = new Object[] { m.getReturnType(), m.getParameterTypes() };
if (wantSpecial) {
assert(!isAbstract()) : this;
if (getReferenceKind() == REF_invokeVirtual)
changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
else if (getReferenceKind() == REF_invokeInterface)
// invokeSpecial on a default method
changeReferenceKind(REF_invokeSpecial, REF_invokeInterface);
}
}
public MemberName asSpecial() {
switch (getReferenceKind()) {
case REF_invokeSpecial: return this;
case REF_invokeVirtual: return clone().changeReferenceKind(REF_invokeSpecial, REF_invokeVirtual);
case REF_invokeInterface: return clone().changeReferenceKind(REF_invokeSpecial, REF_invokeInterface);
case REF_newInvokeSpecial: return clone().changeReferenceKind(REF_invokeSpecial, REF_newInvokeSpecial);
}
throw new IllegalArgumentException(this.toString());
......
......@@ -510,12 +510,12 @@ public abstract class Executable extends AccessibleObject
*/
AnnotatedType getAnnotatedReturnType0(Type returnType) {
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
returnType,
TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN_TYPE);
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
returnType,
TypeAnnotation.TypeAnnotationTarget.METHOD_RETURN);
}
/**
......@@ -535,12 +535,12 @@ public abstract class Executable extends AccessibleObject
*/
public AnnotatedType getAnnotatedReceiverType() {
return TypeAnnotationParser.buildAnnotatedType(getTypeAnnotationBytes(),
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
getDeclaringClass(),
TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER_TYPE);
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
getDeclaringClass(),
TypeAnnotation.TypeAnnotationTarget.METHOD_RECEIVER);
}
/**
......@@ -556,7 +556,13 @@ public abstract class Executable extends AccessibleObject
* @since 1.8
*/
public AnnotatedType[] getAnnotatedParameterTypes() {
throw new UnsupportedOperationException("Not yet");
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
getParameterTypes(),
TypeAnnotation.TypeAnnotationTarget.METHOD_FORMAL_PARAMETER);
}
/**
......@@ -573,12 +579,12 @@ public abstract class Executable extends AccessibleObject
*/
public AnnotatedType[] getAnnotatedExceptionTypes() {
return TypeAnnotationParser.buildAnnotatedTypes(getTypeAnnotationBytes(),
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
getGenericExceptionTypes(),
TypeAnnotation.TypeAnnotationTarget.THROWS);
sun.misc.SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
getGenericExceptionTypes(),
TypeAnnotation.TypeAnnotationTarget.THROWS);
}
}
......@@ -1161,6 +1161,6 @@ class Field extends AccessibleObject implements Member {
this,
getDeclaringClass(),
getGenericType(),
TypeAnnotation.TypeAnnotationTarget.FIELD_TYPE);
TypeAnnotation.TypeAnnotationTarget.FIELD);
}
}
......@@ -350,8 +350,19 @@ public class Modifier {
return (mod & MANDATED) != 0;
}
/**
* See JLSv3 section 8.1.1.
// Note on the FOO_MODIFIERS fields and fooModifiers() methods:
// the sets of modifiers are not guaranteed to be constants
// across time and Java SE releases. Therefore, it would not be
// appropriate to expose an external interface to this information
// that would allow the values to be treated as Java-level
// constants since the values could be constant folded and updates
// to the sets of modifiers missed. Thus, the fooModifiers()
// methods return an unchanging values for a given release, but a
// value that can potentially change over time.
/**
* The Java source modifiers that can be applied to a class.
* @jls 8.1.1 Class Modifiers
*/
private static final int CLASS_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
......@@ -359,7 +370,8 @@ public class Modifier {
Modifier.STRICT;
/**
* See JLSv3 section 9.1.1.
* The Java source modifiers that can be applied to an interface.
* @jls 9.1.1 Interface Modifiers
*/
private static final int INTERFACE_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
......@@ -367,13 +379,15 @@ public class Modifier {
/**
* See JLSv3 section 8.8.3.
* The Java source modifiers that can be applied to a constructor.
* @jls 8.8.3 Constructor Modifiers
*/
private static final int CONSTRUCTOR_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE;
/**
* See JLSv3 section 8.4.3.
* The Java source modifiers that can be applied to a method.
* @jls8.4.3 Method Modifiers
*/
private static final int METHOD_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
......@@ -381,13 +395,21 @@ public class Modifier {
Modifier.SYNCHRONIZED | Modifier.NATIVE | Modifier.STRICT;
/**
* See JLSv3 section 8.3.1.
* The Java source modifiers that can be applied to a field.
* @jls 8.3.1 Field Modifiers
*/
private static final int FIELD_MODIFIERS =
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT |
Modifier.VOLATILE;
/**
* The Java source modifiers that can be applied to a method or constructor parameter.
* @jls 8.4.1 Formal Parameters
*/
private static final int PARAMETER_MODIFIERS =
Modifier.FINAL;
/**
*
*/
......@@ -411,7 +433,7 @@ public class Modifier {
* Return an {@code int} value OR-ing together the source language
* modifiers that can be applied to an interface.
* @return an {@code int} value OR-ing together the source language
* modifiers that can be applied to an inteface.
* modifiers that can be applied to an interface.
*
* @jls 9.1.1 Interface Modifiers
* @since 1.7
......@@ -446,7 +468,6 @@ public class Modifier {
return METHOD_MODIFIERS;
}
/**
* Return an {@code int} value OR-ing together the source language
* modifiers that can be applied to a field.
......@@ -459,4 +480,17 @@ public class Modifier {
public static int fieldModifiers() {
return FIELD_MODIFIERS;
}
/**
* Return an {@code int} value OR-ing together the source language
* modifiers that can be applied to a parameter.
* @return an {@code int} value OR-ing together the source language
* modifiers that can be applied to a parameter.
*
* @jls 8.4.1 Formal Parameters
* @since 1.8
*/
public static int parameterModifiers() {
return PARAMETER_MODIFIERS;
}
}
......@@ -200,6 +200,19 @@ public final class Parameter implements AnnotatedElement {
return tmp;
}
/**
* Returns an AnnotatedType object that represents the use of a type to
* specify the type of the formal parameter represented by this Parameter.
*
* @return an {@code AnnotatedType} object representing the use of a type
* to specify the type of the formal parameter represented by this
* Parameter
*/
public AnnotatedType getAnnotatedType() {
// no caching for now
return executable.getAnnotatedParameterTypes()[index];
}
private transient volatile Class<?> parameterClassCache = null;
/**
......
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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,15 +25,19 @@
package java.util.regex;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.CharacterIterator;
import java.text.Normalizer;
import java.util.Locale;
import java.util.Iterator;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Predicate;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
......@@ -5742,4 +5746,83 @@ NEXT: while (i <= last) {
return Character.isMirrored(ch);}});
}
}
/**
* Creates a predicate which can be used to match a string.
*
* @return The predicate which can be used for matching on a string
* @since 1.8
*/
public Predicate<String> asPredicate() {
return s -> matcher(s).find();
}
/**
* Creates a stream from the given input sequence around matches of this
* pattern.
*
* <p> The stream returned by this method contains each substring of the
* input sequence that is terminated by another subsequence that matches
* this pattern or is terminated by the end of the input sequence. The
* substrings in the stream are in the order in which they occur in the
* input.
*
* <p> If this pattern does not match any subsequence of the input then
* the resulting stream has just one element, namely the input sequence in
* string form.
*
* <p> If the input sequence is mutable, it must remain constant during the
* execution of the terminal stream operation. Otherwise, the result of the
* terminal stream operation is undefined.
*
* @param input
* The character sequence to be split
*
* @return The stream of strings computed by splitting the input
* around matches of this pattern
* @see #split(CharSequence)
* @since 1.8
*/
public Stream<String> splitAsStream(final CharSequence input) {
class MatcherIterator implements Iterator<String> {
private final Matcher matcher;
// The start position of the next sub-sequence of input
// when current == input.length there are no more elements
private int current;
// null if the next element, if any, needs to obtained
private String nextElement;
MatcherIterator() {
this.matcher = matcher(input);
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
String n = nextElement;
nextElement = null;
return n;
}
public boolean hasNext() {
if (nextElement != null)
return true;
if (current == input.length())
return false;
if (matcher.find()) {
nextElement = input.subSequence(current, matcher.start()).toString();
current = matcher.end();
} else {
nextElement = input.subSequence(current, input.length()).toString();
current = input.length();
}
return true;
}
}
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(
new MatcherIterator(), Spliterator.ORDERED | Spliterator.NONNULL));
}
}
......@@ -94,12 +94,7 @@ final class MatchOps {
}
}
// @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
Supplier<BooleanTerminalSink<T>> s = new Supplier<BooleanTerminalSink<T>>() {
@Override
public BooleanTerminalSink<T> get() {return new MatchSink();}
};
return new MatchOp<>(StreamShape.REFERENCE, matchKind, s);
return new MatchOp<>(StreamShape.REFERENCE, matchKind, MatchSink::new);
}
/**
......@@ -128,12 +123,7 @@ final class MatchOps {
}
}
// @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
Supplier<BooleanTerminalSink<Integer>> s = new Supplier<BooleanTerminalSink<Integer>>() {
@Override
public BooleanTerminalSink<Integer> get() {return new MatchSink();}
};
return new MatchOp<>(StreamShape.INT_VALUE, matchKind, s);
return new MatchOp<>(StreamShape.INT_VALUE, matchKind, MatchSink::new);
}
/**
......@@ -163,12 +153,7 @@ final class MatchOps {
}
}
// @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
Supplier<BooleanTerminalSink<Long>> s = new Supplier<BooleanTerminalSink<Long>>() {
@Override
public BooleanTerminalSink<Long> get() {return new MatchSink();}
};
return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, s);
return new MatchOp<>(StreamShape.LONG_VALUE, matchKind, MatchSink::new);
}
/**
......@@ -198,12 +183,7 @@ final class MatchOps {
}
}
// @@@ Workaround for JDK-8011591 -- when fixed, replace s with constructor ref
Supplier<BooleanTerminalSink<Double>> s = new Supplier<BooleanTerminalSink<Double>>() {
@Override
public BooleanTerminalSink<Double> get() {return new MatchSink();}
};
return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, s);
return new MatchOp<>(StreamShape.DOUBLE_VALUE, matchKind, MatchSink::new);
}
/**
......
/*
* 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
......@@ -27,6 +27,7 @@ package java.util.zip;
import java.io.SequenceInputStream;
import java.io.ByteArrayInputStream;
import java.io.FilterInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.EOFException;
......@@ -212,7 +213,10 @@ class GZIPInputStream extends InflaterInputStream {
int n = inf.getRemaining();
if (n > 0) {
in = new SequenceInputStream(
new ByteArrayInputStream(buf, len - n, n), in);
new ByteArrayInputStream(buf, len - n, n),
new FilterInputStream(in) {
public void close() throws IOException {}
});
}
// Uses left-to-right evaluation order
if ((readUInt(in) != crc.getValue()) ||
......
......@@ -427,6 +427,15 @@ public class JDesktopPane extends JLayeredPane implements Accessible
}
}
/**
* {@inheritDoc}
*/
@Override
public void remove(Component comp) {
super.remove(comp);
updateFramesCache();
}
/**
* Selects the next <code>JInternalFrame</code> in this desktop pane.
*
......
......@@ -127,7 +127,7 @@ public class AAShapePipe
private static byte[] theTile;
public synchronized static byte[] getAlphaTile(int len) {
private synchronized static byte[] getAlphaTile(int len) {
byte[] t = theTile;
if (t == null || t.length < len) {
t = new byte[len];
......@@ -137,7 +137,7 @@ public class AAShapePipe
return t;
}
public synchronized static void dropAlphaTile(byte[] t) {
private synchronized static void dropAlphaTile(byte[] t) {
theTile = t;
}
......
......@@ -321,15 +321,7 @@ class ServerImpl implements TimeSource {
public void run() {
while (!finished) {
try {
ListIterator<HttpConnection> li =
connsToRegister.listIterator();
for (HttpConnection c : connsToRegister) {
reRegister(c);
}
connsToRegister.clear();
List<Event> list = null;
selector.select(1000);
synchronized (lolock) {
if (events.size() > 0) {
list = events;
......@@ -343,8 +335,14 @@ class ServerImpl implements TimeSource {
}
}
/* process the selected list now */
for (HttpConnection c : connsToRegister) {
reRegister(c);
}
connsToRegister.clear();
selector.select(1000);
/* process the selected list now */
Set<SelectionKey> selected = selector.selectedKeys();
Iterator<SelectionKey> iter = selected.iterator();
while (iter.hasNext()) {
......
......@@ -83,12 +83,13 @@ public class TypeAnnotation {
CLASS_TYPE_PARAMETER,
METHOD_TYPE_PARAMETER,
CLASS_EXTENDS,
CLASS_IMPLEMENTS,
CLASS_PARAMETER_BOUND,
METHOD_PARAMETER_BOUND,
METHOD_RETURN_TYPE,
METHOD_RECEIVER_TYPE,
FIELD_TYPE,
CLASS_IMPLEMENTS, // Not in the spec
CLASS_TYPE_PARAMETER_BOUND,
METHOD_TYPE_PARAMETER_BOUND,
FIELD,
METHOD_RETURN,
METHOD_RECEIVER,
METHOD_FORMAL_PARAMETER,
THROWS;
}
public static class TypeAnnotationTargetInfo {
......
......@@ -282,10 +282,10 @@ public class TypeAnnotationParser {
AnnotatedElement boundsDecl;
TypeAnnotationTarget target;
if (decl instanceof Class) {
target = TypeAnnotationTarget.CLASS_PARAMETER_BOUND;
target = TypeAnnotationTarget.CLASS_TYPE_PARAMETER_BOUND;
boundsDecl = (Class)decl;
} else {
target = TypeAnnotationTarget.METHOD_PARAMETER_BOUND;
target = TypeAnnotationTarget.METHOD_TYPE_PARAMETER_BOUND;
boundsDecl = (Executable)decl;
}
return TypeAnnotation.filter(TypeAnnotationParser.parseAllTypeAnnotations(boundsDecl), target);
......@@ -371,14 +371,15 @@ public class TypeAnnotationParser {
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 final byte INSTANCEOF = (byte)0x43;
private static final byte NEW = (byte)0x44;
private static final byte CONSTRUCTOR_REFERENCE = (byte)0x45;
private static final byte METHOD_REFERENCE = (byte)0x46;
private static final byte CAST = (byte)0x47;
private static final byte CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT = (byte)0x48;
private static final byte METHOD_INVOCATION_TYPE_ARGUMENT = (byte)0x49;
private static final byte CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT = (byte)0x4A;
private static final byte METHOD_REFERENCE_TYPE_ARGUMENT = (byte)0x4B;
private static TypeAnnotation parseTypeAnnotation(ByteBuffer buf,
ConstantPool cp,
......@@ -417,19 +418,20 @@ public class TypeAnnotationParser {
return res;
}} break;
case CLASS_TYPE_PARAMETER_BOUND:
return parse2ByteTarget(TypeAnnotationTarget.CLASS_PARAMETER_BOUND, buf);
return parse2ByteTarget(TypeAnnotationTarget.CLASS_TYPE_PARAMETER_BOUND, buf);
case METHOD_TYPE_PARAMETER_BOUND:
return parse2ByteTarget(TypeAnnotationTarget.METHOD_PARAMETER_BOUND, buf);
return parse2ByteTarget(TypeAnnotationTarget.METHOD_TYPE_PARAMETER_BOUND, buf);
case FIELD:
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.FIELD_TYPE);
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.FIELD);
case METHOD_RETURN:
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RETURN_TYPE);
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RETURN);
case METHOD_RECEIVER:
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RECEIVER_TYPE);
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_RECEIVER);
case METHOD_FORMAL_PARAMETER: {
// Todo
byte index = buf.get();
} break;
return new TypeAnnotationTargetInfo(TypeAnnotationTarget.METHOD_FORMAL_PARAMETER,
index);
} //unreachable break;
case THROWS:
return parseShortTarget(TypeAnnotationTarget.THROWS, buf);
......@@ -445,30 +447,27 @@ public class TypeAnnotationParser {
short varLength = buf.getShort();
short index = buf.getShort();
}
break;
return null;
case EXCEPTION_PARAMETER: {
byte index = buf.get();
} break;
case CAST:
}
return null;
case INSTANCEOF:
case NEW: {
short offset = buf.getShort();
} break;
case CONSTRUCTOR_REFERENCE_RECEIVER:
case METHOD_REFERENCE_RECEIVER: {
case NEW:
case CONSTRUCTOR_REFERENCE:
case METHOD_REFERENCE: {
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;
}
return null;
case CAST:
case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
case METHOD_INVOCATION_TYPE_ARGUMENT:
case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
case METHOD_REFERENCE_TYPE_ARGUMENT: {
short offset = buf.getShort();
byte index = buf.get();
} break;
}
return null;
default:
// will throw error below
......
/*
* Copyright (c) 2003, 2004, 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
......@@ -27,7 +27,7 @@ package sun.reflect.generics.reflectiveObjects;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Type;
import java.util.Objects;
/**
* Implementation of GenericArrayType interface for core reflection.
......@@ -81,18 +81,13 @@ public class GenericArrayTypeImpl
if (o instanceof GenericArrayType) {
GenericArrayType that = (GenericArrayType) o;
Type thatComponentType = that.getGenericComponentType();
return genericComponentType == null ?
thatComponentType == null :
genericComponentType.equals(thatComponentType);
return Objects.equals(genericComponentType, that.getGenericComponentType());
} else
return false;
}
@Override
public int hashCode() {
return (genericComponentType == null) ?
0:
genericComponentType.hashCode();
return Objects.hashCode(genericComponentType);
}
}
/*
* Copyright (c) 2003, 2004, 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
......@@ -33,7 +33,7 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.Objects;
/** Implementing class for ParameterizedType interface. */
......@@ -47,9 +47,7 @@ public class ParameterizedTypeImpl implements ParameterizedType {
Type ownerType) {
this.actualTypeArguments = actualTypeArguments;
this.rawType = rawType;
if (ownerType != null) {
this.ownerType = ownerType;
} else { this.ownerType = rawType.getDeclaringClass();}
this.ownerType = (ownerType != null) ? ownerType : rawType.getDeclaringClass();
validateConstructorArguments();
}
......@@ -62,7 +60,6 @@ public class ParameterizedTypeImpl implements ParameterizedType {
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
/**
......@@ -189,14 +186,9 @@ public class ParameterizedTypeImpl implements ParameterizedType {
return ownerEquality && rawEquality && typeArgEquality;
}
return
(ownerType == null ?
thatOwner == null :
ownerType.equals(thatOwner)) &&
(rawType == null ?
thatRawType == null :
rawType.equals(thatRawType)) &&
Objects.equals(ownerType, thatOwner) &&
Objects.equals(rawType, thatRawType) &&
Arrays.equals(actualTypeArguments, // avoid clone
that.getActualTypeArguments());
} else
......@@ -207,8 +199,8 @@ public class ParameterizedTypeImpl implements ParameterizedType {
public int hashCode() {
return
Arrays.hashCode(actualTypeArguments) ^
(ownerType == null ? 0 : ownerType.hashCode() ) ^
(rawType == null ? 0 : rawType.hashCode() );
Objects.hashCode(ownerType) ^
Objects.hashCode(rawType);
}
public String toString() {
......@@ -239,10 +231,7 @@ public class ParameterizedTypeImpl implements ParameterizedType {
for(Type t: actualTypeArguments) {
if (!first)
sb.append(", ");
if (t instanceof Class)
sb.append(((Class)t).getName());
else
sb.append(t.toString());
sb.append(t.getTypeName());
first = false;
}
sb.append(">");
......
......@@ -170,13 +170,8 @@ public class TypeVariableImpl<D extends GenericDeclaration>
GenericDeclaration thatDecl = that.getGenericDeclaration();
String thatName = that.getName();
return
(genericDeclaration == null ?
thatDecl == null :
genericDeclaration.equals(thatDecl)) &&
(name == null ?
thatName == null :
name.equals(thatName));
return Objects.equals(genericDeclaration, thatDecl) &&
Objects.equals(name, thatName);
} else
return false;
......
/*
* Copyright (c) 2003, 2004, 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
......@@ -203,10 +203,7 @@ public class WildcardTypeImpl extends LazyReflectiveObjectGenerator
sb.append(" & ");
first = false;
if (bound instanceof Class)
sb.append(((Class)bound).getName() );
else
sb.append(bound.toString());
sb.append(bound.getTypeName());
}
return sb.toString();
}
......
......@@ -55,11 +55,11 @@ public abstract class EType {
}
public static void initStatic() {
boolean allowed = true;
boolean allowed = false;
try {
Config cfg = Config.getInstance();
String temp = cfg.get("libdefaults", "allow_weak_crypto");
if (temp != null && temp.equals("false")) allowed = false;
if (temp != null && temp.equals("true")) allowed = true;
} catch (Exception exc) {
if (DEBUG) {
System.out.println ("Exception in getting allow_weak_crypto, " +
......
......@@ -64,7 +64,7 @@ public abstract class CertPathHelper {
instance.implSetPathToNames(sel, names);
}
static void setDateAndTime(X509CRLSelector sel, Date date, long skew) {
public static void setDateAndTime(X509CRLSelector sel, Date date, long skew) {
instance.implSetDateAndTime(sel, date, skew);
}
}
......@@ -50,7 +50,7 @@ import sun.security.x509.*;
* @author Sean Mullan
* @since 1.4.2
*/
class DistributionPointFetcher {
public class DistributionPointFetcher {
private static final Debug debug = Debug.getInstance("certpath");
......@@ -66,13 +66,14 @@ class DistributionPointFetcher {
* Return the X509CRLs matching this selector. The selector must be
* an X509CRLSelector with certificateChecking set.
*/
static Collection<X509CRL> getCRLs(X509CRLSelector selector,
boolean signFlag, PublicKey prevKey,
String provider,
List<CertStore> certStores,
boolean[] reasonsMask,
Set<TrustAnchor> trustAnchors,
Date validity)
public static Collection<X509CRL> getCRLs(X509CRLSelector selector,
boolean signFlag,
PublicKey prevKey,
String provider,
List<CertStore> certStores,
boolean[] reasonsMask,
Set<TrustAnchor> trustAnchors,
Date validity)
throws CertStoreException
{
X509Certificate cert = selector.getCertificateChecking();
......
/*
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 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
......@@ -85,10 +85,9 @@ public final class OCSP {
* value is negative, set the timeout length to the default.
*/
private static int initializeTimeout() {
int tmp = java.security.AccessController.doPrivileged(
new GetIntegerAction("com.sun.security.ocsp.timeout",
DEFAULT_CONNECT_TIMEOUT));
if (tmp < 0) {
Integer tmp = java.security.AccessController.doPrivileged(
new GetIntegerAction("com.sun.security.ocsp.timeout"));
if (tmp == null || tmp < 0) {
return DEFAULT_CONNECT_TIMEOUT;
}
// Convert to milliseconds, as the system property will be
......
/*
* 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
......@@ -43,6 +43,7 @@ import java.util.Map;
import javax.security.auth.x500.X500Principal;
import sun.misc.HexDumpEncoder;
import sun.security.action.GetIntegerAction;
import sun.security.x509.*;
import sun.security.util.*;
......@@ -144,9 +145,31 @@ public final class OCSPResponse {
// Object identifier for the OCSPSigning key purpose
private static final String KP_OCSP_SIGNING_OID = "1.3.6.1.5.5.7.3.9";
// Maximum clock skew in milliseconds (15 minutes) allowed when checking
// validity of OCSP responses
private static final long MAX_CLOCK_SKEW = 900000;
// Default maximum clock skew in milliseconds (15 minutes)
// allowed when checking validity of OCSP responses
private static final int DEFAULT_MAX_CLOCK_SKEW = 900000;
/**
* Integer value indicating the maximum allowable clock skew, in seconds,
* to be used for the OCSP check.
*/
private static final int MAX_CLOCK_SKEW = initializeClockSkew();
/**
* Initialize the maximum allowable clock skew by getting the OCSP
* clock skew system property. If the property has not been set, or if its
* value is negative, set the skew to the default.
*/
private static int initializeClockSkew() {
Integer tmp = java.security.AccessController.doPrivileged(
new GetIntegerAction("com.sun.security.ocsp.clockSkew"));
if (tmp == null || tmp < 0) {
return DEFAULT_MAX_CLOCK_SKEW;
}
// Convert to milliseconds, as the system property will be
// specified in seconds
return tmp * 1000;
}
// an array of all of the CRLReasons (used in SingleResponse)
private static CRLReason[] values = CRLReason.values();
......
/*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 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
......@@ -51,6 +51,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import sun.security.action.GetIntegerAction;
import sun.security.x509.AccessDescription;
import sun.security.x509.GeneralNameInterface;
import sun.security.x509.URIName;
......@@ -121,6 +122,33 @@ class URICertStore extends CertStoreSpi {
private CertStore ldapCertStore;
private String ldapPath;
// Default maximum connect timeout in milliseconds (15 seconds)
// allowed when downloading CRLs
private static final int DEFAULT_CRL_CONNECT_TIMEOUT = 15000;
/**
* Integer value indicating the connect timeout, in seconds, to be
* used for the CRL download. A timeout of zero is interpreted as
* an infinite timeout.
*/
private static final int CRL_CONNECT_TIMEOUT = initializeTimeout();
/**
* Initialize the timeout length by getting the CRL timeout
* system property. If the property has not been set, or if its
* value is negative, set the timeout length to the default.
*/
private static int initializeTimeout() {
Integer tmp = java.security.AccessController.doPrivileged(
new GetIntegerAction("com.sun.security.crl.timeout"));
if (tmp == null || tmp < 0) {
return DEFAULT_CRL_CONNECT_TIMEOUT;
}
// Convert to milliseconds, as the system property will be
// specified in seconds
return tmp * 1000;
}
/**
* Creates a URICertStore.
*
......@@ -364,6 +392,7 @@ class URICertStore extends CertStoreSpi {
connection.setIfModifiedSince(lastModified);
}
long oldLastModified = lastModified;
connection.setConnectTimeout(CRL_CONNECT_TIMEOUT);
try (InputStream in = connection.getInputStream()) {
lastModified = connection.getLastModified();
if (oldLastModified != 0) {
......
/*
* 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
......@@ -822,7 +822,7 @@ final class SSLSessionImpl extends ExtendedSSLSession {
* them are removed.
*/
@Override
public void finalize() {
protected void finalize() throws Throwable {
String[] names = getValueNames();
for (int i = 0; i < names.length; i++) {
removeValue(names[i]);
......
/*
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
......@@ -90,6 +90,8 @@ static const int BAD_MAGIC = ENOEXEC;
static const char * BAD_EXEC_MSG = "jexec failed";
static const char * CRAZY_EXEC_MSG = "missing args";
static const char * MISSING_JAVA_MSG = "can't locate java";
static const char * BAD_ARG_MSG = "incorrect number of arguments";
static const char * MEM_FAILED_MSG = "memory allocation failed";
#ifdef __linux__
static const char * BAD_PATHNAME_MSG = "invalid path";
static const char * BAD_FILE_MSG = "invalid file";
......@@ -156,6 +158,7 @@ int main(int argc, const char * argv[]) {
const char ** nargv = NULL; /* new args array */
int nargc = 0; /* new args array count */
int argi = 0; /* index into old array */
size_t alen = 0; /* length of new array */
/* Make sure we have something to work with */
if ((argc < 1) || (argv == NULL)) {
......@@ -168,8 +171,14 @@ int main(int argc, const char * argv[]) {
if (getJavaPath(argv[argi++], java, RELATIVE_DEPTH) != 0) {
errorExit(errno, MISSING_JAVA_MSG);
}
nargv = (const char **) malloc((argc + 2) * (sizeof (const char *)));
alen = (argc + 2) * (sizeof (const char *));
if (alen <= 0 || alen > INT_MAX / sizeof(char *)) {
errorExit(errno, BAD_ARG_MSG);
}
nargv = (const char **) malloc(alen);
if (nargv == NULL) {
errorExit(errno, MEM_FAILED_MSG);
}
nargv[nargc++] = java;
#ifdef __linux__
......
......@@ -1887,7 +1887,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
switch (getWindowType())
{
case NORMAL:
typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_NORMAL;
typeAtom = (ownerPeer == null) ?
protocol.XA_NET_WM_WINDOW_TYPE_NORMAL :
protocol.XA_NET_WM_WINDOW_TYPE_DIALOG;
break;
case UTILITY:
typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_UTILITY;
......
......@@ -759,9 +759,7 @@ public abstract class WComponentPeer extends WObjectPeer
WComponentPeer(Component target) {
this.target = target;
this.paintArea = new RepaintArea();
Container parent = WToolkit.getNativeContainer(target);
WComponentPeer parentPeer = (WComponentPeer) WToolkit.targetToPeer(parent);
create(parentPeer);
create(getNativeParent());
// fix for 5088782: check if window object is created successfully
checkCreation();
......@@ -771,6 +769,17 @@ public abstract class WComponentPeer extends WObjectPeer
}
abstract void create(WComponentPeer parent);
/**
* Gets the native parent of this peer. We use the term "parent" explicitly,
* because we override the method in top-level window peer implementations.
*
* @return the parent container/owner of this peer.
*/
WComponentPeer getNativeParent() {
Container parent = SunToolkit.getNativeContainer((Component) target);
return (WComponentPeer) WToolkit.targetToPeer(parent);
}
protected void checkCreation()
{
if ((hwnd == 0) || (pData == 0))
......
......@@ -215,6 +215,12 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
createAwtWindow(parent);
}
@Override
final WComponentPeer getNativeParent() {
final Container owner = ((Window) target).getOwner();
return (WComponentPeer) WToolkit.targetToPeer(owner);
}
// should be overriden in WDialogPeer
protected void realShow() {
super.show();
......
......@@ -224,7 +224,7 @@ class WindowsFileCopy {
String linkTarget = WindowsLinkSupport.readLink(source);
int flags = SYMBOLIC_LINK_FLAG_DIRECTORY;
CreateSymbolicLink(targetPath,
addPrefixIfNeeded(linkTarget),
WindowsPath.addPrefixIfNeeded(linkTarget),
flags);
}
} catch (WindowsException x) {
......@@ -414,7 +414,7 @@ class WindowsFileCopy {
} else {
String linkTarget = WindowsLinkSupport.readLink(source);
CreateSymbolicLink(targetPath,
addPrefixIfNeeded(linkTarget),
WindowsPath.addPrefixIfNeeded(linkTarget),
SYMBOLIC_LINK_FLAG_DIRECTORY);
}
} catch (WindowsException x) {
......@@ -502,18 +502,4 @@ class WindowsFileCopy {
priv.drop();
}
}
/**
* Add long path prefix to path if required
*/
private static String addPrefixIfNeeded(String path) {
if (path.length() > 248) {
if (path.startsWith("\\\\")) {
path = "\\\\?\\UNC" + path.substring(1, path.length());
} else {
path = "\\\\?\\" + path;
}
}
return path;
}
}
......@@ -231,7 +231,7 @@ class WindowsLinkSupport {
int end = (next == -1) ? path.length() : next;
String search = sb.toString() + path.substring(curr, end);
try {
FirstFile fileData = FindFirstFile(addLongPathPrefixIfNeeded(search));
FirstFile fileData = FindFirstFile(WindowsPath.addPrefixIfNeeded(search));
FindClose(fileData.handle());
// if a reparse point is encountered then we must return the
......@@ -405,20 +405,6 @@ class WindowsLinkSupport {
return path;
}
/**
* Add long path prefix to path if required.
*/
private static String addLongPathPrefixIfNeeded(String path) {
if (path.length() > 248) {
if (path.startsWith("\\\\")) {
path = "\\\\?\\UNC" + path.substring(1, path.length());
} else {
path = "\\\\?\\" + path;
}
}
return path;
}
/**
* Strip long path or symbolic link prefix from path
*/
......
......@@ -283,7 +283,7 @@ class WindowsPath extends AbstractPath {
// Add long path prefix to path if required
static String addPrefixIfNeeded(String path) {
if (path.length() > 248) {
if (path.length() > MAX_PATH) {
if (path.startsWith("\\\\")) {
path = "\\\\?\\UNC" + path.substring(1, path.length());
} else {
......
......@@ -517,6 +517,7 @@ jdk_other: $(call TestDirs, \
javax/xml/soap \
javax/xml/ws com/sun/internal/ws com/sun/org/glassfish \
jdk/asm \
jdk/lambda \
com/sun/org/apache/xerces \
com/sun/corba \
com/sun/tracing \
......
/*
* 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
......@@ -28,7 +28,7 @@
* @author anton.tarasov@sun.com: area=awt.focus
* @library ../../regtesthelpers
* @build Util
* @run main OverrideRedirectWindowActivationTest
* @run main SimpleWindowActivationTest
*/
import java.awt.*;
import java.awt.event.*;
......@@ -37,7 +37,7 @@ import javax.swing.SwingUtilities;
import sun.awt.SunToolkit;
import test.java.awt.regtesthelpers.Util;
public class OverrideRedirectWindowActivationTest {
public class SimpleWindowActivationTest {
private static Frame frame;
private static Window window;
......@@ -115,7 +115,7 @@ public class OverrideRedirectWindowActivationTest {
wbutton = new Button("wbutton");
label = new Label("label");
window.setBounds(800, 200, 200, 100);
window.setBounds(800, 200, 300, 100);
window.setLayout(new FlowLayout());
window.add(wbutton);
window.add(label);
......@@ -126,7 +126,7 @@ public class OverrideRedirectWindowActivationTest {
private static void createAndShowFrame() {
fbutton = new Button("fbutton");
frame.setBounds(800, 0, 200, 100);
frame.setBounds(800, 0, 300, 100);
frame.setLayout(new FlowLayout());
frame.add(fbutton);
frame.setVisible(true);
......
# 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
......@@ -22,7 +22,8 @@
${TESTJAVA}/bin/javac -cp ${TESTSRC} -d . ${TESTSRC}/BadDisplayTest.java
export DISPLAY=
DISPLAY=
export DISPLAY
OS=`uname -s`
case "$OS" in
......
......@@ -103,7 +103,6 @@ public class Test4679556 extends AbstractTest {
}
protected void initialize(XMLEncoder encoder) {
encoder.setExceptionListener(this);
encoder.setPersistenceDelegate(C.class, new DefaultPersistenceDelegate() {
protected Expression instantiate(Object oldInstance, Encoder out) {
C c = (C) oldInstance;
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
# This file identifies root(s) of the test-ng hierarchy.
bootclasspath.dirs = .
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册