提交 e0933fb3 编写于 作者: H herrick

6797688: Umbrella: Merge all JDK 6u4 - 6u12 deployment code into JDK7

6845973: Update JDK7 with deployment changes in 6u13, 6u14
4802695: Support 64-bit Java Plug-in and Java webstart on Windows/Linux on AMD64
6825019: DownloadManager should not be loaded and referenced for full JRE
6738770: REGRESSION:JSException throws when use LiveConnect javascript facility
6772884: plugin2 : java.lang.OutOfMemoryError or crash
6707535: Crossing domain hole affecting multiple sites/domains using plug-in
6728071: Non-verification of Update files may allow unintended updates
6704154: Code loaded from local filesystem should not get access to localhost
6727081: Web Start security restrictions bypass using special extension jnlp
6727079: Java Web Start Socket() restriction bypass
6727071: Cache location/user name information disclosure in SingleInstanceImpl.
6716217: AppletClassLoader adds permissions based on codebase regardless of CS
6694892: Java Webstart inclusion via system properties override [CVE-2008-2086]
6704074: localhost socket access due to cache location exposed
6703909: Java webstart arbitrary file creation using nativelib
6665315: browser crashes when deployment.properties has more slashes ( / )
6660121: Encoding values in JNLP files can cause buffer overflow
6606110: URLConnection.setProxiedHost for resources that are loaded via proxy
6581221: SSV(VISTA): Redirection FAILS to work if user does a downgrade install
6609756: Buffer Overflow in Java ActiveX component
6608712: Bypassing the same origin policy in Java with crafted names
6534630: "gnumake clobber" doesn't
6849953: JDK7 - replacement of bufferoverflowU.lib on amd64 breaks build
6849029: Need some JDK7 merge clean-up after comments on the webrev
6847582: Build problem on JDK7 with isSecureProperty in merge
6827935: JDK 7 deployment merging - problem in Compiler-msvm.gmk
6823215: latest merge fixes from 6u12 -> JDK7
6816153: further mergers for JDK7 deployment integration
6807074: Fix Java Kernel and JQS in initial JDK7 builds
Summary: Initial changeset for implementing 6uX Deployment Features into JDK7
Reviewed-by: dgu, billyh
上级 a7445907
......@@ -91,10 +91,10 @@ ifeq ($(PLATFORM), windows)
CXXFLAGS_COMMON += $(MS_RUNTIME_OPTION)
LDOUTPUT = -Fe
# J2SE name required here
RC_FLAGS += /D "J2SE_FNAME=$(PGRM).exe" \
/D "J2SE_INTERNAL_NAME=$(PGRM)" \
/D "J2SE_FTYPE=0x1L"
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \
/D "JDK_INTERNAL_NAME=$(PGRM)" \
/D "JDK_FTYPE=0x1L"
RES = $(OBJDIR)/$(PGRM).res
else
......@@ -133,13 +133,19 @@ unpacker:
$(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_OPT= LDMAPFLAGS_DBG=
ifeq ($(PLATFORM), windows)
IMVERSIONVALUE=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
SED_ALL_MANIFEST=$(SED) -e 's%IMVERSION%$(IMVERSIONVALUE)%g'
updatefiles::
$(CAT) $(TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest | $(SED_ALL_MANIFEST) > $(OBJDIR)/unpack200.exe.manifest
winres:: $(RES)
else
updatefiles::
$(ECHO) "Manifest not required for Unix"
winres::
$(ECHO) "Resource files not required for Unix"
endif
$(UNPACK_EXE): $(UNPACK_EXE_FILES_o) winres
$(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
$(prep-target)
$(LINKER) $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
ifdef MT
......
#
# Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
# Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
......@@ -464,11 +464,48 @@ JDK_RC_NAME = \
JDK_RC_FVER = \
$(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER)
# J2SE name required here
RC_FLAGS += -d "J2SE_BUILD_ID=$(JDK_RC_BUILD_ID)" \
-d "J2SE_COMPANY=$(JDK_RC_COMPANY)" \
-d "J2SE_COMPONENT=$(JDK_RC_COMPONENT)" \
-d "J2SE_VER=$(JDK_RC_VER)" \
-d "J2SE_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
-d "J2SE_NAME=$(JDK_RC_NAME)" \
-d "J2SE_FVER=$(JDK_RC_FVER)"
# JDK name required here
RC_FLAGS += -d "JDK_BUILD_ID=$(JDK_RC_BUILD_ID)" \
-d "JDK_COMPANY=$(JDK_RC_COMPANY)" \
-d "JDK_COMPONENT=$(JDK_RC_COMPONENT)" \
-d "JDK_VER=$(JDK_RC_VER)" \
-d "JDK_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
-d "JDK_NAME=$(JDK_RC_NAME)" \
-d "JDK_FVER=$(JDK_RC_FVER)"
# Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available
ifeq ($(ARCH_DATA_MODEL), 32)
ifneq ($(KERNEL), off)
# This is a hack to use until 7-Zip (and UPX) bundles can be put
# under /java/devtools.
ifndef DEPLOY_TOPDIR
DEPLOY_TOPDIR=$(JDK_TOPDIR)/../deploy
endif
# Uncomment this block to cause build failure if above assumption false
#DCHK = $(shell if [ ! -d $(DEPLOY_TOPDIR) ] ; then \
# $(ECHO) deploy_not_a_peer_of_j2se ; \
#fi )
#ifeq ($(DCHK), deploy_not_a_peer_of_j2se)
# If a build failure points to control coming here it means
# it means deploy is not in the same directory
# as j2se. Java Kernel can't tolerate that for the time being.
#endif
EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \
$(ECHO) true ; \
else \
$(ECHO) false ; \
fi )
ifeq ($(EC_TMP), true)
EXTRA_COMP_INSTALL_PATH = lib\\\\deploy\\\\lzma.dll
# Crazy but true: deploy/make/plugin/jinstall/Makefile.jkernel does
# not include deploy/make/common/Defs-windows.gmk, either directly
# or indirectly. But it does include this file, so redundantly declare
# these variables that are in deploy/make/common/Defs-windows.gmk for
# the sake of the Java Kernel part of the deploy build. Whew!
EXTRA_COMP_LIB_NAME = lzma.dll
EXTRA_COMP_PATH = $(OUTPUTDIR)/tmp/deploy/lzma/win32/obj
EXTRA_COMP_CMD_PATH = $(EXTRA_COMP_PATH)/lzma.exe
EXTRA_COMP_LIB_PATH = $(EXTRA_COMP_PATH)/$(EXTRA_COMP_LIB_NAME)
endif
endif
endif
......@@ -207,10 +207,10 @@ ifndef LOCAL_RESOURCE_FILE
endif
@$(ECHO) Created $@
# J2SE name required here
RC_FLAGS += /D "J2SE_FNAME=$(LIBRARY).dll" \
/D "J2SE_INTERNAL_NAME=$(LIBRARY)" \
/D "J2SE_FTYPE=0x2L"
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
/D "JDK_INTERNAL_NAME=$(LIBRARY)" \
/D "JDK_FTYPE=0x2L"
$(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
ifndef LOCAL_RESOURCE_FILE
......
......@@ -123,10 +123,10 @@ $(ACTUAL_PROGRAM):: classes $(JVMCFG) $(INIT)
#
ifeq ($(PLATFORM), windows)
# J2SE name required here
RC_FLAGS += /D "J2SE_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
/D "J2SE_INTERNAL_NAME=$(PROGRAM)" \
/D "J2SE_FTYPE=0x1L"
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
/D "JDK_INTERNAL_NAME=$(PROGRAM)" \
/D "JDK_FTYPE=0x1L"
$(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
@$(prep-target)
......
......@@ -797,6 +797,11 @@ ifeq ($(PLATFORM), windows)
$(CD) $(JRE_IMAGE_DIR)/lib && \
$(RM) java.$(LIB_SUFFIX) jvm.$(LIB_SUFFIX) \
hpi.$(LIB_SUFFIX) awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
ifeq ($(ARCH_DATA_MODEL), 32)
@# The Java Kernel JRE image ships with a special VM. It is not included
@# in the full JRE image, so remove it. Also, is it only for 32-bit windows.
$(CD) $(JRE_IMAGE_DIR)/bin && $(RM) -r kernel
endif
endif # Windows
ifneq ($(PLATFORM), windows)
$(call copy-man-pages,$(JRE_IMAGE_DIR),$(JRE_MAN_PAGES))
......
......@@ -35,8 +35,8 @@ ifeq ($(PLATFORM), windows)
LIBEXE = $(COMPILER_PATH)lib
LINK = $(COMPILER_PATH)link
RC = $(MSDEVTOOLS_PATH)rc
RSC = $(MSDEVTOOLS_PATH)rc
LINK32 = $(LINK)
RSC = $(RC)
# Fill in unknown values
COMPILER_NAME=Unknown MSVC Compiler
......@@ -98,6 +98,9 @@ ifeq ($(PLATFORM), windows)
endif
ifeq ($(CC_MAJORVER), 14)
ifeq ($(ARCH), amd64)
#rebase and midl moved out of Visual Studio into the SDK:
REBASE = $(MSDEVTOOLS_PATH)/rebase
MTL = $(MSDEVTOOLS_PATH)/midl.exe
ifeq ($(CC_MICROVER), 30701)
# This should be: CC_VER=14.00.30701 LINK_VER=8.00.30701
# WARNING: it says 14, but it is such an early build it doesn't
......@@ -110,6 +113,8 @@ ifeq ($(PLATFORM), windows)
COMPILER_NAME=Microsoft Platform SDK - April 2005 Edition (3790.1830)
COMPILER_VERSION=VS2005
endif
else
REBASE = $(COMPILER_PATH)../rebase
endif
endif
ifeq ($(CC_MAJORVER), 15)
......@@ -120,7 +125,6 @@ ifeq ($(PLATFORM), windows)
endif
# This will cause problems if ALT_COMPILER_PATH is defined to ""
# which is a directive to use the PATH.
REBASE = $(COMPILER_PATH)../REBASE
ifndef COMPILER_PATH
COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
endif
......
......@@ -72,6 +72,7 @@ ADB = $(UTILS_COMMAND_PATH)adb
AR = $(UTILS_CCS_BIN_PATH)ar
AS = $(UTILS_CCS_BIN_PATH)as
BASENAME = $(UTILS_COMMAND_PATH)basename
BZIP2 = $(UTILS_COMMAND_PATH)bzip2
CAT = $(UTILS_COMMAND_PATH)cat
CHMOD = $(UTILS_COMMAND_PATH)chmod
CMP = $(UTILS_USR_BIN_PATH)cmp
......@@ -157,6 +158,7 @@ ifeq ($(PLATFORM),windows)
endif
# Re-define some utilities
LEX =# override GNU Make intrinsic: no lex on windows
SHA1SUM = $(UNIXCOMMAND_PATH)openssl sha1
endif
# Linux specific
......
......@@ -518,7 +518,7 @@ ifdef ALT_INSTALL_MSSDK
xALT_INSTALL_MSSDK :="$(subst \,/,$(ALT_INSTALL_MSSDK))"
INSTALL_MSSDK :=$(call FullPath,$(xALT_INSTALL_MSSDK))
else
INSTALL_MSSDK :=$(_psdk)
INSTALL_MSSDK :=$(_ms_sdk)
endif
INSTALL_MSSDK:=$(call AltCheckSpaces,INSTALL_MSSDK)
......@@ -645,6 +645,17 @@ ifeq ($(ARCH_DATA_MODEL), 32)
HOTSPOT_CLIENT_PATH:=$(call AltCheckValue,HOTSPOT_CLIENT_PATH)
endif
# HOTSPOT_KERNEL_PATH: location of kernel jvm library file.
ifeq ($(ARCH_DATA_MODEL), 32)
ifdef ALT_HOTSPOT_KERNEL_PATH
HOTSPOT_KERNEL_PATH :=$(call FullPath,$(ALT_HOTSPOT_KERNEL_PATH))
else
HOTSPOT_KERNEL_PATH =$(HOTSPOT_IMPORT_PATH)/$(ARCH_VM_SUBDIR)/kernel
endif
HOTSPOT_KERNEL_PATH:=$(call AltCheckSpaces,HOTSPOT_KERNEL_PATH)
HOTSPOT_KERNEL_PATH:=$(call AltCheckValue,HOTSPOT_KERNEL_PATH)
endif
# HOTSPOT_SERVER_PATH: location of server jvm library file.
ifdef ALT_HOTSPOT_SERVER_PATH
HOTSPOT_SERVER_PATH :=$(call FullPath,$(ALT_HOTSPOT_SERVER_PATH))
......@@ -663,4 +674,3 @@ else
endif
HOTSPOT_LIB_PATH:=$(call AltCheckSpaces,HOTSPOT_LIB_PATH)
HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
......@@ -277,6 +277,7 @@ endif
PROMOTED_RE_AREA = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted
PROMOTED_BUILD_LATEST = latest
PROMOTED_BUILD_BASEDIR = $(PROMOTED_RE_AREA)/$(PROMOTED_BUILD_LATEST)
PROMOTED_BUILD_DISTDIR = $(PROMOTED_BUILD_BASEDIR)/dist/$(PLATFORM)-$(ARCH)
PROMOTED_BUILD_BINARIES = $(PROMOTED_BUILD_BASEDIR)/binaries
# PARALLEL_COMPILE_JOBS: is the number of compiles done in parallel.
......
......@@ -1545,10 +1545,49 @@ ifeq ($(ARCH_DATA_MODEL), 32)
" and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
"" >> $(ERROR_FILE) ; \
fi
endif
@#
@# Check for presence of headers required for new Java Plug-In ("plugin2")
@#
@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin2_mozilla_headers/npapi.h ]; then \
$(ECHO) "ERROR: You do not have access to valid Mozilla header files for the new Java Plug-In. \n" \
" Please check your access to \n" \
" $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin2_mozilla_headers/npapi.h \n" \
" and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
"" >> $(ERROR_FILE) ; \
fi
endif
######################################################
# Make sure Java Kernel VM is accessible
######################################################
sane-kernel-vm:
ifeq ($(PLATFORM), windows)
ifeq ($(ARCH_DATA_MODEL), 32)
@if [ ! -r $(HOTSPOT_KERNEL_PATH)/jvm.dll ]; then \
$(ECHO) "ERROR: Your HOTSPOT_IMPORT_PATH does not include a Kernel VM... \n" \
" $(HOTSPOT_KERNEL_PATH)/jvm.dll \n" \
" Please check the value of ALT_HOTSPOT_IMPORT_PATH. \n" \
>> $(ERROR_FILE) ; \
fi
endif
endif
######################################################
# SECURITY_BASELINE_131 test
######################################################
security_baseline_131:
ifeq ($(PLATFORM), windows)
@if [ -z "$(SECURITY_BASELINE_131)" ]; then \
$(ECHO) "WARNING: Your SECURITY_BASELINE_131 setting is empty.\n" \
" Setting it to the default value of 1.3.1_20.\n" \
" It is recommended to set SECURITY_BASELINE_131.\n" \
"" >> $(WARNING_FILE) ; \
fi
endif
######################################################
# SECURITY_BASELINE_142 test
######################################################
......@@ -1575,6 +1614,19 @@ ifeq ($(PLATFORM), windows)
fi
endif
######################################################
# SECURITY_BASELINE_160 test
######################################################
security_baseline_160:
ifeq ($(PLATFORM), windows)
@if [ -z "$(SECURITY_BASELINE_160)" ]; then \
$(ECHO) "WARNING: Your SECURITY_BASELINE_160 setting is empty.\n" \
" Setting it to the default value of 1.6.0_11.\n" \
" It is recommended to set SECURITY_BASELINE_160.\n" \
"" >> $(WARNING_FILE) ; \
fi
endif
######################################################
# this should be the last rule in any target's sanity rule.
......
......@@ -64,6 +64,7 @@ FILES_c = \
jio.c \
logging.c \
jni_util.c \
jni_util_md.c \
jdk_util.c \
jdk_util_md.c \
check_version.c \
......
......@@ -40,6 +40,7 @@ include $(BUILDDIR)/common/Defs.gmk
SERVER_LOCATION = server
CLIENT_LOCATION = client
KERNEL_LOCATION = kernel
DB_SUFFIX = _db
......@@ -103,6 +104,12 @@ endif
ifeq ($(PLATFORM), windows)
# Windows vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Windows
# Add the Java Kernel VM to the import path, but only on windows 32-bit Windows
ifeq ($(ARCH_DATA_MODEL), 32)
IMPORT_LIST += $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVM_NAME) \
$(LIB_LOCATION)/$(KERNEL_LOCATION)/Xusage.txt
endif
IMPORT_LIST += $(MS_RUNTIME_LIBRARIES:%=$(BINDIR)/%)
# NOTE: These might actually come from BUILDDIR, depends on the settings.
......@@ -119,10 +126,13 @@ IMPORT_LIST += \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME) \
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME)
# Hotspot client is only available on 32-bit builds
# Add .map and .pdb files to the import path for client and kernel VMs.
# These are only available on 32-bit windows builds.
ifeq ($(ARCH_DATA_MODEL), 32)
IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMMAP_NAME) \
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMPDB_NAME)
IMPORT_LIST += $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMMAP_NAME) \
$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMPDB_NAME)
endif
$(LIBDIR)/$(JVMLIB_NAME): $(HOTSPOT_LIB_PATH)/$(JVMLIB_NAME)
......@@ -134,6 +144,10 @@ $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMMAP_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_CLIENT_PATH)/$(JVMMAP_NAME) $@
$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMMAP_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMMAP_NAME) $@
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMMAP_NAME) $@
......@@ -142,6 +156,10 @@ $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMPDB_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_CLIENT_PATH)/$(JVMPDB_NAME) $@
$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMPDB_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMPDB_NAME) $@
$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME):
@$(prep-target)
-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMPDB_NAME) $@
......@@ -195,6 +213,9 @@ endif # PLATFORM
$(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVM_NAME)
$(install-import-file)
$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVM_NAME): $(HOTSPOT_KERNEL_PATH)/$(JVM_NAME)
$(install-file)
$(LIB_LOCATION)/$(LIBJSIG_NAME): $(HOTSPOT_SERVER_PATH)/$(LIBJSIG_NAME)
$(install-import-file)
......@@ -224,6 +245,9 @@ $(LIB_LOCATION)/$(SERVER_LOCATION)/Xusage.txt : $(HOTSPOT_SERVER_PATH)/Xusage.tx
$(LIB_LOCATION)/$(CLIENT_LOCATION)/Xusage.txt : $(HOTSPOT_CLIENT_PATH)/Xusage.txt
$(install-import-file)
$(LIB_LOCATION)/$(KERNEL_LOCATION)/Xusage.txt : $(HOTSPOT_KERNEL_PATH)/Xusage.txt
$(install-file)
ifeq ($(INCLUDE_SA), true)
# The Serviceability Agent is built in the Hotspot workspace.
# It contains two files:
......
......@@ -33,6 +33,12 @@ PRODUCT = jpda
PROGRAM = jdb
include $(BUILDDIR)/common/Defs.gmk
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Java Files to compile are found automatically.
#
......
......@@ -58,7 +58,7 @@ ifdef OPENJDK
else
RENDER_SUBDIR = dcpr
endif
SUBDIRS = jar security javazic misc net audio $(RENDER_SUBDIR) image \
SUBDIRS = jar security javazic misc jkernel net audio $(RENDER_SUBDIR) image \
awt splashscreen $(XAWT_SUBDIR) \
$(HEADLESS_SUBDIR) $(DGA_SUBDIR) \
font jpeg cmm applet rmi beans $(JDBC_SUBDIR) \
......
......@@ -32,6 +32,12 @@ PACKAGE = sun.applet
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Files to compile.
#
......
......@@ -32,6 +32,13 @@ PACKAGE = sun.tools
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Files
#
......
......@@ -54,9 +54,9 @@ Link America/Los_Angeles PST
Link Pacific/Guadalcanal SST
Link Asia/Saigon VST
# The follwong link is required to generate J2SE 1.2.x and 1.3.x
# The follwong link is required to generate JDK 1.2.x and 1.3.x
# compatible zones. In the Olson public source, MET is defined as
# GMT+1:00 with the C-Eur rules. In J2SE, MET is defined as an alias
# GMT+1:00 with the C-Eur rules. In JDK, MET is defined as an alias
# of Asia/Tehran. This line must be removed if a full set of Olson
# zones is generated. Otherwise, MET appears twice in the
# ZoneInfoMappings.IDs table.
......
......@@ -32,6 +32,13 @@ PACKAGE = sun.tools.jconsole
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
JARFILE = $(LIBDIR)/jconsole.jar
OTHER_JAVACFLAGS += -encoding iso8859-1
......
#
# Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
FILES_cpp = \
stdafx.cpp \
kernel.cpp \
DownloadDialog.cpp \
DownloadHelper.cpp \
DownloadHelper.cpp
FILES_rc = kernel.rc
# FILES_export definitions for Win32
FILES_export = \
sun/jkernel/DownloadManager.java \
sun/jkernel/Mutex.java \
sun/jkernel/Bundle.java \
sun/jkernel/BackgroundDownloader.java \
#
# Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
FILES_java = \
$(TARGDIR)sun/jkernel/BackgroundDownloader.java \
$(TARGDIR)sun/jkernel/Bundle.java \
$(TARGDIR)sun/jkernel/ByteArrayToFromHexDigits.java \
$(TARGDIR)sun/jkernel/BundleCheck.java \
$(TARGDIR)sun/jkernel/DownloadManager.java \
$(TARGDIR)sun/jkernel/Mutex.java \
$(TARGDIR)sun/jkernel/StandaloneByteArrayAccess.java \
$(TARGDIR)sun/jkernel/StandaloneMessageDigest.java \
$(TARGDIR)sun/jkernel/StandaloneSHA.java \
FILES_export = \
sun/jkernel/DownloadManager.java \
sun/jkernel/Mutex.java \
sun/jkernel/Bundle.java \
sun/jkernel/BackgroundDownloader.java
#
# Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
BUILDDIR = ../..
PACKAGE = sun.jkernel
LIBRARY = jkernel
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# Use highest optimization level
#
_OPT = $(CC_HIGHEST_OPT)
# This re-directs all the class files to a separate location
CLASSDESTDIR = $(TEMPDIR)/classes
#
# Java source files
#
include FILES_java.gmk
AUTO_FILES_JAVA_DIRS = sun/jkernel
LOCALE_SUFFIXES = $(JDK_LOCALES)
#
# Native source files
#
ifeq ($(ARCH_DATA_MODEL), 32)
ifeq ($(PLATFORM), windows)
include FILES_c_windows.gmk
vpath %.cpp $(PLATFORM_SRC)/native/sun/jkernel
VERSIONINFO_RESOURCE = $(PLATFORM_SRC)/native/sun/jkernel/kernel.rc
LDLIBS += urlmon.lib wininet.lib shlwapi.lib version.lib comctl32.lib gdi32.lib -def:$(PLATFORM_SRC)/native/sun/jkernel/kernel.def
include $(BUILDDIR)/common/Library.gmk
endif
endif
#
# Resources
#
include $(TOPDIR)/make/common/internal/Resources.gmk
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
# If extra compression is going to be available in the deploy build enable
# its use here by defining the JRE-relative pathname of the shared library
ifeq ($(PLATFORM), windows)
ifdef EXTRA_COMP_INSTALL_PATH
CPPFLAGS += -DEXTRA_COMP_INSTALL_PATH=$(EXTRA_COMP_INSTALL_PATH)
endif
endif
......@@ -33,6 +33,13 @@ PRODUCT = sun
OTHER_JAVACFLAGS += -Xlint:serial -Werror
include $(BUILDDIR)/common/Defs.gmk
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Files
#
......
......@@ -32,6 +32,13 @@ PACKAGE = sun.rmi.rmic
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Files
#
......
......@@ -32,6 +32,14 @@ PACKAGE = sun.tools.serialver
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# This program must contain a manifest that defines the execution level
# needed to follow standard Vista User Access Control Guidelines
# This must be set before Program.gmk is included
#
BUILD_MANIFEST=true
#
# Files
#
......
......@@ -1823,10 +1823,18 @@ public class ICC_Profile implements Serializable {
}
if (!f.isFile()) { /* try the directory of built-in profiles */
dir = System.getProperty("java.home") +
File.separatorChar + "lib" + File.separatorChar + "cmm";
fullPath = dir + File.separatorChar + fileName;
dir = System.getProperty("java.home") +
File.separatorChar + "lib" + File.separatorChar + "cmm";
fullPath = dir + File.separatorChar + fileName;
f = new File(fullPath);
if (!f.isFile()) {
//make sure file was installed in the kernel mode
try {
//kernel uses platform independent paths =>
// should not use platform separator char
sun.jkernel.DownloadManager.downloadFile("lib/cmm/"+fileName);
} catch (IOException ioe) {}
}
}
if (f.isFile()) {
......
......@@ -58,6 +58,7 @@ import sun.misc.URLClassPath;
import sun.misc.VM;
import sun.reflect.Reflection;
import sun.security.util.SecurityConstants;
import sun.jkernel.DownloadManager;
/**
* A class loader is an object that is responsible for loading classes. The
......@@ -1280,6 +1281,21 @@ public abstract class ClassLoader {
* Find resources from the VM's built-in classloader.
*/
private static URL getBootstrapResource(String name) {
try {
// If this is a known JRE resource, ensure that its bundle is
// downloaded. If it isn't known, we just ignore the download
// failure and check to see if we can find the resource anyway
// (which is possible if the boot class path has been modified).
if (sun.misc.VM.isBootedKernelVM()) {
sun.jkernel.DownloadManager.getBootClassPathEntryForResource(
name);
}
} catch (NoClassDefFoundError e) {
// This happens while Java itself is being compiled; DownloadManager
// isn't accessible when this code is first invoked. It isn't an
// issue, as if we can't find DownloadManager, we can safely assume
// that additional code is not available for download.
}
URLClassPath ucp = getBootstrapClassPath();
Resource res = ucp.getResource(name);
return res != null ? res.getURL() : null;
......@@ -1305,13 +1321,9 @@ public abstract class ClassLoader {
// Returns the URLClassPath that is used for finding system resources.
static URLClassPath getBootstrapClassPath() {
if (bootstrapClassPath == null) {
bootstrapClassPath = sun.misc.Launcher.getBootstrapClassPath();
}
return bootstrapClassPath;
return sun.misc.Launcher.getBootstrapClassPath();
}
private static URLClassPath bootstrapClassPath;
/**
* Returns an input stream for reading the specified resource.
......@@ -1800,6 +1812,24 @@ public abstract class ClassLoader {
// Invoked in the java.lang.Runtime class to implement load and loadLibrary.
static void loadLibrary(Class fromClass, String name,
boolean isAbsolute) {
try {
if (VM.isBootedKernelVM() && !DownloadManager.isJREComplete() &&
!DownloadManager.isCurrentThreadDownloading()) {
DownloadManager.downloadFile("bin/" +
System.mapLibraryName(name));
// it doesn't matter if the downloadFile call returns false --
// it probably just means that this is a user library, as
// opposed to a JRE library
}
} catch (IOException e) {
throw new UnsatisfiedLinkError("Error downloading library " +
name + ": " + e);
} catch (NoClassDefFoundError e) {
// This happens while Java itself is being compiled; DownloadManager
// isn't accessible when this code is first invoked. It isn't an
// issue, as if we can't find DownloadManager, we can safely assume
// that additional code is not available for download.
}
ClassLoader loader =
(fromClass == null) ? null : fromClass.getClassLoader();
if (sys_paths == null) {
......
......@@ -1106,12 +1106,22 @@ public final class System {
initProperties(props);
sun.misc.Version.init();
// Workaround until DownloadManager initialization is revisited.
// Make JavaLangAccess available early enough for internal
// Shutdown hooks to be registered
setJavaLangAccess();
// Gets and removes system properties that configure the Integer
// cache used to support the object identity semantics of autoboxing.
// At this time, the size of the cache may be controlled by the
// -XX:AutoBoxCacheMax=<size> option.
// vm option -XX:AutoBoxCacheMax=<size>.
Integer.getAndRemoveCacheProperties();
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary("zip");
FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
......@@ -1119,10 +1129,6 @@ public final class System {
setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
// Load the zip library now in order to keep java.util.zip.ZipFile
// from trying to use itself to load this library later.
loadLibrary("zip");
// Setup Java signal handlers for HUP, TERM, and INT (where available).
Terminator.setup();
......@@ -1152,7 +1158,9 @@ public final class System {
// way as other threads; we must do it ourselves here.
Thread current = Thread.currentThread();
current.getThreadGroup().add(current);
}
private static void setJavaLangAccess() {
// Allow privileged classes outside of java.lang
sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
public sun.reflect.ConstantPool getConstantPool(Class klass) {
......
......@@ -109,7 +109,15 @@ class ZipEntry implements ZipConstants, Cloneable {
* @see #getTime()
*/
public void setTime(long time) {
this.time = javaToDosTime(time);
// fix for bug 6625963: we bypass time calculations while Kernel is
// downloading bundles, since they aren't necessary and would cause
// the Kernel core to depend upon the (very large) time zone data
if (sun.misc.VM.isBootedKernelVM() &&
sun.jkernel.DownloadManager.isCurrentThreadDownloading()) {
this.time = sun.jkernel.DownloadManager.KERNEL_STATIC_MODTIME;
} else {
this.time = javaToDosTime(time);
}
}
/**
......@@ -245,10 +253,14 @@ class ZipEntry implements ZipConstants, Cloneable {
* the first 0xFFFF bytes are output to the ZIP file entry.
*
* @param comment the comment string
*
* @exception IllegalArgumentException if the length of the specified
* comment string is greater than 0xFFFF bytes
* @see #getComment()
*/
public void setComment(String comment) {
if (comment != null && comment.length() > 0xffff) {
throw new IllegalArgumentException("invalid entry comment length");
}
this.comment = comment;
}
......
......@@ -69,6 +69,7 @@ public class AppletClassLoader extends URLClassLoader {
private final Object grabReleaseSynchronizer = new Object();
private boolean codebaseLookup = true;
private volatile boolean allowRecursiveDirectoryRead = true;
/*
* Creates a new AppletClassLoader for the specified base URL.
......@@ -81,6 +82,11 @@ public class AppletClassLoader extends URLClassLoader {
acc = AccessController.getContext();
}
public void disableRecursiveDirectoryRead() {
allowRecursiveDirectoryRead = false;
}
/**
* Set the codebase lookup flag.
*/
......@@ -188,7 +194,21 @@ public class AppletClassLoader extends URLClassLoader {
byte[] b = (byte[]) AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run() throws IOException {
return getBytes(new URL(base, path));
try {
URL finalURL = new URL(base, path);
// Make sure the codebase won't be modified
if (base.getProtocol().equals(finalURL.getProtocol()) &&
base.getHost().equals(finalURL.getHost()) &&
base.getPort() == finalURL.getPort()) {
return getBytes(finalURL);
}
else {
return null;
}
} catch (Exception e) {
return null;
}
}
}, acc);
......@@ -243,51 +263,48 @@ public class AppletClassLoader extends URLClassLoader {
}
if (path != null) {
final String rawPath = path;
if (!path.endsWith(File.separator)) {
int endIndex = path.lastIndexOf(File.separatorChar);
if (endIndex != -1) {
path = path.substring(0, endIndex+1) + "-";
path = path.substring(0, endIndex + 1) + "-";
perms.add(new FilePermission(path,
SecurityConstants.FILE_READ_ACTION));
}
}
perms.add(new SocketPermission("localhost",
SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
String host = InetAddress.getLocalHost().getHostName();
perms.add(new SocketPermission(host,
SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
} catch (UnknownHostException uhe) {
}
return null;
}
});
final File f = new File(rawPath);
final boolean isDirectory = f.isDirectory();
// grant codebase recursive read permission
// this should only be granted to non-UNC file URL codebase and
// the codesource path must either be a directory, or a file
// that ends with .jar or .zip
if (allowRecursiveDirectoryRead && (isDirectory ||
rawPath.toLowerCase().endsWith(".jar") ||
rawPath.toLowerCase().endsWith(".zip"))) {
Permission bperm;
try {
bperm = base.openConnection().getPermission();
} catch (java.io.IOException ioe) {
bperm = null;
}
if (bperm instanceof FilePermission) {
String bpath = bperm.getName();
if (bpath.endsWith(File.separator)) {
bpath += "-";
try {
bperm = base.openConnection().getPermission();
} catch (java.io.IOException ioe) {
bperm = null;
}
perms.add(new FilePermission(bpath,
SecurityConstants.FILE_READ_ACTION));
} else if ((bperm == null) && (base.getProtocol().equals("file"))) {
String bpath = base.getFile().replace('/', File.separatorChar);
bpath = ParseUtil.decode(bpath);
if (bpath.endsWith(File.separator)) {
bpath += "-";
if (bperm instanceof FilePermission) {
String bpath = bperm.getName();
if (bpath.endsWith(File.separator)) {
bpath += "-";
}
perms.add(new FilePermission(bpath,
SecurityConstants.FILE_READ_ACTION));
} else if ((bperm == null) && (base.getProtocol().equals("file"))) {
String bpath = base.getFile().replace('/', File.separatorChar);
bpath = ParseUtil.decode(bpath);
if (bpath.endsWith(File.separator)) {
bpath += "-";
}
perms.add(new FilePermission(bpath, SecurityConstants.FILE_READ_ACTION));
}
perms.add(new FilePermission(bpath, SecurityConstants.FILE_READ_ACTION));
}
}
}
return perms;
}
......@@ -702,7 +719,7 @@ public class AppletClassLoader extends URLClassLoader {
* Grab this AppletClassLoader and its ThreadGroup/AppContext, so they
* won't be destroyed.
*/
void grab() {
public void grab() {
synchronized(grabReleaseSynchronizer) {
usageCount++;
}
......@@ -740,11 +757,7 @@ public class AppletClassLoader extends URLClassLoader {
--usageCount;
} else {
synchronized(threadGroupSynchronizer) {
// Store app context in temp variable
tempAppContext = appContext;
usageCount = 0;
appContext = null;
threadGroup = null;
tempAppContext = resetAppContext();
}
}
}
......@@ -758,6 +771,29 @@ public class AppletClassLoader extends URLClassLoader {
}
}
/*
* reset classloader's AppContext and ThreadGroup
* This method is for subclass PluginClassLoader to
* reset superclass's AppContext and ThreadGroup but do
* not dispose the AppContext. PluginClassLoader does not
* use UsageCount to decide whether to dispose AppContext
*
* @return previous AppContext
*/
protected AppContext resetAppContext() {
AppContext tempAppContext = null;
synchronized(threadGroupSynchronizer) {
// Store app context in temp variable
tempAppContext = appContext;
usageCount = 0;
appContext = null;
threadGroup = null;
}
return tempAppContext;
}
// Hash map to store applet compatibility info
private HashMap jdk11AppletInfo = new HashMap();
private HashMap jdk12AppletInfo = new HashMap();
......
......@@ -80,7 +80,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
/**
* The classloader for the applet.
*/
AppletClassLoader loader;
protected AppletClassLoader loader;
/* applet event ids */
public final static int APPLET_DISPOSE = 0;
......@@ -116,7 +116,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
/**
* The thread for the applet.
*/
Thread handler;
protected Thread handler;
/**
......
/*
* Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.jkernel;
import java.io.*;
/**
* Invoked by DownloadManager to begin (in a new JRE) the process of downloading
* all remaining JRE components in the background. A mutex is used to ensure
* that only one BackgroundDownloader can be active at a time.
*
*/
public class BackgroundDownloader {
public static final String BACKGROUND_DOWNLOAD_PROPERTY = "kernel.background.download";
// relative to the bundle directory
public static final String PID_PATH = "tmp" + File.separator + "background.pid";
// Time to wait before beginning to download components. Gives the JRE
// which spawned this one a chance to get its downloads going.
private static final int WAIT_TIME = 10000;
private static Mutex backgroundMutex;
static synchronized Mutex getBackgroundMutex() {
if (backgroundMutex == null)
backgroundMutex = Mutex.create(DownloadManager.MUTEX_PREFIX + "background");
return backgroundMutex;
}
private static void doBackgroundDownloads() {
if (DownloadManager.isJREComplete())
return;
if (getBackgroundMutex().acquire(0)) { // give up and exit immediately if we can't acquire mutex
try {
writePid();
Thread.sleep(WAIT_TIME);
DownloadManager.doBackgroundDownloads(false);
DownloadManager.performCompletionIfNeeded();
}
catch (InterruptedException e) {
}
finally {
getBackgroundMutex().release();
}
}
else {
System.err.println("Unable to acquire background download mutex.");
System.exit(1);
}
}
/**
* Writes the current process ID to a file, so that the uninstaller can
* find and kill this process if needed.
*/
private static void writePid() {
try {
File pid = new File(DownloadManager.getBundlePath(), PID_PATH);
pid.getParentFile().mkdirs();
PrintStream out = new PrintStream(new FileOutputStream(pid));
pid.deleteOnExit();
out.println(DownloadManager.getCurrentProcessId());
out.close();
}
catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
}
/**
* Reads from an InputStream until exhausted, writing all data to the
* specified OutputStream.
*/
private static void send(InputStream in, OutputStream out)
throws IOException {
int c;
byte[] buffer = new byte[2048];
while ((c = in.read(buffer)) > 0)
out.write(buffer, 0, c);
}
/*
* Returns the value of the BACKGROUND_DOWNLOAD_PROPERTY.
* Checks if system property has been set first
* then checks if registry key to disable background download
* has been set.
*/
public static boolean getBackgroundDownloadProperty(){
/*
* Check registry key value
*/
boolean bgDownloadEnabled = getBackgroundDownloadKey();
/*
* Check system property - it should override the registry
* key value.
*/
if (System.getProperty(BACKGROUND_DOWNLOAD_PROPERTY) != null){
bgDownloadEnabled = Boolean.valueOf(
System.getProperty(BACKGROUND_DOWNLOAD_PROPERTY));
}
return bgDownloadEnabled;
}
// This method is to retrieve the value of registry key
// that disables background download.
static native boolean getBackgroundDownloadKey();
static void startBackgroundDownloads() {
if (!getBackgroundDownloadProperty()){
// If getBackgroundDownloadProperty() returns false
// we're doing the downloads from this VM; we don't want to
// spawn another one
return;
}
// if System.err isn't initialized yet, it means the charsets aren't
// available yet and we're going to run into trouble down below. Wait
// until it's ready.
while (System.err == null) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
return;
}
}
try {
String args = "-D" + BACKGROUND_DOWNLOAD_PROPERTY + "=false -Xmx256m";
String backgroundDownloadURL = DownloadManager.getBaseDownloadURL();
// only set KERNEL_DOWNLOAD_URL_PROPERTY if we override
// the default download url
if (backgroundDownloadURL != null &&
backgroundDownloadURL.equals(
DownloadManager.DEFAULT_DOWNLOAD_URL) == false) {
args += " -D" + DownloadManager.KERNEL_DOWNLOAD_URL_PROPERTY +
"=" + backgroundDownloadURL;
};
args += " sun.jkernel.BackgroundDownloader";
final Process jvm = Runtime.getRuntime().exec("\"" + new File(System.getProperty("java.home"), "bin" +
File.separator + "java.exe") + "\" " + args);
Thread outputReader = new Thread("kernelOutputReader") {
public void run() {
try {
InputStream in = jvm.getInputStream();
send(in, new PrintStream(new ByteArrayOutputStream()));
}
catch (IOException e) {
e.printStackTrace();
}
}
};
outputReader.setDaemon(true);
outputReader.start();
Thread errorReader = new Thread("kernelErrorReader") {
public void run() {
try {
InputStream in = jvm.getErrorStream();
send(in, new PrintStream(new ByteArrayOutputStream()));
}
catch (IOException e) {
e.printStackTrace();
}
}
};
errorReader.setDaemon(true);
errorReader.start();
}
catch (Exception e) {
e.printStackTrace();
// TODO: error handling
}
}
public static void main(String[] arg) {
doBackgroundDownloads();
}
}
此差异已折叠。
/*
* Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
*
* The Java Kernel Bundle security check.
*
* This class is responsible for detail of creating, storing, dispensing, and
* updating bundle security checks and security checks for all the files
* extracted from a bundle. Security checks are cryptographic
* hashcodes that make it impractical to counterfeit a file. The security
* check algorithm is defined by peer class StandaloneMessageDigest. The
* cryptographic
* hashcodes are held in instances of this class as byte arrays and externally
* as hexidecimal string values for Bundle name Property keys. The properties
* are a resource in the Java Kernel core JRE rt.jar and accessed after a
* real or simulated bundle download by peer classes DownloadManager and
* Bundle. Build-time deployment class SplitJRE uses this class to create file
* security checks directly and via a special execution of DownloadManager.
* The main method of this class can be used to create a
* new set of security codes and updated properties for a given JRE path
* and set of bundle names (CWD assume to contain bundle files as <name>.zip).
*
* This is a Sun internal class defined by the Sun implementation and
* intended for JRE/JDK release deployment.
*
* @see sun.jkernel.DownloadManager
* @see sun.jkernel.Bundle
* @see sun.jkernel.StandaloneSHA
* @see sun.jkernel.ByteArrayToFromHexDigits
* See also deploy/src/kernel/share/classes/sun/kernel/SplitJRE.java
*/
package sun.jkernel;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class BundleCheck {
/* File buffer size */
private static final int DIGEST_STREAM_BUFFER_SIZE = 2048;
/* The bundle filename suffix */
private static final String BUNDLE_SUFFIX = ".zip";
/* Mutable static state. */
/* Properties (Bundle name/check hex String pairs) for a set of Bundles.
Guarded by this class' object. */
private static volatile Properties properties;
/* Mutable instance state. */
/**
* The bytes of the check value. Guarded by the bundle Mutex (in
* sun.jkernel.DownloadManager) or the fact that sun.kernel.SplitJRE
* and/or DownloadManager with "-download all" runs a single thread.
*/
private byte[] checkBytes;
/* Prevent instantiation by default constructor */
private BundleCheck(){}
/**
* Store the bundle check values as properties to the path specified.
* Only invoked by SplitJRE.
*/
public static void storeProperties(String fullPath) {
try {
File f = new File(fullPath);
f.getParentFile().mkdirs();
OutputStream out = new FileOutputStream(f);
properties.store(out, null);
out.close();
} catch (Exception e) {
throw new RuntimeException(
"BundleCheck: storing properties threw: " + e);
}
}
/**
* Fetch the check value properties as a DownloadManager resource.
*/
private static void loadProperties() {
properties = new Properties();
try {
InputStream in = new BufferedInputStream(
DownloadManager.class.getResourceAsStream(
DownloadManager.CHECK_VALUES_FILE));
if (in == null)
throw new RuntimeException("BundleCheck: unable to locate " +
DownloadManager.CHECK_VALUES_FILE + " as resource");
properties.load(in);
in.close();
} catch (Exception e) {
throw new RuntimeException("BundleCheck: loadProperties threw " +
e);
}
}
/* Get the check value Properties object */
private synchronized static Properties getProperties() {
if (properties == null) {
// If this fails it means addProperty has been used inappropriately
loadProperties();
}
return properties;
}
/* Reset the properties with an empty Properties object */
public static void resetProperties() {
properties = null;
}
/* The BundleCheck expressed as a String */
public String toString() {
return ByteArrayToFromHexDigits.bytesToHexString(checkBytes);
}
/* Add the given BundleCheck as a property to bundleCheckvalueProperties */
private void addProperty(String name) {
// When first called by SplitJRE just start with empty object
// rather than allowing a load to happen, as it does at install time.
if (properties == null) {
properties = new Properties();
}
getProperties().put(name, toString());
}
/* private ctor for creating/initializing a BundleCheck */
private BundleCheck(byte[] checkBytes) {
this.checkBytes = checkBytes;
}
/* private ctor for creating a BundleCheck with a given name and known
Property value. */
private BundleCheck(String name) {
String hexString = getProperties().getProperty(name);
if (hexString == null) {
throw new RuntimeException(
"BundleCheck: no check property for bundle: " + name);
}
this.checkBytes = ByteArrayToFromHexDigits.hexStringToBytes(hexString);
}
/* Make a BundleCheck from the contents of the given file or a Bundle
name. Save the new object's value as a property if saveProperty is
true. Behavior is only defined for name or file being null, but not
both, and for saveProperty to be true only when both name and file
are not null.
Any IO or other exception implies an unexpected and fatal internal
error and results in a RuntimeException. */
private static BundleCheck getInstance(String name,
File file, boolean saveProperty) {
if (file == null ) {
return new BundleCheck(name);
} else {
StandaloneMessageDigest checkDigest = null;
try {
FileInputStream checkFileStream = new FileInputStream(file);
checkDigest = StandaloneMessageDigest.getInstance("SHA-1");
// Compute a check code across all of the file bytes.
// NOTE that every time a bundle is created, even from
// the "same bits", it may be different wrt to the security
// code because of slight variations build to build. For
// example, the JVM build normally contains an
// auto-incrementing build number, built archives might have
// timestamps, etc.
int readCount;
byte[] messageStreamBuff =
new byte[DIGEST_STREAM_BUFFER_SIZE];
do {
readCount = checkFileStream.read(messageStreamBuff);
if (readCount > 0) {
checkDigest.update(messageStreamBuff,0,readCount);
}
} while (readCount != -1);
checkFileStream.close();
} catch (Exception e) {
throw new RuntimeException(
"BundleCheck.addProperty() caught: " + e);
}
BundleCheck bc = new BundleCheck(checkDigest.digest());
if (saveProperty) {
bc.addProperty(name);
}
return bc;
}
}
/* Create a BundleCheck from the given file */
public static BundleCheck getInstance(File file) {
return getInstance(null, file, false);
}
/* Create a BundleCheck from the given bundle name */
static BundleCheck getInstance(String name) {
return getInstance(name, null, false);
}
/* Create a BundleCheck from the given bundle name and file and
use it to make and save a security check Property value. */
public static void addProperty(String name, File file) {
getInstance(name, file, true);
}
/* Create a bundlecheck from the given bundle name and file and
add a Property value for it. */
static void add(String name, File file) {
getInstance(name, file, true).addProperty(name);
}
/* Compare two BundkCheck instances for equal check values */
boolean equals(BundleCheck b) {
if ((checkBytes == null) || (b.checkBytes == null)) {
return false;
}
if (checkBytes.length != b.checkBytes.length) {
return false;
}
for (int i = 0; i < checkBytes.length; i++) {
if (checkBytes[i] != b.checkBytes[i]) {
if (DownloadManager.debug) {
System.out.println(
"BundleCheck.equals mismatch between this: " +
toString() + " and param: " + b.toString());
}
return false;
}
}
return true;
}
/* After SplitJRE is used to restructure the JRE into a "core JRE" and
a set of Java Kernel "bundles", if extra compression is available
the bundles are extracted and rearchived with zero compression by
deploy build make steps. The newly compressed bundle names are then
passed to this main with the path of the kernel core JRE to have new
bundle security check values computed and the corresponding properties
updated in rt.jar. If extra compression isn't available then this main is
never used and the default jar/zip bundle compression and security
codes created by SplitJRE are left in place and ready to use. */
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Usage: java BundleCheck <jre path> " +
"<bundle 1 name> ... <bundle N name>");
return;
}
// Make a security check code for each bundle file
for (int arg = 1; arg < args.length; arg++) {
BundleCheck.addProperty(args[arg],
new File(args[arg] + BUNDLE_SUFFIX));
}
// Store the new check code properties below the current directory
BundleCheck.storeProperties(DownloadManager.CHECK_VALUES_DIR);
// Now swap the new properties file into the core rt.jar
try {
int status = Runtime.getRuntime().exec(
"jar uf " + args[0] + "\\lib\\rt.jar " +
DownloadManager.CHECK_VALUES_DIR).waitFor();
if (status != 0) {
System.err.println(
"BundleCheck: exec of jar uf gave nonzero status");
return;
}
} catch (Exception e) {
System.err.println("BundleCheck: exec of jar uf threw: " + e);
return;
}
} // main
}
/*
* Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.jkernel;
/**
* TODO: The JRE and deploy build code (SplitJRE) can be made a bit smarter
* then cryto hashcode byte arrays can be used directly, eliminating the need
* for this class altogether. So just leave this alone until it can be removed.
* TODO: Change "Digits" to "String" for uniformity and more intuitive names.
* A lightweight class to provide convert between hex digits and
* <code>byte[]</code>.
*<p>
* TODO: Try to get this built without the -source 1.3 -target -1.3 options,
* which prevent use of java.text.Format, assuming this wouldn't bloat the
* JK rt.jar. Also, there still might be equivalent code hiding in the JDK
* already, but preliminary searches havn't found it.
*/
public final class ByteArrayToFromHexDigits {
private static final char [] chars = new char[]
{'0','1','2','3','4','5','6','7','8','9', 'A','B','C','D','E','F'};
private static final boolean debug = false;
/**
* Converts the <code>byte[] b</code> into a <code>String</code> of
* hex digits representing the integer values of all the bytes.
*
* @param b byte array to be converted
* @return String representing <code>b</code> in hexadecimal
* @throws IllegalArgumentException if <code>b</code> is null or zero length
*/
public static String bytesToHexString(byte[] b) {
if (debug ) {
System.out.print("I: ");
for(int i=0;i<b.length;i++) {
System.out.format("%02X",b[i]);
}
System.out.println();
}
if ((b == null) || (b.length == 0)) {
throw new IllegalArgumentException("argument null or zero length");
}
StringBuffer buff = new StringBuffer(b.length * 2);
for (int i = 0; i < b.length; i++ ) {
buff.insert(i*2,chars[(b[i] >> 4) & 0xf]);
buff.insert(i*2+1,chars[b[i] & 0xf]);
}
if (debug ) {
System.out.println("O: " + buff.toString());
}
return buff.toString();
}
// Convert one hex character to a 4 bit byte value
private static byte hexCharToByte(char c) throws IllegalArgumentException {
if ((c < '0') ||
( ((c < 'A') && (c > 'F')) && ((c < 'a') && (c > 'f'))) ) {
throw new IllegalArgumentException("not a hex digit");
}
if (c > '9') {
if (c > 'F') {
return (byte) ((c - 'a' + 10) & 0xf);
} else {
return (byte) ((c - 'A' + 10) & 0xf);
}
} else {
return (byte) ((c - '0') & 0xf);
}
}
/**
* Converts the <code>String d</code> assumed to contain a sequence
* of hexadecimal digit characters into a <code>byte[]</code>.
*
* @param d String to be converted
* @return byte array representing the hex string
* @throws IllegalArgumentException if <code>d</code> is odd length,
* contains a character outside the ranges of 0-9, a-f, and A-F,
* or is zero length or null
*/
public static byte[] hexStringToBytes(String d) throws IllegalArgumentException {
if (d == null) {
throw new IllegalArgumentException(
"parameter cannot be null");
}
if (d.length() == 0) {
throw new IllegalArgumentException(
"parameter cannot be zero length");
}
if ((d.length() & 1) != 0) {
throw new IllegalArgumentException(
"odd length string");
}
byte[] b = new byte[d.length() / 2];
// TODO Might be code in the JK initial bundle to do this better (i.e.
// method that tests for a hex char?)
for (int i=0;i<d.length();i+=2) {
b[i/2] = (byte) (( (byte) (hexCharToByte(d.charAt(i))) << 4) +
(byte) hexCharToByte(d.charAt(i+1)));
}
return b;
}
}
/*
* Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.jkernel;
import java.io.FilterOutputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import sun.jkernel.StandaloneMessageDigest;
/*
* This class provides the main functionality of <code>FilterOutputStream</code>,
* and accumulates a check value as bytes are written to
* it. The check value is available by method <code>getCheckValue</code>.
*<p>
* Operations on the public <code>out</code> field of this class should be
* avoided to prevent an invalid check code being generated.
*
* TODO: The javadoc HTML hasn't been generated and eyeballed for yet.
* TODO: There is a javadoc trick to cause the parent class javadoc to be
* automagically used: try to take advantage of this.
* TODO: Add javadoc links instead of <code>API</code> where it would be useful.
* TODO: Go visit the Docs style guide again and get the periods right and
* consistent for all sun.* classes.
* @author Pete Soper
* @see java.lang.FilterOutputStream
* @see getCheckValue
*/
public class DigestOutputStream extends FilterOutputStream {
private static final String DEFAULT_ALGORITHM = "SHA-1";
private final boolean debug = false;
private StandaloneMessageDigest smd = null;
private void initDigest(String algorithm) throws NoSuchAlgorithmException {
smd = StandaloneMessageDigest.getInstance(algorithm);
}
// The underlying stream.
protected volatile OutputStream out;
/**
* Creates a <code>DigestOutputStream</code> with stream <code>s</code>
* to be checked with using <code>algorithm</code>.
* <p>
* If <code>algorithm</code> is not supported then
* <code>NoSuchAlgorithm</code> is thrown.
* <p>
* See {linkplain sun.security.provider.StandaloneMessageDigest} for an
* implementation-specific list of supported algorithms.
*
* @throws NoSuchAlgorithm if <code>algorithm</code> is not supported
* @see sun.security.provider.StandaloneMessageDigest
*/
/**
* Creates an output stream filter built on top of
* underlying output stream <code>out</code> for checking with
* algorithm <code>algorithm</code>.
* <p>
* If <code>algorithm</code> is not supported then
* <code>NoSuchAlgorithm</code> is thrown.
* <p>
* See {linkplain sun.security.provider.StandaloneMessageDigest} for an
* implementation-specific list of supported algorithms.
*
* @param out the underlying output stream to be assigned to
* the field <tt>this.out</tt> for later use, or
* <code>null</code> if this instance is to be
* created without an underlying stream.
* @param algorithm the check algorithm to use.
* @throws NoSuchAlgorithm if <code>algorithm</code> is not supported
* @see sun.security.provider.StandaloneMessageDigest
* @see DigestInputStream(InputStream, String)
*/
public DigestOutputStream(OutputStream out, String algorithm) throws NoSuchAlgorithmException {
super(out);
initDigest(algorithm);
this.out = out;
}
/**
* Creates an output stream filter built on top of
* underlying output stream <code>out</code> for the default checking
* algorithm.
* <p>
* This implemention provides "SHA-1" as the default checking algorithm.
*
* @param out the underlying output stream to be assigned to
* the field <tt>this.out</tt> for later use, or
* <code>null</code> if this instance is to be
* created without an underlying stream.
* @see DigestInputStream(InputStream)
*/
public DigestOutputStream(OutputStream out) {
super(out);
try {
initDigest(DEFAULT_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
// Impossible to get here, but stranger things have happened...
throw new RuntimeException("DigestOutputStream() unknown algorithm");
}
// superstition from a test failure this.out = out;
}
/**
* Writes a byte specified by <code>v</code> to this stream
* and updates the check information.
*
*
* @param v the byte to be written.
* @throws IOException if an I/O error occurs.
*/
public void write(int v) throws IOException {
super.write(v);
// TODO Could create this array once
byte[] b = new byte[] {(byte) (v & 0xff)};
smd.update(b,0,1);
}
/**
* Writes the bytes in array <code>data</code>
* to this stream and updates the check information.
*
* @param data the data.
* @throws IOException if an I/O error occurs.
* @throws NullPointerException if <code>data</code> is <code>null</code>
*/
public void write(byte[] data) throws IOException {
write(data,0,data.length);
}
/**
* Writes a sub array as a sequence of bytes to this output stream and
* updates the check information.
* @param data the data to be written
* @param ofs the start offset in the data
* @param len the number of bytes that are written
* @throws IOException If an I/O error has occurred.
* @throws NullPointerException if <code>data</code> is <code>null</code>
* @throws IndexOutOfBoundsException If <code>ofs</code> is negative,
* <code>len</code> is negative, or <code>len</code> is greater than
* <code>b.length - ofs</code>
*/
public void write(byte[] data, int ofs, int len) throws IOException {
if (debug) {
System.out.print("DigestOutputStream.write: ");
for (int i=ofs; i<(len - ofs); i++) {
System.out.format("%02X",data[i]);
}
System.out.println();
}
if (data == null) {
throw new NullPointerException("null array in DigestOutputStream.write");
} else if (ofs < 0 || len < 0 || len > data.length - ofs) {
throw new IndexOutOfBoundsException();
}
//super.write(data,ofs,len);
// WATCH OUT: FilterOutputStream does a byte at a time write(byte)
// TODO: Will this work all the time, or is there another caveat
// to publish
out.write(data,ofs,len);
if (debug) {
System.out.println("DigestOutputStream.write before");
}
smd.update(data,ofs,len);
if (debug) {
System.out.println("DigestOutputStream.write after");
}
}
/**
* Closes this file output stream and releases any system resources
* associated with this stream and makes the check value for the stream
* available via <code>getCheckValue</code>. This file output stream may
* no longer be used for writing bytes.
*
* @throws IOException if an I/O error occurs.
* @see getCheckValue
*/
public void close() throws IOException {
super.close();
}
/**
* Return the check value computed for the stream and reset the state of
* check value generation.
*
* @return the check value bytes
*/
public byte[] getCheckValue() {
byte[] b = smd.digest();
if (debug) {
System.out.print("DigestOutputStream.getCheckValue: ");
for (int i=0; i<b.length; i++) {
System.out.format("%02X",b[i]);
}
System.out.println();
}
smd.reset();
return b;
}
/**
* Flushes this output stream.
*
* @throws IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#flush()
*/
public void flush() throws IOException {
super.flush();
}
/**
* Compares two digests for equality. Does a simple byte compare.
*
* @param digesta one of the digests to compare.
*
* @param digestb the other digest to compare.
*
* @return true if the digests are equal, false otherwise.
*/
// public static boolean isEqual(byte digesta[], byte digestb[]) {
// return StandaloneMessageDigest.isEqual(digesta, digestb);
// }
}
此差异已折叠。
/*
* Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.jkernel;
/**
* Thrown to indicate that Java Kernel is unable to install a required bundle
* and the JRE is therefore not adhering to specifications.
*/
public class KernelError extends VirtualMachineError {
/**
* Constructs a <code>KernelError</code> with no detail message.
*/
public KernelError() {
super();
}
/**
* Constructs a <code>KernelError</code> with the specified
* detail message.
*
* @param s the detail message.
*/
public KernelError(String s) {
super(s);
}
}
/*
* Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.jkernel;
/**
* A mutex which works even between different processes. Currently implemented
* only on Win32.
*
*@author Ethan Nicholas
*/
public class Mutex {
static {
try {
System.loadLibrary("jkernel");
}
catch (Exception e) {
throw new Error(e);
}
}
private String uniqueId;
private long handle;
public static Mutex create(String uniqueId) {
return new Mutex(uniqueId);
}
private Mutex(String uniqueId) {
this.uniqueId = uniqueId;
this.handle = createNativeMutex(uniqueId);
}
private static native long createNativeMutex(String uniqueId);
public native void acquire();
public native boolean acquire(int timeout);
public native void release();
public native void destroyNativeMutex();
public void dispose() {
destroyNativeMutex();
handle = 0;
}
public void finalize() {
dispose();
}
public String toString() {
return "Mutex[" + uniqueId + "]";
}
}
/*
* Copyright 2008 - 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This is a pure subset of package-private class
* sun.security.provider.ByteArrayAccess. The subset consists of only the simple
* shift and boolean operations needed for the one current client of this
* class (sun.jkernel.StandaloneSHA) and omits optimization code and comments
* not relevant to the subset. No semantic changes have been made.
* A few long lines were broken to conform to JDK coding style.
* Pete Soper, August, 2007.
*/
package sun.jkernel;
/**
* Methods for converting between byte[] and int[]/long[].
*
* @since 1.6
* @version 1.1, 05/26/06
* @author Andreas Sterbenz
*/
final class StandaloneByteArrayAccess {
private StandaloneByteArrayAccess() {
// empty
}
/**
* byte[] to int[] conversion, little endian byte order.
*/
static void b2iLittle(byte[] in, int inOfs, int[] out, int outOfs,
int len) {
len += inOfs;
while (inOfs < len) {
out[outOfs++] = ((in[inOfs ] & 0xff) )
| ((in[inOfs + 1] & 0xff) << 8)
| ((in[inOfs + 2] & 0xff) << 16)
| ((in[inOfs + 3] ) << 24);
inOfs += 4;
}
}
/**
* int[] to byte[] conversion, little endian byte order.
*/
static void i2bLittle(int[] in, int inOfs, byte[] out, int outOfs,
int len) {
len += outOfs;
while (outOfs < len) {
int i = in[inOfs++];
out[outOfs++] = (byte)(i );
out[outOfs++] = (byte)(i >> 8);
out[outOfs++] = (byte)(i >> 16);
out[outOfs++] = (byte)(i >> 24);
}
}
/**
* byte[] to int[] conversion, big endian byte order.
*/
static void b2iBig(byte[] in, int inOfs, int[] out, int outOfs, int len) {
len += inOfs;
while (inOfs < len) {
out[outOfs++] = ((in[inOfs + 3] & 0xff) )
| ((in[inOfs + 2] & 0xff) << 8)
| ((in[inOfs + 1] & 0xff) << 16)
| ((in[inOfs ] ) << 24);
inOfs += 4;
}
}
/**
* int[] to byte[] conversion, big endian byte order.
*/
static void i2bBig(int[] in, int inOfs, byte[] out, int outOfs, int len) {
len += outOfs;
while (outOfs < len) {
int i = in[inOfs++];
out[outOfs++] = (byte)(i >> 24);
out[outOfs++] = (byte)(i >> 16);
out[outOfs++] = (byte)(i >> 8);
out[outOfs++] = (byte)(i );
}
}
// Store one 32-bit value into out[outOfs..outOfs+3] in big endian order.
static void i2bBig4(int val, byte[] out, int outOfs) {
out[outOfs ] = (byte)(val >> 24);
out[outOfs + 1] = (byte)(val >> 16);
out[outOfs + 2] = (byte)(val >> 8);
out[outOfs + 3] = (byte)(val );
}
/**
* byte[] to long[] conversion, big endian byte order.
*/
static void b2lBig(byte[] in, int inOfs, long[] out, int outOfs, int len) {
len += inOfs;
while (inOfs < len) {
int i1 = ((in[inOfs + 3] & 0xff) )
| ((in[inOfs + 2] & 0xff) << 8)
| ((in[inOfs + 1] & 0xff) << 16)
| ((in[inOfs ] ) << 24);
inOfs += 4;
int i2 = ((in[inOfs + 3] & 0xff) )
| ((in[inOfs + 2] & 0xff) << 8)
| ((in[inOfs + 1] & 0xff) << 16)
| ((in[inOfs ] ) << 24);
out[outOfs++] = ((long)i1 << 32) | (i2 & 0xffffffffL);
inOfs += 4;
}
}
/**
* long[] to byte[] conversion
*/
static void l2bBig(long[] in, int inOfs, byte[] out, int outOfs, int len) {
len += outOfs;
while (outOfs < len) {
long i = in[inOfs++];
out[outOfs++] = (byte)(i >> 56);
out[outOfs++] = (byte)(i >> 48);
out[outOfs++] = (byte)(i >> 40);
out[outOfs++] = (byte)(i >> 32);
out[outOfs++] = (byte)(i >> 24);
out[outOfs++] = (byte)(i >> 16);
out[outOfs++] = (byte)(i >> 8);
out[outOfs++] = (byte)(i );
}
}
}
此差异已折叠。
......@@ -78,4 +78,3 @@ public class OperatingSystemImpl implements OperatingSystemMXBean {
}
}
......@@ -419,4 +419,3 @@ class ThreadImpl implements ThreadMXBean {
}
}
......@@ -38,6 +38,7 @@ import java.util.StringTokenizer;
import java.util.Set;
import java.util.Vector;
import java.security.AccessController;
import java.security.AllPermission;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.security.AccessControlContext;
......@@ -49,7 +50,8 @@ import java.security.CodeSource;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;
import sun.net.www.ParseUtil;
import sun.jkernel.Bundle;
import sun.jkernel.DownloadManager;
/**
* This class is used by the system to launch the main application.
......@@ -116,6 +118,18 @@ public class Launcher {
return loader;
}
public static void addURLToAppClassLoader(URL u) {
AccessController.checkPermission(new AllPermission());
ClassLoader loader = Launcher.getLauncher().getClassLoader();
((Launcher.AppClassLoader) loader).addAppURL(u);
}
public static void addURLToExtClassLoader(URL u) {
AccessController.checkPermission(new AllPermission());
ClassLoader loader = Launcher.getLauncher().getClassLoader();
((Launcher.ExtClassLoader) loader.getParent()).addExtURL(u);
}
/*
* The class loader used for loading installed extensions.
*/
......@@ -233,6 +247,16 @@ public class Launcher {
return null;
}
protected Class findClass(String name) throws ClassNotFoundException {
if (VM.isBootedKernelVM()) {
// Check for download before we look for it. If
// DownloadManager ends up downloading it, it will add it to
// our search path before we proceed to the findClass().
DownloadManager.getBootClassPathEntryForClass(name);
}
return super.findClass(name);
}
private static AccessControlContext getContext(File[] dirs)
throws IOException
{
......@@ -297,6 +321,9 @@ public class Launcher {
public Class loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
if (VM.isBootedKernelVM()) {
DownloadManager.getBootClassPathEntryForClass(name);
}
int i = name.lastIndexOf('.');
if (i != -1) {
SecurityManager sm = System.getSecurityManager();
......@@ -353,39 +380,66 @@ public class Launcher {
return acc;
}
void addAppURL(URL url) {
super.addURL(url);
}
}
public static URLClassPath getBootstrapClassPath() {
String prop = AccessController.doPrivileged(
new GetPropertyAction("sun.boot.class.path"));
URL[] urls;
if (prop != null) {
final String path = prop;
urls = AccessController.doPrivileged(
new PrivilegedAction<URL[]>() {
public URL[] run() {
File[] classPath = getClassPath(path);
int len = classPath.length;
Set<File> seenDirs = new HashSet<File>();
for (int i = 0; i < len; i++) {
File curEntry = classPath[i];
// Negative test used to properly handle
// nonexistent jars on boot class path
if (!curEntry.isDirectory()) {
curEntry = curEntry.getParentFile();
}
if (curEntry != null && seenDirs.add(curEntry)) {
MetaIndex.registerDirectory(curEntry);
private static URLClassPath bootstrapClassPath;
public static synchronized URLClassPath getBootstrapClassPath() {
if (bootstrapClassPath == null) {
String prop = AccessController.doPrivileged(
new GetPropertyAction("sun.boot.class.path"));
URL[] urls;
if (prop != null) {
final String path = prop;
urls = AccessController.doPrivileged(
new PrivilegedAction<URL[]>() {
public URL[] run() {
File[] classPath = getClassPath(path);
int len = classPath.length;
Set<File> seenDirs = new HashSet<File>();
for (int i = 0; i < len; i++) {
File curEntry = classPath[i];
// Negative test used to properly handle
// nonexistent jars on boot class path
if (!curEntry.isDirectory()) {
curEntry = curEntry.getParentFile();
}
if (curEntry != null && seenDirs.add(curEntry)) {
MetaIndex.registerDirectory(curEntry);
}
}
return pathToURLs(classPath);
}
return pathToURLs(classPath);
}
}
);
} else {
urls = new URL[0];
);
} else {
urls = new URL[0];
}
bootstrapClassPath = new URLClassPath(urls, factory);
if (VM.isBootedKernelVM()) {
final File[] additionalBootStrapPaths =
DownloadManager.getAdditionalBootStrapPaths();
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
for (int i=0; i<additionalBootStrapPaths.length; i++) {
bootstrapClassPath.addURL(
getFileURL(additionalBootStrapPaths[i]));
}
return null;
}
});
}
}
return new URLClassPath(urls, factory);
return bootstrapClassPath;
}
public static synchronized void flushBootstrapClassPath() {
bootstrapClassPath = null;
}
private static URL[] pathToURLs(File[] path) {
......
......@@ -346,6 +346,11 @@ public class VM {
private native static void getThreadStateValues(int[][] vmThreadStateValues,
String[][] vmThreadStateNames);
private static boolean kernelVM;
public static boolean isBootedKernelVM() {
return booted && kernelVM;
}
static {
initialize();
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -416,5 +416,3 @@ class GlobalListener implements AWTEventListener {
// }
}
}
......@@ -105,4 +105,3 @@ class TestFailedException extends RuntimeException {
super("Test failed: " + msg);
}
}
......@@ -66,4 +66,3 @@ public class TranslatedOutlineTest {
throw new RuntimeException("Outline was not detected");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册