changeset 5177:a5949f7b8693 jdk7u6-b08

Merge
author lana
date Wed, 25 Apr 2012 15:54:31 -0700
parents b3aee8fb88b0 (current diff) cdeb4234136d (diff)
children 0cd518f8fea7 224011dbdf1f 1e3829d2447c
files
diffstat 45 files changed, 852 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/make/com/sun/tools/attach/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/com/sun/tools/attach/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,8 @@
 #
 
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../../..
 PACKAGE = com.sun.tools.attach
 LIBRARY = attach
--- a/make/common/Defs-linux.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Defs-linux.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -132,8 +132,9 @@
   # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
   # JDK build to import .debuginfo or .diz files from the HotSpot build.
   # However, adding FDS support to the JDK build will occur in phases
-  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
-  # is used to indicate that a particular library supports FDS.
+  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+  # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
+  # particular library or program supports FDS.
 
   ifeq ($(OBJCOPY),)
     _JUNK_ := $(shell \
@@ -157,9 +158,7 @@
     _JUNK_ := $(shell \
       echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
 
-    # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
-    # changes are promoted
-    ZIP_DEBUGINFO_FILES ?= 0
+    ZIP_DEBUGINFO_FILES ?= 1
 
     _JUNK_ := $(shell \
       echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
@@ -262,6 +261,17 @@
   CFLAGS_REQUIRED += $(DEBUG_FLAG)
 endif
 
+# If Full Debug Symbols is enabled, then we want the same debug and
+# optimization flags as used by FASTDEBUG.
+#
+ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+  ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+    ifeq ($(VARIANT), OPT)
+      CC_OPT = $(DEBUG_FLAG) $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+    endif
+  endif
+endif
+
 CFLAGS_OPT      = $(CC_OPT)
 CFLAGS_DBG      = $(DEBUG_FLAG)
 CFLAGS_COMMON += $(CFLAGS_REQUIRED)
--- a/make/common/Defs-solaris.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Defs-solaris.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -139,8 +139,9 @@
   # Setting ENABLE_FULL_DEBUG_SYMBOLS=1 (and OBJCOPY) above enables the
   # JDK build to import .debuginfo or .diz files from the HotSpot build.
   # However, adding FDS support to the JDK build will occur in phases
-  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS)
-  # is used to indicate that a particular library supports FDS.
+  # so a different make variable (LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+  # and PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS) is used to indicate that a
+  # particular library or program supports FDS.
 
   ifeq ($(OBJCOPY),)
     _JUNK_ := $(shell \
@@ -165,9 +166,7 @@
     _JUNK_ := $(shell \
       echo >&2 "INFO: STRIP_POLICY=$(STRIP_POLICY)")
 
-    # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
-    # changes are promoted
-    ZIP_DEBUGINFO_FILES ?= 0
+    ZIP_DEBUGINFO_FILES ?= 1
 
     _JUNK_ := $(shell \
       echo >&2 "INFO: ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")
@@ -241,6 +240,21 @@
   CXXFLAGS_DEBUG_OPTION  = -g0 $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
 endif
 
+# If Full Debug Symbols is enabled, then we want the same debug and
+# optimization flags as used by FASTDEBUG. We also want all the
+# debug info in one place (-xs).
+#
+ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+  ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+    ifeq ($(VARIANT), OPT)
+      CC_OPT   = -g  -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+      CXX_OPT  = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+    endif
+    CFLAGS_DEBUG_OPTION    += -xs
+    CXXFLAGS_DEBUG_OPTION  += -xs
+  endif
+endif
+
 CFLAGS_COMMON   = -L$(OBJDIR)
 
 # Do not allow C99 language features like declarations in code etc.
--- a/make/common/Defs-windows.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Defs-windows.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -114,9 +114,7 @@
   echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")
 
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
-  # HACK: disable ZIP_DEBUGINFO_FILES by default until install repo
-  # changes are promoted
-  ZIP_DEBUGINFO_FILES ?= 0
+  ZIP_DEBUGINFO_FILES ?= 1
 else
   ZIP_DEBUGINFO_FILES=0
 endif
--- a/make/common/Library.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Library.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -184,8 +184,17 @@
 	$(CP) $(OBJDIR)/$(@F) $@
 	@$(call binary_file_verification,$@)
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+  ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	(set -e ; \
+	 $(CD) $(OBJDIR) ; \
+	 $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).map $(LIBRARY).pdb ; \
+	)
+	$(CP) $(OBJDIR)/$(LIBRARY).diz $(@D)
+	$(RM) $(OBJDIR)/$(LIBRARY).map $(OBJDIR)/$(LIBRARY).pdb
+  else
 	$(CP) $(OBJDIR)/$(LIBRARY).map $(@D)
 	$(CP) $(OBJDIR)/$(LIBRARY).pdb $(@D)
+  endif
 endif
 
 endif # LIBRARY
@@ -251,6 +260,37 @@
 ifeq ($(WRITE_LIBVERSION),true)
 	$(MCS) -d -a "$(FULL_VERSION)" $@
 endif # WRITE_LIBVERSION
+  ifneq ($(PLATFORM), macosx)
+    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+      ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+	(set -e ; \
+	 $(CD) $(@D) ; \
+	 $(OBJCOPY) --only-keep-debug $(@F) $(LIBRARY).debuginfo ; \
+	 $(OBJCOPY) --add-gnu-debuglink=$(LIBRARY).debuginfo $(@F) ; \
+	)
+        ifeq ($(STRIP_POLICY),all_strip)
+	  $(STRIP) $@
+        else
+          ifeq ($(STRIP_POLICY),min_strip)
+            ifeq ($(PLATFORM), solaris)
+	      $(STRIP) -x $@
+            else
+              # assume Linux
+	      $(STRIP) -g $@
+            endif
+          # implied else here is no stripping at all
+          endif
+        endif
+        ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	  (set -e ; \
+	   $(CD) $(@D) ; \
+	   $(ZIPEXE) -q $(LIBRARY).diz $(LIBRARY).debuginfo ; \
+	   $(RM) $(LIBRARY).debuginfo ; \
+	  )
+        endif
+      endif # LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS
+    endif # ENABLE_FULL_DEBUG_SYMBOLS
+  endif # PLATFORM-!macosx
 endif # LIBRARY
 
 endif # PLATFORM
--- a/make/common/Program.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Program.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -189,6 +189,15 @@
 	$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
   endif # MT
 	@$(call binary_file_verification,$@)
+  ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+    ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	(set -e ; \
+	 $(CD) $(OBJDIR) ; \
+	 $(ZIPEXE) -q $(PROGRAM).diz $(PROGRAM).map $(PROGRAM).pdb ; \
+	 $(RM) $(PROGRAM).map $(PROGRAM).pdb ; \
+	)
+    endif
+  endif
 else # *NIXES
   #
   # Note that we have to link -lthread even when USE_PTHREADS is true.
@@ -232,6 +241,42 @@
 	-codesign -s openjdk_codesign $@
   endif # INFO_PLIST_FILE
 	@$(call binary_file_verification,$@)
+  ifneq ($(PLATFORM), macosx)
+    ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
+      ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
+	(set -e ; \
+	 $(CD) $(@D) ; \
+	 $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
+	 $(OBJCOPY) --add-gnu-debuglink=$(@F).debuginfo $(@F) ; \
+	)
+        ifeq ($(STRIP_POLICY),all_strip)
+	  $(STRIP) $@
+        else
+          ifeq ($(STRIP_POLICY),min_strip)
+            ifeq ($(PLATFORM), solaris)
+	      $(STRIP) -x $@
+            else
+              # assume Linux
+	      $(STRIP) -g $@
+            endif
+          # implied else here is no stripping at all
+          endif
+        endif
+        ifeq ($(ZIP_DEBUGINFO_FILES),1)
+	  (set -e ; \
+	   $(CD) $(@D) ; \
+	   $(ZIPEXE) -q $(@F).diz $(@F).debuginfo ; \
+	   $(RM) $(@F).debuginfo ; \
+	  )
+          # save ZIP'ed debug info with rest of the program's build artifacts
+	  $(MV) $@.diz $(OBJDIR)
+        else
+          # save debug info with rest of the program's build artifacts
+	  $(MV) $@.debuginfo $(OBJDIR)
+        endif
+      endif # PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
+    endif # ENABLE_FULL_DEBUG_SYMBOLS
+  endif # PLATFORM-!macosx
 endif # PLATFORM
 
 clean:: 
@@ -240,12 +285,16 @@
 	$(RM) $(OBJDIR)/$(PROGRAM).ico
 	$(RM) $(OBJDIR)/$(PROGRAM).lcf
 	$(RM) $(OBJDIR)/$(PROGRAM).map
+	$(RM) $(OBJDIR)/$(PROGRAM).pdb
 	$(RM) $(OBJDIR)/$(PROGRAM).exp
 	$(RM) $(OBJDIR)/$(PROGRAM).lib
 	$(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
 	$(RM) $(OBJDIR)/$(PROGRAM).ilk
 	$(RM) *.pdb
+else
+	$(RM) $(OBJDIR)/$(PROGRAM).debuginfo
 endif
+	$(RM) $(OBJDIR)/$(PROGRAM).diz
 
 
 clobber:: 
--- a/make/common/Release-macosx.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Release-macosx.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -35,8 +35,8 @@
 MACOSX_SRC	 = $(JDK_TOPDIR)/src/macosx
 
 BUNDLE_ID ?= net.java.openjdk
-BUNLDE_ID_JRE ?= $(BUNDLE_ID).jre
-BUNLDE_ID_JDK ?= $(BUNDLE_ID).jdk
+BUNDLE_ID_JRE ?= $(BUNDLE_ID).jre
+BUNDLE_ID_JDK ?= $(BUNDLE_ID).jdk
 
 BUNDLE_NAME ?= OpenJDK $(JDK_MINOR_VERSION)
 BUNDLE_NAME_JRE ?= $(BUNDLE_NAME)
--- a/make/common/Release.gmk	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/common/Release.gmk	Wed Apr 25 15:54:31 2012 -0700
@@ -881,7 +881,9 @@
 	   -o -name \*.dll | $(EGREP) -v -i "$(MSVCRNN_DLL)" > $@
 else
 	$(FIND) $(JRE_IMAGE_DIR)/lib -type f -name \*.$(LIB_SUFFIX) >> $@
-	$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+# The FILE command reports .debuginfo files as "ELF", but we don't want
+# those files in the JRE_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
+	$(FILE) `$(FIND) $(JRE_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
 endif
 
@@ -1140,9 +1142,11 @@
 else
 	$(RM) $@
 	$(FIND) $(JDK_IMAGE_DIR)/jre/lib -type f -name \*.$(LIB_SUFFIX) >> $@
-	$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f -name \*$(EXE_SUFFIX)` \
+# The FILE command reports .debuginfo files as "ELF", but we don't want
+# those files in the JDK_BIN_LIST file. EXE_SUFFIX is empty on non-Windows.
+	$(FILE) `$(FIND) $(JDK_IMAGE_DIR)/jre/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
-	file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f -name \*$(EXE_SUFFIX)` \
+	file `$(FIND) $(JDK_IMAGE_DIR)/bin -type f ! -name '*.debuginfo' -name \*$(EXE_SUFFIX)` \
 	    | $(EGREP) 'ELF' | $(CUT) -d':' -f1 >> $@
 endif
 
--- a/make/java/instrument/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/instrument/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 # Makefile for building the Java Programming Language Instrumentation Services
 # agent, supporting java.lang.instrument
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PACKAGE = sun.instrument
 LIBRARY = instrument
--- a/make/java/java_crw_demo/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/java_crw_demo/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 
 LIBRARY = java_crw_demo
--- a/make/java/java_hprof_demo/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/java_hprof_demo/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 LIBRARY = hprof
 PRODUCT = sun
--- a/make/java/main/java/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/main/java/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PROGRAM = java
 PRODUCT = java
--- a/make/java/management/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/management/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PACKAGE = java.lang.management
 LIBRARY = management
--- a/make/java/npt/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/npt/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 
 # It's currently used by jpda and hprof.  Put it in base module for now.
--- a/make/java/verify/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/java/verify/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 # Build libverify.so
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PRODUCT = java
 LIBRARY = verify
--- a/make/jpda/jdwp/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/jpda/jdwp/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 # Makefile for building JDWP
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../..
 PACKAGE = com.sun.tools.jdwp
 PRODUCT = jpda
--- a/make/jpda/transport/socket/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/jpda/transport/socket/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 # Makefile for building the JDI back-end implementation
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 LIBRARY = dt_socket
 PRODUCT = jbug
--- a/make/launchers/Makefile.launcher	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/launchers/Makefile.launcher	Wed Apr 25 15:54:31 2012 -0700
@@ -27,6 +27,8 @@
 # Makefile for building simple launchers
 #
 
+PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ..
 PACKAGE = launcher
 PRODUCT = sun
--- a/make/mkdemo/jvmti/compiledMethodLoad/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/compiledMethodLoad/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = compiledMethodLoad
--- a/make/mkdemo/jvmti/gctest/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/gctest/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = gctest
--- a/make/mkdemo/jvmti/heapTracker/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/heapTracker/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = heapTracker
--- a/make/mkdemo/jvmti/heapViewer/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/heapViewer/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = heapViewer
--- a/make/mkdemo/jvmti/hprof/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/hprof/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = hprof
--- a/make/mkdemo/jvmti/minst/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/minst/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = minst
--- a/make/mkdemo/jvmti/mtrace/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/mtrace/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = mtrace
--- a/make/mkdemo/jvmti/versionCheck/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/versionCheck/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = versionCheck
--- a/make/mkdemo/jvmti/waiters/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/mkdemo/jvmti/waiters/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
 # questions.
 #
 
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PRODUCT = demo/jvmti
 DEMONAME = waiters
--- a/make/sun/tracing/dtrace/Makefile	Mon Apr 23 15:13:40 2012 -0700
+++ b/make/sun/tracing/dtrace/Makefile	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,9 @@
 #
 # Makefile for building dtrace extension
 #
+
+LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS=1
+
 BUILDDIR = ../../..
 PACKAGE = sun.tracing.dtrace
 LIBRARY = jsdt
--- a/src/macosx/bin/java_md_macosx.c	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/macosx/bin/java_md_macosx.c	Wed Apr 25 15:54:31 2012 -0700
@@ -906,11 +906,41 @@
 {
     char envVar[80];
     if (strstr(arg, "-Xdock:name=") == arg) {
+        /*
+         * The APP_NAME_<pid> environment variable is used to pass
+         * an application name as specified with the -Xdock:name command
+         * line option from Java launcher code to the AWT code in order
+         * to assign this name to the app's dock tile on the Mac.
+         * The _<pid> part is added to avoid collisions with child processes.
+         *
+         * WARNING: This environment variable is an implementation detail and
+         * isn't meant for use outside of the core platform. The mechanism for
+         * passing this information from Java launcher to other modules may
+         * change drastically between update release, and it may even be
+         * removed or replaced with another mechanism.
+         *
+         * NOTE: It is used by SWT, and JavaFX.
+         */
         snprintf(envVar, sizeof(envVar), "APP_NAME_%d", getpid());
         setenv(envVar, (arg + 12), 1);
     }
 
     if (strstr(arg, "-Xdock:icon=") == arg) {
+        /*
+         * The APP_ICON_<pid> environment variable is used to pass
+         * an application icon as specified with the -Xdock:icon command
+         * line option from Java launcher code to the AWT code in order
+         * to assign this icon to the app's dock tile on the Mac.
+         * The _<pid> part is added to avoid collisions with child processes.
+         *
+         * WARNING: This environment variable is an implementation detail and
+         * isn't meant for use outside of the core platform. The mechanism for
+         * passing this information from Java launcher to other modules may
+         * change drastically between update release, and it may even be
+         * removed or replaced with another mechanism.
+         *
+         * NOTE: It is used by SWT, and JavaFX.
+         */
         snprintf(envVar, sizeof(envVar), "APP_ICON_%d", getpid());
         setenv(envVar, (arg + 12), 1);
     }
@@ -931,6 +961,22 @@
     NULL_CHECK(mainClassName = (*env)->GetStringUTFChars(env, mainClassString, NULL));
 
     char envVar[80];
+    /*
+     * The JAVA_MAIN_CLASS_<pid> environment variable is used to pass
+     * the name of a Java class whose main() method is invoked by
+     * the Java launcher code to start the application, to the AWT code
+     * in order to assign the name to the Apple menu bar when the app
+     * is active on the Mac.
+     * The _<pid> part is added to avoid collisions with child processes.
+     *
+     * WARNING: This environment variable is an implementation detail and
+     * isn't meant for use outside of the core platform. The mechanism for
+     * passing this information from Java launcher to other modules may
+     * change drastically between update release, and it may even be
+     * removed or replaced with another mechanism.
+     *
+     * NOTE: It is used by SWT, and JavaFX.
+     */
     snprintf(envVar, sizeof(envVar), "JAVA_MAIN_CLASS_%d", getpid());
     setenv(envVar, mainClassName, 1);
 
--- a/src/share/classes/java/security/CodeSource.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/share/classes/java/security/CodeSource.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -371,9 +371,8 @@
      */
     private boolean matchLocation(CodeSource that)
         {
-            if (location == null) {
+            if (location == null)
                 return true;
-            }
 
             if ((that == null) || (that.location == null))
                 return false;
@@ -381,32 +380,9 @@
             if (location.equals(that.location))
                 return true;
 
-            if (!location.getProtocol().equals(that.location.getProtocol()))
+            if (!location.getProtocol().equalsIgnoreCase(that.location.getProtocol()))
                 return false;
 
-            String thisHost = location.getHost();
-            String thatHost = that.location.getHost();
-
-            if (thisHost != null) {
-                if (("".equals(thisHost) || "localhost".equals(thisHost)) &&
-                    ("".equals(thatHost) || "localhost".equals(thatHost))) {
-                    // ok
-                } else if (!thisHost.equals(thatHost)) {
-                    if (thatHost == null) {
-                        return false;
-                    }
-                    if (this.sp == null) {
-                        this.sp = new SocketPermission(thisHost, "resolve");
-                    }
-                    if (that.sp == null) {
-                        that.sp = new SocketPermission(thatHost, "resolve");
-                    }
-                    if (!this.sp.implies(that.sp)) {
-                        return false;
-                    }
-                }
-            }
-
             if (location.getPort() != -1) {
                 if (location.getPort() != that.location.getPort())
                     return false;
@@ -443,10 +419,34 @@
                 }
             }
 
-            if (location.getRef() == null)
-                return true;
-            else
-                return location.getRef().equals(that.location.getRef());
+            if (location.getRef() != null) {
+                if (!location.getRef().equals(that.location.getRef()))
+                    return false;
+            }
+
+            String thisHost = location.getHost();
+            String thatHost = that.location.getHost();
+            if (thisHost != null) {
+                if (("".equals(thisHost) || "localhost".equals(thisHost)) &&
+                    ("".equals(thatHost) || "localhost".equals(thatHost))) {
+                    // ok
+                } else if (!thisHost.equalsIgnoreCase(thatHost)) {
+                    if (thatHost == null) {
+                        return false;
+                    }
+                    if (this.sp == null) {
+                        this.sp = new SocketPermission(thisHost, "resolve");
+                    }
+                    if (that.sp == null) {
+                        that.sp = new SocketPermission(thatHost, "resolve");
+                    }
+                    if (!this.sp.implies(that.sp)) {
+                        return false;
+                    }
+                }
+            }
+            // everything matches
+            return true;
         }
 
     /**
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -970,7 +970,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             ResourceManager.afterUdpClose();
 
             // if member of mulitcast group then invalidate all keys
--- a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -261,7 +261,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/share/classes/sun/nio/ch/SocketChannelImpl.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -816,7 +816,8 @@
             // channel from using the old fd, which might be recycled in the
             // meantime and allocated to an entirely different channel.
             //
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
 
             // Signal native threads, if needed.  If a target thread is not
             // currently blocked in an I/O operation then no harm is done since
--- a/src/share/classes/sun/tools/jcmd/JCmd.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/share/classes/sun/tools/jcmd/JCmd.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *com.sun.tools.attach.AttachNotSupportedException
 
@@ -142,17 +142,20 @@
         // Cast to HotSpotVirtualMachine as this is an
         // implementation specific method.
         HotSpotVirtualMachine hvm = (HotSpotVirtualMachine) vm;
-        try (InputStream in = hvm.executeJCmd(command);) {
-            // read to EOF and just print output
-            byte b[] = new byte[256];
-            int n;
-            do {
-                n = in.read(b);
-                if (n > 0) {
-                    String s = new String(b, 0, n, "UTF-8");
-                    System.out.print(s);
-                }
-            } while (n > 0);
+        String lines[] = command .split("\\n");
+        for (String line : lines) {
+            try (InputStream in = hvm.executeJCmd(line);) {
+                // read to EOF and just print output
+                byte b[] = new byte[256];
+                int n;
+                do {
+                    n = in.read(b);
+                    if (n > 0) {
+                        String s = new String(b, 0, n, "UTF-8");
+                        System.out.print(s);
+                    }
+                } while (n > 0);
+            }
         }
         vm.detach();
     }
--- a/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/solaris/classes/sun/nio/ch/SinkChannelImpl.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/solaris/classes/sun/nio/ch/SourceChannelImpl.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,7 +84,8 @@
 
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
-            nd.preClose(fd);
+            if (state != ST_KILLED)
+                nd.preClose(fd);
             long th = thread;
             if (th != 0)
                 NativeThread.signal(th);
--- a/src/solaris/native/com/sun/management/MacosxOperatingSystem.c	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/solaris/native/com/sun/management/MacosxOperatingSystem.c	Wed Apr 25 15:54:31 2012 -0700
@@ -25,16 +25,136 @@
 
 #include "com_sun_management_UnixOperatingSystem.h"
 
+#include <sys/time.h>
+#include <mach/mach.h>
+#include <mach/task_info.h>
+
+
 JNIEXPORT jdouble JNICALL
 Java_com_sun_management_UnixOperatingSystem_getSystemCpuLoad
 (JNIEnv *env, jobject dummy)
 {
-  return -1.0; // not available
+    // This code is influenced by the darwin top source
+
+    kern_return_t kr;
+    mach_msg_type_number_t count;
+    host_cpu_load_info_data_t load;
+
+    static jlong last_used  = 0;
+    static jlong last_total = 0;
+
+    count = HOST_CPU_LOAD_INFO_COUNT;
+    kr = host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, (host_info_t)&load, &count);
+    if (kr != KERN_SUCCESS) {
+        return -1;
+    }
+
+    jlong used  = load.cpu_ticks[CPU_STATE_USER] + load.cpu_ticks[CPU_STATE_NICE] + load.cpu_ticks[CPU_STATE_SYSTEM];
+    jlong total = used + load.cpu_ticks[CPU_STATE_IDLE];
+
+    if (last_used == 0 || last_total == 0) {
+        // First call, just set the last values
+        last_used  = used;
+        last_total = total;
+        // return 0 since we have no data, not -1 which indicates error
+        return 0;
+    }
+
+    jlong used_delta  = used - last_used;
+    jlong total_delta = total - last_total;
+
+    jdouble cpu = (jdouble) used_delta / total_delta;
+
+    last_used  = used;
+    last_total = total;
+
+    return cpu;
 }
 
+
+#define TIME_VALUE_TO_TIMEVAL(a, r) do {  \
+     (r)->tv_sec = (a)->seconds;          \
+     (r)->tv_usec = (a)->microseconds;    \
+} while (0)
+
+
+#define TIME_VALUE_TO_MICROSECONDS(TV) \
+     ((TV).tv_sec * 1000 * 1000 + (TV).tv_usec)
+
+
 JNIEXPORT jdouble JNICALL
 Java_com_sun_management_UnixOperatingSystem_getProcessCpuLoad
 (JNIEnv *env, jobject dummy)
 {
-  return -1.0; // not available
-}
+    // This code is influenced by the darwin top source
+
+    struct task_basic_info_64 task_info_data;
+    struct task_thread_times_info thread_info_data;
+    struct timeval user_timeval, system_timeval, task_timeval;
+    struct timeval now;
+    mach_port_t task = mach_task_self();
+    kern_return_t kr;
+
+    static jlong last_task_time = 0;
+    static jlong last_time      = 0;
+
+    mach_msg_type_number_t thread_info_count = TASK_THREAD_TIMES_INFO_COUNT;
+    kr = task_info(task,
+            TASK_THREAD_TIMES_INFO,
+            (task_info_t)&thread_info_data,
+            &thread_info_count);
+    if (kr != KERN_SUCCESS) {
+        // Most likely cause: |task| is a zombie.
+        return -1;
+    }
+
+    mach_msg_type_number_t count = TASK_BASIC_INFO_64_COUNT;
+    kr = task_info(task,
+            TASK_BASIC_INFO_64,
+            (task_info_t)&task_info_data,
+            &count);
+    if (kr != KERN_SUCCESS) {
+        // Most likely cause: |task| is a zombie.
+        return -1;
+    }
+
+    /* Set total_time. */
+    // thread info contains live time...
+    TIME_VALUE_TO_TIMEVAL(&thread_info_data.user_time, &user_timeval);
+    TIME_VALUE_TO_TIMEVAL(&thread_info_data.system_time, &system_timeval);
+    timeradd(&user_timeval, &system_timeval, &task_timeval);
+
+    // ... task info contains terminated time.
+    TIME_VALUE_TO_TIMEVAL(&task_info_data.user_time, &user_timeval);
+    TIME_VALUE_TO_TIMEVAL(&task_info_data.system_time, &system_timeval);
+    timeradd(&user_timeval, &task_timeval, &task_timeval);
+    timeradd(&system_timeval, &task_timeval, &task_timeval);
+
+    if (gettimeofday(&now, NULL) < 0) {
+       return -1;
+    }
+    jint ncpus      = JVM_ActiveProcessorCount();
+    jlong time      = TIME_VALUE_TO_MICROSECONDS(now) * ncpus;
+    jlong task_time = TIME_VALUE_TO_MICROSECONDS(task_timeval);
+
+    if ((last_task_time == 0) || (last_time == 0)) {
+        // First call, just set the last values.
+        last_task_time = task_time;
+        last_time      = time;
+        // return 0 since we have no data, not -1 which indicates error
+        return 0;
+    }
+
+    jlong task_time_delta = task_time - last_task_time;
+    jlong time_delta      = time - last_time;
+    if (time_delta == 0) {
+        return -1;
+    }
+
+    jdouble cpu = (jdouble) task_time_delta / time_delta;
+
+    last_task_time = task_time;
+    last_time      = time;
+
+    return cpu;
+ }
--- a/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	Mon Apr 23 15:13:40 2012 -0700
+++ b/src/solaris/native/com/sun/management/UnixOperatingSystem_md.c	Wed Apr 25 15:54:31 2012 -0700
@@ -34,6 +34,13 @@
 #include <sys/stat.h>
 #if defined(_ALLBSD_SOURCE)
 #include <sys/sysctl.h>
+#ifdef __APPLE__
+#include <sys/param.h>
+#include <sys/mount.h>
+#include <mach/mach.h>
+#include <sys/proc_info.h>
+#include <libproc.h>
+#endif
 #else
 #include <sys/swap.h>
 #endif
@@ -150,6 +157,13 @@
     avail = (jlong)si.freeswap * si.mem_unit;
 
     return available ? avail : total;
+#elif defined(__APPLE__)
+    struct xsw_usage vmusage;
+    size_t size = sizeof(vmusage);
+    if (sysctlbyname("vm.swapusage", &vmusage, &size, NULL, 0) != 0) {
+        throw_internal_error(env, "sysctlbyname failed");
+    }
+    return available ? (jlong)vmusage.xsu_avail : (jlong)vmusage.xsu_total;
 #else /* _ALLBSD_SOURCE */
     /*
      * XXXBSD: there's no way available to get swap info in
@@ -216,6 +230,15 @@
 
     fclose(fp);
     return (jlong)vsize;
+#elif defined(__APPLE__)
+    struct task_basic_info t_info;
+    mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
+
+    kern_return_t res = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
+    if (res != KERN_SUCCESS) {
+        throw_internal_error(env, "task_info failed");
+    }
+    return t_info.virtual_size;
 #else /* _ALLBSD_SOURCE */
     /*
      * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
@@ -243,6 +266,17 @@
 Java_com_sun_management_UnixOperatingSystem_getProcessCpuTime
   (JNIEnv *env, jobject mbean)
 {
+#ifdef __APPLE__
+    struct rusage usage;
+    if (getrusage(RUSAGE_SELF, &usage) != 0) {
+        throw_internal_error(env, "getrusage failed");
+        return -1;
+    }
+    jlong microsecs =
+        usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec +
+        usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec;
+    return microsecs * 1000;
+#else
     jlong clk_tck, ns_per_clock_tick;
     jlong cpu_time_ns;
     struct tms time;
@@ -267,19 +301,32 @@
     cpu_time_ns = ((jlong)time.tms_utime + (jlong) time.tms_stime) *
                       ns_per_clock_tick;
     return cpu_time_ns;
+#endif
 }
 
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize
   (JNIEnv *env, jobject mbean)
 {
-#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+    mach_msg_type_number_t count;
+    vm_statistics_data_t vm_stats;
+    kern_return_t res;
+
+    count = HOST_VM_INFO_COUNT;
+    res = host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vm_stats, &count);
+    if (res != KERN_SUCCESS) {
+        throw_internal_error(env, "host_statistics failed");
+        return -1;
+    }
+    return (jlong)vm_stats.free_count * page_size;
+#elif defined(_ALLBSD_SOURCE)
     /*
      * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
      */
     // throw_internal_error(env, "Unimplemented in FreeBSD");
     return (128 * MB);
-#else
+#else // solaris / linux
     jlong num_avail_physical_pages = sysconf(_SC_AVPHYS_PAGES);
     return (num_avail_physical_pages * page_size);
 #endif
@@ -290,28 +337,75 @@
   (JNIEnv *env, jobject mbean)
 {
 #ifdef _ALLBSD_SOURCE
-    jlong result;
+    jlong result = 0;
     int mib[2];
     size_t rlen;
 
     mib[0] = CTL_HW;
-    mib[1] = HW_PHYSMEM;
+    mib[1] = HW_MEMSIZE;
     rlen = sizeof(result);
-    if (sysctl(mib, 2, &result, &rlen, NULL, 0) == -1)
-        result = 256 * MB;
-
-    return (result);
-#else
+    if (sysctl(mib, 2, &result, &rlen, NULL, 0) != 0) {
+        throw_internal_error(env, "sysctl failed");
+        return -1;
+    }
+    return result;
+#else // solaris / linux
     jlong num_physical_pages = sysconf(_SC_PHYS_PAGES);
     return (num_physical_pages * page_size);
 #endif
 }
 
+
+
 JNIEXPORT jlong JNICALL
 Java_com_sun_management_UnixOperatingSystem_getOpenFileDescriptorCount
   (JNIEnv *env, jobject mbean)
 {
-#ifdef _ALLBSD_SOURCE
+#ifdef __APPLE__
+    // This code is influenced by the darwin lsof source
+    pid_t my_pid;
+    struct proc_bsdinfo bsdinfo;
+    struct proc_fdinfo *fds;
+    int nfiles;
+    kern_return_t kres;
+    int res;
+    size_t fds_size;
+
+    kres = pid_for_task(mach_task_self(), &my_pid);
+    if (res != KERN_SUCCESS) {
+        throw_internal_error(env, "pid_for_task failed");
+        return -1;
+    }
+
+    // get the maximum number of file descriptors
+    res = proc_pidinfo(my_pid, PROC_PIDTBSDINFO, 0, &bsdinfo, PROC_PIDTBSDINFO_SIZE);
+    if (res <= 0) {
+        throw_internal_error(env, "proc_pidinfo with PROC_PIDTBSDINFO failed");
+        return -1;
+    }
+
+    // allocate memory to hold the fd information (we don't acutally use this information
+    // but need it to get the number of open files)
+    fds_size = bsdinfo.pbi_nfiles * sizeof(struct proc_fdinfo);
+    fds = malloc(fds_size);
+    if (fds == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "could not allocate space for file descriptors");
+        return -1;
+    }
+
+    // get the list of open files - the return value is the number of bytes
+    // proc_pidinfo filled in
+    res = proc_pidinfo(my_pid, PROC_PIDLISTFDS, 0, fds, fds_size);
+    if (res <= 0) {
+        free(fds);
+        throw_internal_error(env, "proc_pidinfo failed for PROC_PIDLISTFDS");
+        return -1;
+    }
+    nfiles = res / sizeof(struct proc_fdinfo);
+    free(fds);
+
+    return nfiles;
+#elif defined(_ALLBSD_SOURCE)
     /*
      * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.
      */
--- a/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh	Mon Apr 23 15:13:40 2012 -0700
+++ b/test/com/sun/management/OperatingSystemMXBean/TestTotalSwap.sh	Wed Apr 25 15:54:31 2012 -0700
@@ -83,6 +83,13 @@
        total_swap=`free -b | grep -i swap | awk '{print $2}'`
        runOne GetTotalSwapSpaceSize $total_swap 
        ;;
+     Darwin )
+       # $ sysctl -n vm.swapusage 
+       # total = 8192.00M  used = 7471.11M  free = 720.89M  (encrypted)
+       swap=`/usr/sbin/sysctl -n vm.swapusage | awk '{ print $3 }' | awk -F . '{ print $1 }'` || exit 2
+       total_swap=`expr $swap \* 1024 \* 1024` || exit 2
+       runOne GetTotalSwapSpaceSize $total_swap
+       ;;
     * )
        runOne GetTotalSwapSpaceSize "sanity-only"
        ;;
--- a/test/java/security/CodeSource/Implies.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/test/java/security/CodeSource/Implies.java	Wed Apr 25 15:54:31 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4866847
+ * @bug 4866847 7155693
  * @summary NullPointerException from CodeSource.matchLocation
  */
 
@@ -34,14 +34,27 @@
     public static void main(String[] args) throws Exception {
         URL thisURL = new URL("http", "localhost", "file");
         URL thatURL = new URL("http", null, "file");
+        // should not throw NullPointerException
+        testImplies(thisURL, thatURL, false);
+
+        thisURL = new URL("http", "localhost", "dir/-");
+        thatURL = new URL("HTTP", "localhost", "dir/file");
+        // protocol check should ignore case
+        testImplies(thisURL, thatURL, true);
+
+        System.out.println("test passed");
+    }
+
+    private static void testImplies(URL thisURL, URL thatURL, boolean result)
+        throws SecurityException
+    {
         CodeSource thisCs =
             new CodeSource(thisURL, (java.security.cert.Certificate[]) null);
         CodeSource thatCs =
             new CodeSource(thatURL, (java.security.cert.Certificate[]) null);
 
-        if (thisCs.implies(thatCs)) {
+        if (thisCs.implies(thatCs) != result) {
             throw new SecurityException("test failed");
         }
-        System.out.println("test passed");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/tools/jcmd/dcmd-big-script.txt	Wed Apr 25 15:54:31 2012 -0700
@@ -0,0 +1,95 @@
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
+VM.version
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/tools/jcmd/jcmd-big-script.sh	Wed Apr 25 15:54:31 2012 -0700
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+
+# @test
+# @bug 7154822
+# @summary test if we can send a file over 1024 bytes large via jcmd -f
+# @author David Buck
+#
+# @library ../common
+# @build SimpleApplication ShutdownSimpleApplication
+# @run shell jcmd-big-script.sh
+
+. ${TESTSRC}/../common/CommonSetup.sh
+. ${TESTSRC}/../common/ApplicationSetup.sh
+
+# Start application and use PORTFILE for coordination
+PORTFILE="${TESTCLASSES}"/shutdown.port
+startApplication SimpleApplication "${PORTFILE}"
+
+failed=0;
+
+# -f <script>
+rm -f jcmd.out 2>/dev/null
+set +e # even if jcmd fails, we do not want abort the script yet.
+${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-big-script.txt > jcmd.out 2>&1
+status="$?"
+set -e
+if [ "$status" != 0 ]; then
+  echo "jcmd command returned non-zero exit code (status=$status). Failed."
+  failed=1;
+fi
+cat jcmd.out
+set +e # if the test passes, grep will "fail" with an exit code of 1
+grep Exception jcmd.out > /dev/null 2>&1
+status="$?"
+set -e
+if [ "$status" = 0 ]; then
+  echo "Output of \"jcmd [pid] -f dcmd-big-script.txt\" contains string \"Exception\". Failed."
+  failed=1;
+fi
+
+# clean up
+rm -f jcmd.out 2>/dev/null
+stopApplication "${PORTFILE}"
+waitForApplication
+
+exit $failed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/launcher/EnvironmentVariables.java	Wed Apr 25 15:54:31 2012 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * see TestSpecialArgs.java
+ * bug 7131021
+ * summary Checks for environment variables set by the launcher
+ * author anthony.petrov@oracle.com: area=launcher
+ */
+
+public class EnvironmentVariables {
+    public static void main(String[] args) {
+        if (args.length != 2) {
+            throw new RuntimeException("ERROR: two command line arguments expected");
+        }
+
+        String name = args[0];
+        String expect = args[1];
+        String key = null;
+
+        if (!name.endsWith("*")) {
+            key = name;
+        } else {
+            name = name.split("\\*")[0];
+
+            for (String s : System.getenv().keySet()) {
+                if (s.startsWith(name)) {
+                    if (key == null) {
+                        key = s;
+                    } else {
+                        System.err.println("WARNING: more variables match: " + s);
+                    }
+                }
+            }
+
+            if (key == null) {
+                throw new RuntimeException("ERROR: unable to find a match for: " + name);
+            }
+        }
+
+        System.err.println("Will check the variable named: '" + key +
+                "' expecting the value: '" + expect + "'");
+
+        if (!System.getenv().containsKey(key)) {
+            throw new RuntimeException("ERROR: the variable '" + key +
+                    "' is not present in the environment");
+        }
+
+        if (!expect.equals(System.getenv().get(key))) {
+            throw new RuntimeException("ERROR: expected: '" + expect +
+                    "', got: '" + System.getenv().get(key) + "'");
+        }
+        for (String x : args) {
+            System.err.print(x + " ");
+        }
+        System.err.println("-----> Passed!");
+    }
+}
+
--- a/test/tools/launcher/TestHelper.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/test/tools/launcher/TestHelper.java	Wed Apr 25 15:54:31 2012 -0700
@@ -21,6 +21,7 @@
  * questions.
  */
 
+import java.util.Set;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileFilter;
@@ -313,19 +314,28 @@
     }
 
     static TestResult doExec(String...cmds) {
-        return doExec(null, cmds);
+        return doExec(null, null, cmds);
     }
 
+    static TestResult doExec(Map<String, String> envToSet, String...cmds) {
+        return doExec(envToSet, null, cmds);
+    }
     /*
      * A method which executes a java cmd and returns the results in a container
      */
-    static TestResult doExec(Map<String, String> envToSet, String...cmds) {
+    static TestResult doExec(Map<String, String> envToSet,
+                             Set<String> envToRemove, String...cmds) {
         String cmdStr = "";
         for (String x : cmds) {
             cmdStr = cmdStr.concat(x + " ");
         }
         ProcessBuilder pb = new ProcessBuilder(cmds);
         Map<String, String> env = pb.environment();
+        if (envToRemove != null) {
+            for (String key : envToRemove) {
+                env.remove(key);
+            }
+        }
         if (envToSet != null) {
             env.putAll(envToSet);
         }
--- a/test/tools/launcher/TestSpecialArgs.java	Mon Apr 23 15:13:40 2012 -0700
+++ b/test/tools/launcher/TestSpecialArgs.java	Wed Apr 25 15:54:31 2012 -0700
@@ -23,23 +23,25 @@
 
 /*
  * @test
- * @bug 7124089
- * @summary Checks for MacOSX specific flags are accepted or rejected
- * @compile -XDignore.symbol.file TestHelper.java TestSpecialArgs.java
+ * @bug 7124089 7131021
+ * @summary Checks for MacOSX specific flags are accepted or rejected, and
+ *          MacOSX platforms specific environment is consistent.
+ * @compile -XDignore.symbol.file TestSpecialArgs.java EnvironmentVariables.java
  * @run main TestSpecialArgs
  */
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
-public class TestSpecialArgs {
+public class TestSpecialArgs extends TestHelper {
 
     public static void main(String... args) {
         final Map<String, String> envMap = new HashMap<>();
         envMap.put("_JAVA_LAUNCHER_DEBUG", "true");
 
-        TestHelper.TestResult tr = TestHelper.doExec(envMap,
-                TestHelper.javaCmd, "-XstartOnFirstThread", "-version");
-        if (TestHelper.isMacOSX) {
+        TestResult tr = doExec(envMap, javaCmd, "-XstartOnFirstThread", "-version");
+        if (isMacOSX) {
             if (!tr.contains("In same thread")) {
                 System.out.println(tr);
                 throw new RuntimeException("Error: not running in the same thread ?");
@@ -55,9 +57,8 @@
             }
         }
 
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xdock:/tmp/not-available",
-                "-version");
-        if (TestHelper.isMacOSX) {
+        tr = doExec(javaCmd, "-Xdock:/tmp/not-available", "-version");
+        if (isMacOSX) {
             if (!tr.isOK()) {
                 System.out.println(tr);
                 throw new RuntimeException("Error: arg was rejected ????");
@@ -68,5 +69,36 @@
                 throw new RuntimeException("Error: argument was accepted ????");
             }
         }
+        // MacOSX specific tests ensue......
+        if (!isMacOSX)
+            return;
+        Set<String> envToRemove = new HashSet<>();
+        Map<String, String> map = System.getenv();
+        for (String s : map.keySet()) {
+            if (s.startsWith("JAVA_MAIN_CLASS_")
+                    || s.startsWith("APP_NAME_")
+                    || s.startsWith("APP_ICON_")) {
+                envToRemove.add(s);
+            }
+        }
+        runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
+                "EnvironmentVariables", "JAVA_MAIN_CLASS_*",
+                "EnvironmentVariables");
+
+        runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
+                "-Xdock:name=TestAppName", "EnvironmentVariables",
+                "APP_NAME_*", "TestAppName");
+
+        runTest(envToRemove, javaCmd, "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
+                "-Xdock:icon=TestAppIcon", "EnvironmentVariables",
+                "APP_ICON_*", "TestAppIcon");
+    }
+
+    static void runTest(Set<String> envToRemove, String... args) {
+        TestResult tr = doExec(null, envToRemove, args);
+        if (!tr.isOK()) {
+            System.err.println(tr.toString());
+            throw new RuntimeException("Test Fails");
+        }
     }
 }