8008772: remove gamma launcher

Mon, 06 May 2013 19:49:23 -0700

author
twisti
date
Mon, 06 May 2013 19:49:23 -0700
changeset 5109
aabf54ccedb1
parent 5108
f0bc60565ba8
child 5110
6f3fd5150b67

8008772: remove gamma launcher
Reviewed-by: kvn, neliasso, ctornqvi

make/Makefile file | annotate | diff | comparison | revisions
make/bsd/makefiles/buildtree.make file | annotate | diff | comparison | revisions
make/bsd/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/bsd/makefiles/vm.make file | annotate | diff | comparison | revisions
make/hotspot.script file | annotate | diff | comparison | revisions
make/linux/makefiles/buildtree.make file | annotate | diff | comparison | revisions
make/linux/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/linux/makefiles/vm.make file | annotate | diff | comparison | revisions
make/solaris/makefiles/buildtree.make file | annotate | diff | comparison | revisions
make/solaris/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/solaris/makefiles/vm.make file | annotate | diff | comparison | revisions
make/windows/makefiles/debug.make file | annotate | diff | comparison | revisions
make/windows/makefiles/fastdebug.make file | annotate | diff | comparison | revisions
make/windows/makefiles/launcher.make file | annotate | diff | comparison | revisions
make/windows/makefiles/product.make file | annotate | diff | comparison | revisions
make/windows/makefiles/projectcreator.make file | annotate | diff | comparison | revisions
make/windows/projectfiles/common/Makefile file | annotate | diff | comparison | revisions
src/os/posix/launcher/java_md.c file | annotate | diff | comparison | revisions
src/os/posix/launcher/java_md.h file | annotate | diff | comparison | revisions
src/os/posix/launcher/launcher.script file | annotate | diff | comparison | revisions
src/os/windows/launcher/java_md.c file | annotate | diff | comparison | revisions
src/os/windows/launcher/java_md.h file | annotate | diff | comparison | revisions
src/share/tools/ProjectCreator/BuildConfig.java file | annotate | diff | comparison | revisions
src/share/tools/ProjectCreator/WinGammaPlatformVC10.java file | annotate | diff | comparison | revisions
src/share/tools/launcher/java.c file | annotate | diff | comparison | revisions
src/share/tools/launcher/java.h file | annotate | diff | comparison | revisions
src/share/tools/launcher/jli_util.c file | annotate | diff | comparison | revisions
src/share/tools/launcher/jli_util.h file | annotate | diff | comparison | revisions
src/share/tools/launcher/wildcard.c file | annotate | diff | comparison | revisions
src/share/tools/launcher/wildcard.h file | annotate | diff | comparison | revisions
     1.1 --- a/make/Makefile	Mon May 06 13:53:13 2013 -0700
     1.2 +++ b/make/Makefile	Mon May 06 19:49:23 2013 -0700
     1.3 @@ -151,32 +151,43 @@
     1.4  		      $(MAKE_ARGS) BUILD_FLAVOR=product docs
     1.5  endif
     1.6  
     1.7 +# Output directories
     1.8 +C1_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1
     1.9 +C2_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2
    1.10 +MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1
    1.11 +ZERO_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_zero
    1.12 +SHARK_DIR   =$(OUTPUTDIR)/$(VM_PLATFORM)_shark
    1.13 +
    1.14  # Build variation of hotspot
    1.15  $(C1_VM_TARGETS):
    1.16  	$(CD) $(GAMMADIR)/make; \
    1.17 -	$(MAKE) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
    1.18 +	$(MAKE) BUILD_DIR=$(C1_DIR) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT)
    1.19  
    1.20  $(C2_VM_TARGETS):
    1.21  	$(CD) $(GAMMADIR)/make; \
    1.22 -	$(MAKE) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
    1.23 +	$(MAKE) BUILD_DIR=$(C2_DIR) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT)
    1.24  
    1.25  $(ZERO_VM_TARGETS):
    1.26  	$(CD) $(GAMMADIR)/make; \
    1.27 -	$(MAKE) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ \
    1.28 -	  generic_buildzero $(ALT_OUT)
    1.29 +	$(MAKE) BUILD_DIR=$(ZERO_DIR) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ generic_buildzero $(ALT_OUT)
    1.30  
    1.31  $(SHARK_VM_TARGETS):
    1.32  	$(CD) $(GAMMADIR)/make; \
    1.33 -	$(MAKE) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ \
    1.34 -	  generic_buildshark $(ALT_OUT)
    1.35 +	$(MAKE) BUILD_DIR=$(SHARK_DIR) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ generic_buildshark $(ALT_OUT)
    1.36  
    1.37  $(MINIMAL1_VM_TARGETS):
    1.38  	$(CD) $(GAMMADIR)/make; \
    1.39 -	$(MAKE) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ \
    1.40 -	  generic_buildminimal1 $(ALT_OUT)
    1.41 +	$(MAKE) BUILD_DIR=$(MINIMAL1_DIR) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ generic_buildminimal1 $(ALT_OUT)
    1.42 +
    1.43 +# Install hotspot script in build directory
    1.44 +HOTSPOT_SCRIPT=$(BUILD_DIR)/$(BUILD_FLAVOR)/hotspot
    1.45 +$(HOTSPOT_SCRIPT): $(GAMMADIR)/make/hotspot.script
    1.46 +	$(QUIETLY) $(MKDIR) -p $(BUILD_DIR)/$(BUILD_FLAVOR)
    1.47 +	$(QUIETLY) cat $< | sed -e 's|@@LIBARCH@@|$(LIBARCH)|g' | sed -e 's|@@JDK_IMPORT_PATH@@|$(JDK_IMPORT_PATH)|g' > $@
    1.48 +	$(QUIETLY) chmod +x $@
    1.49  
    1.50  # Build compiler1 (client) rule, different for platforms
    1.51 -generic_build1:
    1.52 +generic_build1: $(HOTSPOT_SCRIPT)
    1.53  	$(MKDIR) -p $(OUTPUTDIR)
    1.54  ifeq ($(OSNAME),windows)
    1.55    ifeq ($(ARCH_DATA_MODEL), 32)
    1.56 @@ -201,7 +212,7 @@
    1.57  endif
    1.58  
    1.59  # Build compiler2 (server) rule, different for platforms
    1.60 -generic_build2:
    1.61 +generic_build2: $(HOTSPOT_SCRIPT)
    1.62  	$(MKDIR) -p $(OUTPUTDIR)
    1.63  ifeq ($(OSNAME),windows)
    1.64  	$(CD) $(OUTPUTDIR); \
    1.65 @@ -217,19 +228,19 @@
    1.66  		      $(MAKE_ARGS) $(VM_TARGET)
    1.67  endif
    1.68  
    1.69 -generic_buildzero:
    1.70 +generic_buildzero: $(HOTSPOT_SCRIPT)
    1.71  	$(MKDIR) -p $(OUTPUTDIR)
    1.72  	$(CD) $(OUTPUTDIR); \
    1.73  		$(MAKE) -f $(ABS_OS_MAKEFILE) \
    1.74  			$(MAKE_ARGS) $(VM_TARGET)
    1.75  
    1.76 -generic_buildshark:
    1.77 +generic_buildshark: $(HOTSPOT_SCRIPT)
    1.78  	$(MKDIR) -p $(OUTPUTDIR)
    1.79  	$(CD) $(OUTPUTDIR); \
    1.80  		$(MAKE) -f $(ABS_OS_MAKEFILE) \
    1.81  			$(MAKE_ARGS) $(VM_TARGET)
    1.82  
    1.83 -generic_buildminimal1:
    1.84 +generic_buildminimal1: $(HOTSPOT_SCRIPT)
    1.85  ifeq ($(JVM_VARIANT_MINIMAL1),true)
    1.86  	$(MKDIR) -p $(OUTPUTDIR)
    1.87    ifeq ($(ARCH_DATA_MODEL), 32)
    1.88 @@ -252,224 +263,210 @@
    1.89  
    1.90  # Export file rule
    1.91  generic_export: $(EXPORT_LIST)
    1.92 +
    1.93  export_product:
    1.94 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
    1.95 -          generic_export
    1.96 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) generic_export
    1.97  export_fastdebug:
    1.98 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
    1.99 -	  EXPORT_SUBDIR=/$(@:export_%=%) \
   1.100 -	  generic_export
   1.101 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
   1.102  export_debug:
   1.103 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
   1.104 -	  EXPORT_SUBDIR=/$(@:export_%=%) \
   1.105 -	  generic_export
   1.106 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
   1.107  export_optimized:
   1.108 -	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) VM_SUBDIR=$(@:export_%=%) \
   1.109 -	  EXPORT_SUBDIR=/$(@:export_%=%) \
   1.110 -	  generic_export
   1.111 +	$(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export
   1.112 +
   1.113  export_product_jdk::
   1.114 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
   1.115 -	  VM_SUBDIR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
   1.116 -	  generic_export
   1.117 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
   1.118  export_optimized_jdk::
   1.119 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
   1.120 -	  VM_SUBDIR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
   1.121 -	  generic_export
   1.122 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export
   1.123  export_fastdebug_jdk::
   1.124 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) \
   1.125 -	  VM_SUBDIR=$(@:export_%_jdk=%)  \
   1.126 -	  ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) \
   1.127 -	  generic_export
   1.128 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
   1.129  export_debug_jdk::
   1.130 -	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) VM_SUBDIR=$(@:export_%_jdk=%) \
   1.131 -	  ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) \
   1.132 -	  generic_export
   1.133 +	$(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export
   1.134  
   1.135  # Export file copy rules
   1.136  XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt
   1.137 -DOCS_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_docs
   1.138 -C1_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1/$(VM_SUBDIR)
   1.139 -C2_DIR      =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2/$(VM_SUBDIR)
   1.140 -MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1/$(VM_SUBDIR)
   1.141 -ZERO_DIR    =$(OUTPUTDIR)/$(VM_PLATFORM)_zero/$(VM_SUBDIR)
   1.142 -SHARK_DIR   =$(OUTPUTDIR)/$(VM_PLATFORM)_shark/$(VM_SUBDIR)
   1.143 +DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs
   1.144 +C1_BUILD_DIR      =$(C1_DIR)/$(BUILD_FLAVOR)
   1.145 +C2_BUILD_DIR      =$(C2_DIR)/$(BUILD_FLAVOR)
   1.146 +MINIMAL1_BUILD_DIR=$(MINIMAL1_DIR)/$(BUILD_FLAVOR)
   1.147 +ZERO_BUILD_DIR    =$(ZERO_DIR)/$(BUILD_FLAVOR)
   1.148 +SHARK_BUILD_DIR   =$(SHARK_DIR)/$(BUILD_FLAVOR)
   1.149  
   1.150  # Server (C2)
   1.151  ifeq ($(JVM_VARIANT_SERVER), true)
   1.152  # Common
   1.153 -$(EXPORT_SERVER_DIR)/%.diz:       		$(C2_DIR)/%.diz
   1.154 +$(EXPORT_SERVER_DIR)/%.diz:       		$(C2_BUILD_DIR)/%.diz
   1.155  	$(install-file)
   1.156 -$(EXPORT_LIB_DIR)/%.jar:			$(C2_DIR)/../generated/%.jar
   1.157 +$(EXPORT_LIB_DIR)/%.jar:			$(C2_BUILD_DIR)/../generated/%.jar
   1.158  	$(install-file)
   1.159 -$(EXPORT_INCLUDE_DIR)/%:			$(C2_DIR)/../generated/jvmtifiles/%
   1.160 +$(EXPORT_INCLUDE_DIR)/%:			$(C2_BUILD_DIR)/../generated/jvmtifiles/%
   1.161  	$(install-file)
   1.162  # Windows
   1.163 -$(EXPORT_SERVER_DIR)/%.dll:			$(C2_DIR)/%.dll
   1.164 +$(EXPORT_SERVER_DIR)/%.dll:			$(C2_BUILD_DIR)/%.dll
   1.165  	$(install-file)
   1.166 -$(EXPORT_SERVER_DIR)/%.pdb:			$(C2_DIR)/%.pdb
   1.167 +$(EXPORT_SERVER_DIR)/%.pdb:			$(C2_BUILD_DIR)/%.pdb
   1.168  	$(install-file)
   1.169 -$(EXPORT_SERVER_DIR)/%.map:			$(C2_DIR)/%.map
   1.170 +$(EXPORT_SERVER_DIR)/%.map:			$(C2_BUILD_DIR)/%.map
   1.171  	$(install-file)
   1.172 -$(EXPORT_LIB_DIR)/%.lib:			$(C2_DIR)/%.lib
   1.173 +$(EXPORT_LIB_DIR)/%.lib:			$(C2_BUILD_DIR)/%.lib
   1.174  	$(install-file)
   1.175 -$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C2_DIR)/%.diz
   1.176 +$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C2_BUILD_DIR)/%.diz
   1.177  	$(install-file)
   1.178 -$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C2_DIR)/%.dll
   1.179 +$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C2_BUILD_DIR)/%.dll
   1.180  	$(install-file)
   1.181 -$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C2_DIR)/%.pdb
   1.182 +$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C2_BUILD_DIR)/%.pdb
   1.183  	$(install-file)
   1.184 -$(EXPORT_JRE_BIN_DIR)/%.map:			$(C2_DIR)/%.map
   1.185 +$(EXPORT_JRE_BIN_DIR)/%.map:			$(C2_BUILD_DIR)/%.map
   1.186  	$(install-file)
   1.187  # Unix
   1.188 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_DIR)/%.$(LIBRARY_SUFFIX)
   1.189 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.190  	$(install-file)
   1.191 -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_DIR)/%.$(LIBRARY_SUFFIX)
   1.192 +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.193  	$(install-file)
   1.194 -$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_DIR)/%.$(LIBRARY_SUFFIX)
   1.195 +$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.196  	$(install-file)
   1.197 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C2_DIR)/%.debuginfo
   1.198 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C2_BUILD_DIR)/%.debuginfo
   1.199  	$(install-file)
   1.200 -$(EXPORT_SERVER_DIR)/%.debuginfo:       	$(C2_DIR)/%.debuginfo
   1.201 +$(EXPORT_SERVER_DIR)/%.debuginfo:       	$(C2_BUILD_DIR)/%.debuginfo
   1.202  	$(install-file)
   1.203 -$(EXPORT_SERVER_DIR)/64/%.debuginfo:    	$(C2_DIR)/%.debuginfo
   1.204 +$(EXPORT_SERVER_DIR)/64/%.debuginfo:    	$(C2_BUILD_DIR)/%.debuginfo
   1.205  	$(install-file)
   1.206 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C2_DIR)/%.diz
   1.207 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C2_BUILD_DIR)/%.diz
   1.208  	$(install-file)
   1.209 -$(EXPORT_SERVER_DIR)/64/%.diz:    		$(C2_DIR)/%.diz
   1.210 +$(EXPORT_SERVER_DIR)/64/%.diz:    		$(C2_BUILD_DIR)/%.diz
   1.211  	$(install-file)
   1.212  endif
   1.213  
   1.214  # Client (C1)
   1.215  ifeq ($(JVM_VARIANT_CLIENT), true)
   1.216  # Common
   1.217 -$(EXPORT_CLIENT_DIR)/%.diz:       		$(C1_DIR)/%.diz
   1.218 +$(EXPORT_CLIENT_DIR)/%.diz:       		$(C1_BUILD_DIR)/%.diz
   1.219  	$(install-file)
   1.220 -$(EXPORT_LIB_DIR)/%.jar:			$(C1_DIR)/../generated/%.jar
   1.221 +$(EXPORT_LIB_DIR)/%.jar:			$(C1_BUILD_DIR)/../generated/%.jar
   1.222  	$(install-file)
   1.223 -$(EXPORT_INCLUDE_DIR)/%:			$(C1_DIR)/../generated/jvmtifiles/%
   1.224 +$(EXPORT_INCLUDE_DIR)/%:			$(C1_BUILD_DIR)/../generated/jvmtifiles/%
   1.225  	$(install-file)
   1.226  # Windows
   1.227 -$(EXPORT_CLIENT_DIR)/%.dll:			$(C1_DIR)/%.dll
   1.228 +$(EXPORT_CLIENT_DIR)/%.dll:			$(C1_BUILD_DIR)/%.dll
   1.229  	$(install-file)
   1.230 -$(EXPORT_CLIENT_DIR)/%.pdb:			$(C1_DIR)/%.pdb
   1.231 +$(EXPORT_CLIENT_DIR)/%.pdb:			$(C1_BUILD_DIR)/%.pdb
   1.232  	$(install-file)
   1.233 -$(EXPORT_CLIENT_DIR)/%.map:			$(C1_DIR)/%.map
   1.234 +$(EXPORT_CLIENT_DIR)/%.map:			$(C1_BUILD_DIR)/%.map
   1.235  	$(install-file)
   1.236 -$(EXPORT_LIB_DIR)/%.lib:			$(C1_DIR)/%.lib
   1.237 +$(EXPORT_LIB_DIR)/%.lib:			$(C1_BUILD_DIR)/%.lib
   1.238  	$(install-file)
   1.239 -$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C1_DIR)/%.diz
   1.240 +$(EXPORT_JRE_BIN_DIR)/%.diz:			$(C1_BUILD_DIR)/%.diz
   1.241  	$(install-file)
   1.242 -$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C1_DIR)/%.dll
   1.243 +$(EXPORT_JRE_BIN_DIR)/%.dll:			$(C1_BUILD_DIR)/%.dll
   1.244  	$(install-file)
   1.245 -$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C1_DIR)/%.pdb
   1.246 +$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(C1_BUILD_DIR)/%.pdb
   1.247  	$(install-file)
   1.248 -$(EXPORT_JRE_BIN_DIR)/%.map:			$(C1_DIR)/%.map
   1.249 +$(EXPORT_JRE_BIN_DIR)/%.map:			$(C1_BUILD_DIR)/%.map
   1.250  	$(install-file)
   1.251  # Unix
   1.252 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_DIR)/%.$(LIBRARY_SUFFIX)
   1.253 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.254  	$(install-file)
   1.255 -$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_DIR)/%.$(LIBRARY_SUFFIX)
   1.256 +$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX):       $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.257  	$(install-file)
   1.258 -$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_DIR)/%.$(LIBRARY_SUFFIX)
   1.259 +$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX):    $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.260  	$(install-file)
   1.261 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C1_DIR)/%.debuginfo
   1.262 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo: 	$(C1_BUILD_DIR)/%.debuginfo
   1.263  	$(install-file)
   1.264 -$(EXPORT_CLIENT_DIR)/%.debuginfo:       	$(C1_DIR)/%.debuginfo
   1.265 +$(EXPORT_CLIENT_DIR)/%.debuginfo:       	$(C1_BUILD_DIR)/%.debuginfo
   1.266  	$(install-file)
   1.267 -$(EXPORT_CLIENT_DIR)/64/%.debuginfo:    	$(C1_DIR)/%.debuginfo
   1.268 +$(EXPORT_CLIENT_DIR)/64/%.debuginfo:    	$(C1_BUILD_DIR)/%.debuginfo
   1.269  	$(install-file)
   1.270 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C1_DIR)/%.diz
   1.271 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz: 		$(C1_BUILD_DIR)/%.diz
   1.272  	$(install-file)
   1.273 -$(EXPORT_CLIENT_DIR)/64/%.diz:    		$(C1_DIR)/%.diz
   1.274 +$(EXPORT_CLIENT_DIR)/64/%.diz:    		$(C1_BUILD_DIR)/%.diz
   1.275  	$(install-file)
   1.276  endif
   1.277  
   1.278  # Minimal1
   1.279  ifeq ($(JVM_VARIANT_MINIMAL1), true)
   1.280  # Common
   1.281 -$(EXPORT_MINIMAL_DIR)/%.diz:			$(MINIMAL1_DIR)/%.diz
   1.282 +$(EXPORT_MINIMAL_DIR)/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
   1.283  	$(install-file)
   1.284 -$(EXPORT_LIB_DIR)/%.jar:			$(MINIMAL1_DIR)/../generated/%.jar
   1.285 +$(EXPORT_LIB_DIR)/%.jar:			$(MINIMAL1_BUILD_DIR)/../generated/%.jar
   1.286  	$(install-file)
   1.287 -$(EXPORT_INCLUDE_DIR)/%:			$(MINIMAL1_DIR)/../generated/jvmtifiles/%
   1.288 +$(EXPORT_INCLUDE_DIR)/%:			$(MINIMAL1_BUILD_DIR)/../generated/jvmtifiles/%
   1.289  	$(install-file)
   1.290  # Windows
   1.291 -$(EXPORT_MINIMAL_DIR)/%.dll:			$(MINIMAL1_DIR)/%.dll
   1.292 +$(EXPORT_MINIMAL_DIR)/%.dll:			$(MINIMAL1_BUILD_DIR)/%.dll
   1.293  	$(install-file)
   1.294 -$(EXPORT_MINIMAL_DIR)/%.pdb:			$(MINIMAL1_DIR)/%.pdb
   1.295 +$(EXPORT_MINIMAL_DIR)/%.pdb:			$(MINIMAL1_BUILD_DIR)/%.pdb
   1.296  	$(install-file)
   1.297 -$(EXPORT_MINIMAL_DIR)/%.map:			$(MINIMAL1_DIR)/%.map
   1.298 +$(EXPORT_MINIMAL_DIR)/%.map:			$(MINIMAL1_BUILD_DIR)/%.map
   1.299  	$(install-file)
   1.300 -$(EXPORT_LIB_DIR)/%.lib:			$(MINIMAL1_DIR)/%.lib
   1.301 +$(EXPORT_LIB_DIR)/%.lib:			$(MINIMAL1_BUILD_DIR)/%.lib
   1.302  	$(install-file)
   1.303 -$(EXPORT_JRE_BIN_DIR)/%.diz:			$(MINIMAL1_DIR)/%.diz
   1.304 +$(EXPORT_JRE_BIN_DIR)/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
   1.305  	$(install-file)
   1.306 -$(EXPORT_JRE_BIN_DIR)/%.dll:			$(MINIMAL1_DIR)/%.dll
   1.307 +$(EXPORT_JRE_BIN_DIR)/%.dll:			$(MINIMAL1_BUILD_DIR)/%.dll
   1.308  	$(install-file)
   1.309 -$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(MINIMAL1_DIR)/%.pdb
   1.310 +$(EXPORT_JRE_BIN_DIR)/%.pdb:			$(MINIMAL1_BUILD_DIR)/%.pdb
   1.311  	$(install-file)
   1.312 -$(EXPORT_JRE_BIN_DIR)/%.map:			$(MINIMAL1_DIR)/%.map
   1.313 +$(EXPORT_JRE_BIN_DIR)/%.map:			$(MINIMAL1_BUILD_DIR)/%.map
   1.314  	$(install-file)
   1.315  # Unix
   1.316 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
   1.317 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.318  	$(install-file)
   1.319 -$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
   1.320 +$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.321  	$(install-file)
   1.322 -$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_DIR)/%.$(LIBRARY_SUFFIX)
   1.323 +$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX):	$(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.324  	$(install-file)
   1.325 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(MINIMAL1_DIR)/%.debuginfo
   1.326 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
   1.327  	$(install-file)
   1.328 -$(EXPORT_MINIMAL_DIR)/%.debuginfo:		$(MINIMAL1_DIR)/%.debuginfo
   1.329 +$(EXPORT_MINIMAL_DIR)/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
   1.330  	$(install-file)
   1.331 -$(EXPORT_MINIMAL_DIR)/64/%.debuginfo:		$(MINIMAL1_DIR)/%.debuginfo
   1.332 +$(EXPORT_MINIMAL_DIR)/64/%.debuginfo:		$(MINIMAL1_BUILD_DIR)/%.debuginfo
   1.333  	$(install-file)
   1.334 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(MINIMAL1_DIR)/%.diz
   1.335 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(MINIMAL1_BUILD_DIR)/%.diz
   1.336  	$(install-file)
   1.337 -$(EXPORT_MINIMAL_DIR)/64/%.diz:			$(MINIMAL1_DIR)/%.diz
   1.338 +$(EXPORT_MINIMAL_DIR)/64/%.diz:			$(MINIMAL1_BUILD_DIR)/%.diz
   1.339  	$(install-file)
   1.340  endif
   1.341  
   1.342  # Zero
   1.343  ifeq ($(JVM_VARIANT_ZERO), true)
   1.344  # Common
   1.345 -$(EXPORT_LIB_DIR)/%.jar:			$(ZERO_DIR)/../generated/%.jar
   1.346 +$(EXPORT_LIB_DIR)/%.jar:			$(ZERO_BUILD_DIR)/../generated/%.jar
   1.347  	$(install-file)
   1.348 -$(EXPORT_INCLUDE_DIR)/%:			$(ZERO_DIR)/../generated/jvmtifiles/%
   1.349 +$(EXPORT_INCLUDE_DIR)/%:			$(ZERO_BUILD_DIR)/../generated/jvmtifiles/%
   1.350  	$(install-file)
   1.351  # Unix
   1.352 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
   1.353 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.354  	$(install-file)
   1.355 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(ZERO_DIR)/%.debuginfo
   1.356 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo:		$(ZERO_BUILD_DIR)/%.debuginfo
   1.357  	$(install-file)
   1.358 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(ZERO_DIR)/%.diz
   1.359 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(ZERO_BUILD_DIR)/%.diz
   1.360  	$(install-file)
   1.361 -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_DIR)/%.$(LIBRARY_SUFFIX)
   1.362 +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.363  	$(install-file)
   1.364 -$(EXPORT_SERVER_DIR)/%.debuginfo:		$(ZERO_DIR)/%.debuginfo
   1.365 +$(EXPORT_SERVER_DIR)/%.debuginfo:		$(ZERO_BUILD_DIR)/%.debuginfo
   1.366  	$(install-file)
   1.367 -$(EXPORT_SERVER_DIR)/%.diz:			$(ZERO_DIR)/%.diz
   1.368 +$(EXPORT_SERVER_DIR)/%.diz:			$(ZERO_BUILD_DIR)/%.diz
   1.369  	$(install-file)
   1.370  endif
   1.371  
   1.372  # Shark
   1.373  ifeq ($(JVM_VARIANT_ZEROSHARK), true)
   1.374  # Common
   1.375 -$(EXPORT_LIB_DIR)/%.jar:			$(SHARK_DIR)/../generated/%.jar
   1.376 +$(EXPORT_LIB_DIR)/%.jar:			$(SHARK_BUILD_DIR)/../generated/%.jar
   1.377  	$(install-file)
   1.378 -$(EXPORT_INCLUDE_DIR)/%:			$(SHARK_DIR)/../generated/jvmtifiles/%
   1.379 +$(EXPORT_INCLUDE_DIR)/%:			$(SHARK_BUILD_DIR)/../generated/jvmtifiles/%
   1.380  	$(install-file)
   1.381  # Unix
   1.382 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
   1.383 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.384  	$(install-file)
   1.385 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo):	$(SHARK_DIR)/%.debuginfo
   1.386 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.debuginfo):	$(SHARK_BUILD_DIR)/%.debuginfo
   1.387  	$(install-file)
   1.388 -$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(SHARK_DIR)/%.diz
   1.389 +$(EXPORT_JRE_LIB_ARCH_DIR)/%.diz:		$(SHARK_BUILD_DIR)/%.diz
   1.390  	$(install-file)
   1.391 -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_DIR)/%.$(LIBRARY_SUFFIX)
   1.392 +$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX):       $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX)
   1.393  	$(install-file)
   1.394 -$(EXPORT_SERVER_DIR)/%.debuginfo:		$(SHARK_DIR)/%.debuginfo
   1.395 +$(EXPORT_SERVER_DIR)/%.debuginfo:		$(SHARK_BUILD_DIR)/%.debuginfo
   1.396  	$(install-file)
   1.397 -$(EXPORT_SERVER_DIR)/%.diz:			$(SHARK_DIR)/%.diz
   1.398 +$(EXPORT_SERVER_DIR)/%.diz:			$(SHARK_BUILD_DIR)/%.diz
   1.399  	$(install-file)
   1.400  endif
   1.401  
     2.1 --- a/make/bsd/makefiles/buildtree.make	Mon May 06 13:53:13 2013 -0700
     2.2 +++ b/make/bsd/makefiles/buildtree.make	Mon May 06 19:49:23 2013 -0700
     2.3 @@ -49,7 +49,6 @@
     2.4  # adlc.make	-
     2.5  # jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
     2.6  # sa.make	- generate SA jar file and natives
     2.7 -# env.[ck]sh	- environment settings
     2.8  #
     2.9  # The makefiles are split this way so that "make foo" will run faster by not
    2.10  # having to read the dependency files for the vm.
    2.11 @@ -129,9 +128,7 @@
    2.12  BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
    2.13  
    2.14  # dtrace.make is used on BSD versions that implement Dtrace (like MacOS X)
    2.15 -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make \
    2.16 -	jvmti.make sa.make dtrace.make \
    2.17 -        env.sh env.csh jdkpath.sh
    2.18 +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make dtrace.make
    2.19  
    2.20  BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
    2.21  	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
    2.22 @@ -354,33 +351,6 @@
    2.23  	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
    2.24  	) > $@
    2.25  
    2.26 -env.sh: $(BUILDTREE_MAKE)
    2.27 -	@echo Creating $@ ...
    2.28 -	$(QUIETLY) ( \
    2.29 -	$(BUILDTREE_COMMENT); \
    2.30 -	{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
    2.31 -	{ \
    2.32 -	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
    2.33 -	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
    2.34 -	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
    2.35 -	echo "export JAVA_HOME CLASSPATH HOTSPOT_BUILD_USER"; \
    2.36 -	) > $@
    2.37 -
    2.38 -env.csh: env.sh
    2.39 -	@echo Creating $@ ...
    2.40 -	$(QUIETLY) ( \
    2.41 -	$(BUILDTREE_COMMENT); \
    2.42 -	{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
    2.43 -	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
    2.44 -	) > $@
    2.45 -
    2.46 -jdkpath.sh: $(BUILDTREE_MAKE)
    2.47 -	@echo Creating $@ ...
    2.48 -	$(QUIETLY) ( \
    2.49 -	$(BUILDTREE_COMMENT); \
    2.50 -	echo "JDK=${JAVA_HOME}"; \
    2.51 -	) > $@
    2.52 -
    2.53  FORCE:
    2.54  
    2.55  .PHONY:  all FORCE
     3.1 --- a/make/bsd/makefiles/launcher.make	Mon May 06 13:53:13 2013 -0700
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,115 +0,0 @@
     3.4 -#
     3.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     3.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 -#
     3.8 -# This code is free software; you can redistribute it and/or modify it
     3.9 -# under the terms of the GNU General Public License version 2 only, as
    3.10 -# published by the Free Software Foundation.
    3.11 -#
    3.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 -# version 2 for more details (a copy is included in the LICENSE file that
    3.16 -# accompanied this code).
    3.17 -#
    3.18 -# You should have received a copy of the GNU General Public License version
    3.19 -# 2 along with this work; if not, write to the Free Software Foundation,
    3.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 -#
    3.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 -# or visit www.oracle.com if you need additional information or have any
    3.24 -# questions.
    3.25 -#
    3.26 -#
    3.27 -
    3.28 -# Rules to build gamma launcher, used by vm.make
    3.29 -
    3.30 -
    3.31 -LAUNCHER_SCRIPT = hotspot
    3.32 -LAUNCHER   = gamma
    3.33 -
    3.34 -LAUNCHERDIR   := $(GAMMADIR)/src/os/posix/launcher
    3.35 -LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
    3.36 -LAUNCHERFLAGS := $(ARCHFLAG) \
    3.37 -                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
    3.38 -                -I$(LAUNCHERDIR_SHARE) \
    3.39 -                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
    3.40 -                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
    3.41 -                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
    3.42 -                -DARCH=\"$(LIBARCH)\" \
    3.43 -                -DGAMMA \
    3.44 -                -DLAUNCHER_TYPE=\"gamma\" \
    3.45 -                -DLINK_INTO_$(LINK_INTO) \
    3.46 -                $(TARGET_DEFINES)
    3.47 -# Give the launcher task_for_pid() privileges so that it can be used to run JStack, JInfo, et al.
    3.48 -LFLAGS_LAUNCHER += -sectcreate __TEXT __info_plist $(GAMMADIR)/src/os/bsd/launcher/Info-privileged.plist
    3.49 -
    3.50 -ifeq ($(LINK_INTO),AOUT)
    3.51 -  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
    3.52 -  LAUNCHER_MAPFILE           = mapfile_reorder
    3.53 -  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
    3.54 -  LFLAGS_LAUNCHER           += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
    3.55 -  LIBS_LAUNCHER             += $(STATIC_STDCXX) $(LIBS)
    3.56 -else
    3.57 -  LAUNCHER.o                 = launcher.o
    3.58 -  LFLAGS_LAUNCHER           += -L`pwd`
    3.59 -
    3.60 -  # The gamma launcher runs the JDK from $JAVA_HOME, overriding the JVM with a
    3.61 -  # freshly built JVM at ./libjvm.{so|dylib}.  This is accomplished by setting
    3.62 -  # the library searchpath using ({DY}LD_LIBRARY_PATH) to find the local JVM
    3.63 -  # first.  Gamma dlopen()s libjava from $JAVA_HOME/jre/lib{/$arch}, which is
    3.64 -  # statically linked with CoreFoundation framework libs. Unfortunately, gamma's
    3.65 -  # unique searchpath results in some unresolved symbols in the framework
    3.66 -  # libraries, because JDK libraries are inadvertently discovered first on the
    3.67 -  # searchpath, e.g. libjpeg.  On Mac OS X, filenames are case *insensitive*.
    3.68 -  # So, the actual filename collision is libjpeg.dylib and libJPEG.dylib.
    3.69 -  # To resolve this, gamma needs to also statically link with the CoreFoundation
    3.70 -  # framework libraries.
    3.71 -
    3.72 -  ifeq ($(OS_VENDOR),Darwin)
    3.73 -    LFLAGS_LAUNCHER         += -framework CoreFoundation
    3.74 -  endif
    3.75 -
    3.76 -  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
    3.77 -endif
    3.78 -
    3.79 -LINK_LAUNCHER = $(LINK.CC)
    3.80 -
    3.81 -LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
    3.82 -LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
    3.83 -
    3.84 -LAUNCHER_OUT = launcher
    3.85 -
    3.86 -SUFFIXES += .d
    3.87 -
    3.88 -SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
    3.89 -SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
    3.90 -
    3.91 -OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
    3.92 -
    3.93 -DEPFILES := $(patsubst %.o,%.d,$(OBJS))
    3.94 --include $(DEPFILES)
    3.95 -
    3.96 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
    3.97 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
    3.98 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
    3.99 -
   3.100 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
   3.101 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
   3.102 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
   3.103 -
   3.104 -$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
   3.105 -	$(QUIETLY) echo Linking launcher...
   3.106 -	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
   3.107 -	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
   3.108 -	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
   3.109 -	# Sign the launcher with the development certificate (if present) so that it can be used
   3.110 -	# to run JStack, JInfo, et al.
   3.111 -	$(QUIETLY) -codesign -s openjdk_codesign $@
   3.112 -
   3.113 -$(LAUNCHER): $(LAUNCHER_SCRIPT)
   3.114 -
   3.115 -$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
   3.116 -	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
   3.117 -	$(QUIETLY) chmod +x $@
   3.118 -
     4.1 --- a/make/bsd/makefiles/vm.make	Mon May 06 13:53:13 2013 -0700
     4.2 +++ b/make/bsd/makefiles/vm.make	Mon May 06 19:49:23 2013 -0700
     4.3 @@ -328,9 +328,6 @@
     4.4  #----------------------------------------------------------------------
     4.5  # Other files
     4.6  
     4.7 -# Gamma launcher
     4.8 -include $(MAKEFILES_DIR)/launcher.make
     4.9 -
    4.10  # Signal interposition library
    4.11  include $(MAKEFILES_DIR)/jsig.make
    4.12  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/make/hotspot.script	Mon May 06 19:49:23 2013 -0700
     5.3 @@ -0,0 +1,218 @@
     5.4 +#!/bin/sh
     5.5 +
     5.6 +# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
     5.7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.8 +#
     5.9 +# This code is free software; you can redistribute it and/or modify it
    5.10 +# under the terms of the GNU General Public License version 2 only, as
    5.11 +# published by the Free Software Foundation.
    5.12 +#
    5.13 +# This code is distributed in the hope that it will be useful, but WITHOUT
    5.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.15 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.16 +# version 2 for more details (a copy is included in the LICENSE file that
    5.17 +# accompanied this code).
    5.18 +#
    5.19 +# You should have received a copy of the GNU General Public License version
    5.20 +# 2 along with this work; if not, write to the Free Software Foundation,
    5.21 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.22 +#
    5.23 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.24 +# or visit www.oracle.com if you need additional information or have any
    5.25 +# questions.
    5.26 +
    5.27 +
    5.28 +# This script launches HotSpot.
    5.29 +#
    5.30 +# If the first parameter is either "-gdb" or "-gud", HotSpot will be
    5.31 +# launched inside gdb. "-gud" means "open an Emacs window and run gdb
    5.32 +# inside Emacs".
    5.33 +#
    5.34 +# If the first parameter is "-dbx", HotSpot will be launched inside dbx.
    5.35 +#
    5.36 +# If the first parameter is "-valgrind", HotSpot will be launched
    5.37 +# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
    5.38 +# and with memory leak detection enabled.  This currently (2005jan19)
    5.39 +# requires at least Valgrind 2.3.0.  -Xmx16m will also be passed as
    5.40 +# the first parameter to HotSpot, since lowering HotSpot's memory
    5.41 +# consumption makes execution inside of Valgrind *a lot* faster.
    5.42 +#
    5.43 +
    5.44 +
    5.45 +#
    5.46 +# User changeable parameters ------------------------------------------------
    5.47 +#
    5.48 +
    5.49 +# This is the name of the gdb binary to use
    5.50 +if [ ! "$GDB" ]
    5.51 +then
    5.52 +    GDB=gdb
    5.53 +fi
    5.54 +
    5.55 +# This is the name of the gdb binary to use
    5.56 +if [ ! "$DBX" ]
    5.57 +then
    5.58 +    DBX=dbx
    5.59 +fi
    5.60 +
    5.61 +# This is the name of the Valgrind binary to use
    5.62 +if [ ! "$VALGRIND" ]
    5.63 +then
    5.64 +    VALGRIND=valgrind
    5.65 +fi
    5.66 +
    5.67 +# This is the name of Emacs for running GUD
    5.68 +EMACS=emacs
    5.69 +
    5.70 +#
    5.71 +# End of user changeable parameters -----------------------------------------
    5.72 +#
    5.73 +
    5.74 +# Make sure the paths are fully specified, i.e. they must begin with /.
    5.75 +REL_MYDIR=`dirname $0`
    5.76 +MYDIR=`cd $REL_MYDIR && pwd`
    5.77 +
    5.78 +#
    5.79 +# Look whether the user wants to run inside gdb
    5.80 +case "$1" in
    5.81 +    -gdb)
    5.82 +        MODE=gdb
    5.83 +        shift
    5.84 +        ;;
    5.85 +    -gud)
    5.86 +        MODE=gud
    5.87 +        shift
    5.88 +        ;;
    5.89 +    -dbx)
    5.90 +        MODE=dbx
    5.91 +        shift
    5.92 +        ;;
    5.93 +    -valgrind)
    5.94 +        MODE=valgrind
    5.95 +        shift
    5.96 +        ;;
    5.97 +    *)
    5.98 +        MODE=run
    5.99 +        ;;
   5.100 +esac
   5.101 +
   5.102 +if [ "${ALT_JAVA_HOME}" != "" ]; then
   5.103 +    JDK=${ALT_JAVA_HOME%%/jre}
   5.104 +else
   5.105 +    JDK=@@JDK_IMPORT_PATH@@
   5.106 +fi
   5.107 +
   5.108 +if [ "${JDK}" = "" ]; then
   5.109 +    echo "Failed to find JDK.  Either ALT_JAVA_HOME is not set or JDK_IMPORT_PATH is empty."
   5.110 +fi
   5.111 +
   5.112 +# We will set the LD_LIBRARY_PATH as follows:
   5.113 +#     o		$JVMPATH (directory portion only)
   5.114 +#     o		$JRE/lib/$ARCH
   5.115 +# followed by the user's previous effective LD_LIBRARY_PATH, if
   5.116 +# any.
   5.117 +JRE=$JDK/jre
   5.118 +JAVA_HOME=$JDK
   5.119 +export JAVA_HOME
   5.120 +
   5.121 +ARCH=@@LIBARCH@@
   5.122 +SBP=${MYDIR}:${JRE}/lib/${ARCH}
   5.123 +
   5.124 +
   5.125 +# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
   5.126 +OS=`uname -s`
   5.127 +if [ "${OS}" = "Darwin" ]
   5.128 +then
   5.129 +    if [ -z "$DYLD_LIBRARY_PATH" ]
   5.130 +    then
   5.131 +        DYLD_LIBRARY_PATH="$SBP"
   5.132 +    else
   5.133 +        DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
   5.134 +    fi
   5.135 +    export DYLD_LIBRARY_PATH
   5.136 +else
   5.137 +    # not 'Darwin'
   5.138 +    if [ -z "$LD_LIBRARY_PATH" ]
   5.139 +    then
   5.140 +        LD_LIBRARY_PATH="$SBP"
   5.141 +    else
   5.142 +        LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
   5.143 +    fi
   5.144 +    export LD_LIBRARY_PATH
   5.145 +fi
   5.146 +
   5.147 +JPARMS="-Dsun.java.launcher=gamma -XXaltjvm=$MYDIR $@ $JAVA_ARGS";
   5.148 +
   5.149 +# Locate the java launcher
   5.150 +LAUNCHER=$JDK/bin/java
   5.151 +if [ ! -x $LAUNCHER ] ; then
   5.152 +    echo Error: Cannot find the java launcher \"$LAUNCHER\"
   5.153 +    exit 1
   5.154 +fi
   5.155 +
   5.156 +GDBSRCDIR=$MYDIR
   5.157 +BASEDIR=`cd $MYDIR/../../.. && pwd`
   5.158 +
   5.159 +init_gdb() {
   5.160 +# Create a gdb script in case we should run inside gdb
   5.161 +    GDBSCR=/tmp/hsl.$$
   5.162 +    rm -f $GDBSCR
   5.163 +    cat >>$GDBSCR <<EOF
   5.164 +cd `pwd`
   5.165 +handle SIGUSR1 nostop noprint
   5.166 +handle SIGUSR2 nostop noprint
   5.167 +set args $JPARMS
   5.168 +file $LAUNCHER
   5.169 +directory $GDBSRCDIR
   5.170 +# Get us to a point where we can set breakpoints in libjvm.so
   5.171 +set breakpoint pending on
   5.172 +break JNI_CreateJavaVM
   5.173 +run
   5.174 +# Stop in JNI_CreateJavaVM
   5.175 +delete 1
   5.176 +# We can now set breakpoints wherever we like
   5.177 +EOF
   5.178 +}
   5.179 +
   5.180 +
   5.181 +case "$MODE" in
   5.182 +    gdb)
   5.183 +	init_gdb
   5.184 +        $GDB -x $GDBSCR
   5.185 +	rm -f $GDBSCR
   5.186 +        ;;
   5.187 +    gud)
   5.188 +	init_gdb
   5.189 +# First find out what emacs version we're using, so that we can
   5.190 +# use the new pretty GDB mode if emacs -version >= 22.1
   5.191 +	case `$EMACS -version 2> /dev/null` in
   5.192 +	    *GNU\ Emacs\ 2[23]*)
   5.193 +	    emacs_gud_cmd="gdba"
   5.194 +	    emacs_gud_args="--annotate=3"
   5.195 +	    ;;
   5.196 +	    *)
   5.197 +		emacs_gud_cmd="gdb"
   5.198 +		emacs_gud_args=
   5.199 +		;;
   5.200 +	esac
   5.201 +        $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
   5.202 +	rm -f $GDBSCR
   5.203 +        ;;
   5.204 +    dbx)
   5.205 +        $DBX -s $HOME/.dbxrc -c "loadobject -load libjvm.so; stop in JNI_CreateJavaVM; run $JPARMS; delete all" $LAUNCHER
   5.206 +        ;;
   5.207 +    valgrind)
   5.208 +        echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
   5.209 +        echo
   5.210 +        $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
   5.211 +        ;;
   5.212 +    run)
   5.213 +        LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
   5.214 +        ;;
   5.215 +    *)
   5.216 +        echo Error: Internal error, unknown launch mode \"$MODE\"
   5.217 +        exit 1
   5.218 +        ;;
   5.219 +esac
   5.220 +RETVAL=$?
   5.221 +exit $RETVAL
     6.1 --- a/make/linux/makefiles/buildtree.make	Mon May 06 13:53:13 2013 -0700
     6.2 +++ b/make/linux/makefiles/buildtree.make	Mon May 06 19:49:23 2013 -0700
     6.3 @@ -49,7 +49,6 @@
     6.4  # adlc.make	-
     6.5  # jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
     6.6  # sa.make	- generate SA jar file and natives
     6.7 -# env.[ck]sh	- environment settings
     6.8  #
     6.9  # The makefiles are split this way so that "make foo" will run faster by not
    6.10  # having to read the dependency files for the vm.
    6.11 @@ -123,8 +122,7 @@
    6.12  # For dependencies and recursive makes.
    6.13  BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
    6.14  
    6.15 -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
    6.16 -        env.sh env.csh jdkpath.sh
    6.17 +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make
    6.18  
    6.19  BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
    6.20  	SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
    6.21 @@ -349,33 +347,6 @@
    6.22  	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
    6.23  	) > $@
    6.24  
    6.25 -env.sh: $(BUILDTREE_MAKE)
    6.26 -	@echo Creating $@ ...
    6.27 -	$(QUIETLY) ( \
    6.28 -	$(BUILDTREE_COMMENT); \
    6.29 -	{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
    6.30 -	{ \
    6.31 -	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
    6.32 -	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
    6.33 -	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
    6.34 -	echo "export JAVA_HOME CLASSPATH HOTSPOT_BUILD_USER"; \
    6.35 -	) > $@
    6.36 -
    6.37 -env.csh: env.sh
    6.38 -	@echo Creating $@ ...
    6.39 -	$(QUIETLY) ( \
    6.40 -	$(BUILDTREE_COMMENT); \
    6.41 -	{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
    6.42 -	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
    6.43 -	) > $@
    6.44 -
    6.45 -jdkpath.sh: $(BUILDTREE_MAKE)
    6.46 -	@echo Creating $@ ...
    6.47 -	$(QUIETLY) ( \
    6.48 -	$(BUILDTREE_COMMENT); \
    6.49 -	echo "JDK=${JAVA_HOME}"; \
    6.50 -	) > $@
    6.51 -
    6.52  FORCE:
    6.53  
    6.54  .PHONY:  all FORCE
     7.1 --- a/make/linux/makefiles/launcher.make	Mon May 06 13:53:13 2013 -0700
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,93 +0,0 @@
     7.4 -#
     7.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     7.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 -#
     7.8 -# This code is free software; you can redistribute it and/or modify it
     7.9 -# under the terms of the GNU General Public License version 2 only, as
    7.10 -# published by the Free Software Foundation.
    7.11 -#
    7.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
    7.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.15 -# version 2 for more details (a copy is included in the LICENSE file that
    7.16 -# accompanied this code).
    7.17 -#
    7.18 -# You should have received a copy of the GNU General Public License version
    7.19 -# 2 along with this work; if not, write to the Free Software Foundation,
    7.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.21 -#
    7.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.23 -# or visit www.oracle.com if you need additional information or have any
    7.24 -# questions.
    7.25 -#  
    7.26 -#
    7.27 -
    7.28 -# Rules to build gamma launcher, used by vm.make
    7.29 -
    7.30 -
    7.31 -LAUNCHER_SCRIPT = hotspot
    7.32 -LAUNCHER   = gamma
    7.33 -
    7.34 -LAUNCHERDIR   := $(GAMMADIR)/src/os/posix/launcher
    7.35 -LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
    7.36 -LAUNCHERFLAGS := $(ARCHFLAG) \
    7.37 -                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
    7.38 -                -I$(LAUNCHERDIR_SHARE) \
    7.39 -                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
    7.40 -                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
    7.41 -                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
    7.42 -                -DARCH=\"$(LIBARCH)\" \
    7.43 -                -DGAMMA \
    7.44 -                -DLAUNCHER_TYPE=\"gamma\" \
    7.45 -                -DLINK_INTO_$(LINK_INTO) \
    7.46 -                $(TARGET_DEFINES)
    7.47 -
    7.48 -ifeq ($(LINK_INTO),AOUT)
    7.49 -  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
    7.50 -  LAUNCHER_MAPFILE           = mapfile_reorder
    7.51 -  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
    7.52 -  LFLAGS_LAUNCHER           += $(SONAMEFLAG:SONAME=$(LIBJVM)) $(STATIC_LIBGCC)
    7.53 -  LIBS_LAUNCHER             += $(STATIC_STDCXX) $(LIBS)
    7.54 -else
    7.55 -  LAUNCHER.o                 = launcher.o
    7.56 -  LFLAGS_LAUNCHER           += -L `pwd`
    7.57 -  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
    7.58 -endif
    7.59 -
    7.60 -LINK_LAUNCHER = $(LINK.CC)
    7.61 -
    7.62 -LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
    7.63 -LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
    7.64 -
    7.65 -LAUNCHER_OUT = launcher
    7.66 -
    7.67 -SUFFIXES += .d
    7.68 -
    7.69 -SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
    7.70 -SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
    7.71 -
    7.72 -OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
    7.73 -
    7.74 -DEPFILES := $(patsubst %.o,%.d,$(OBJS))
    7.75 --include $(DEPFILES)
    7.76 -
    7.77 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
    7.78 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
    7.79 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
    7.80 -
    7.81 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
    7.82 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
    7.83 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
    7.84 -
    7.85 -$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
    7.86 -	$(QUIETLY) echo Linking launcher...
    7.87 -	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
    7.88 -	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
    7.89 -	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
    7.90 -
    7.91 -$(LAUNCHER): $(LAUNCHER_SCRIPT)
    7.92 -
    7.93 -$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
    7.94 -	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
    7.95 -	$(QUIETLY) chmod +x $@
    7.96 -
     8.1 --- a/make/linux/makefiles/vm.make	Mon May 06 13:53:13 2013 -0700
     8.2 +++ b/make/linux/makefiles/vm.make	Mon May 06 19:49:23 2013 -0700
     8.3 @@ -372,9 +372,6 @@
     8.4  #----------------------------------------------------------------------
     8.5  # Other files
     8.6  
     8.7 -# Gamma launcher
     8.8 -include $(MAKEFILES_DIR)/launcher.make
     8.9 -
    8.10  # Signal interposition library
    8.11  include $(MAKEFILES_DIR)/jsig.make
    8.12  
     9.1 --- a/make/solaris/makefiles/buildtree.make	Mon May 06 13:53:13 2013 -0700
     9.2 +++ b/make/solaris/makefiles/buildtree.make	Mon May 06 19:49:23 2013 -0700
     9.3 @@ -49,7 +49,6 @@
     9.4  # adlc.make	-
     9.5  # jvmti.make	- generate JVMTI bindings from the spec (JSR-163)
     9.6  # sa.make	- generate SA jar file and natives
     9.7 -# env.[ck]sh	- environment settings
     9.8  #
     9.9  # The makefiles are split this way so that "make foo" will run faster by not
    9.10  # having to read the dependency files for the vm.
    9.11 @@ -116,8 +115,7 @@
    9.12  # For dependencies and recursive makes.
    9.13  BUILDTREE_MAKE	= $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make
    9.14  
    9.15 -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make \
    9.16 -        env.sh env.csh jdkpath.sh
    9.17 +BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make sa.make
    9.18  
    9.19  BUILDTREE_VARS	= GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \
    9.20  	ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT)
    9.21 @@ -339,33 +337,6 @@
    9.22  	echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \
    9.23  	) > $@
    9.24  
    9.25 -env.sh: $(BUILDTREE_MAKE)
    9.26 -	@echo Creating $@ ...
    9.27 -	$(QUIETLY) ( \
    9.28 -	$(BUILDTREE_COMMENT); \
    9.29 -	{ echo "JAVA_HOME=$(JDK_IMPORT_PATH)"; }; \
    9.30 -	{ \
    9.31 -	echo "CLASSPATH=$${CLASSPATH:+$$CLASSPATH:}.:\$${JAVA_HOME}/jre/lib/rt.jar:\$${JAVA_HOME}/jre/lib/i18n.jar"; \
    9.32 -	} | sed s:$${JAVA_HOME:--------}:\$${JAVA_HOME}:g; \
    9.33 -	echo "HOTSPOT_BUILD_USER=\"$${LOGNAME:-$$USER} in `basename $(GAMMADIR)`\""; \
    9.34 -	echo "export JAVA_HOME LD_LIBRARY_PATH CLASSPATH HOTSPOT_BUILD_USER"; \
    9.35 -	) > $@
    9.36 -
    9.37 -env.csh: env.sh
    9.38 -	@echo Creating $@ ...
    9.39 -	$(QUIETLY) ( \
    9.40 -	$(BUILDTREE_COMMENT); \
    9.41 -	{ echo "setenv JAVA_HOME \"$(JDK_IMPORT_PATH)\""; }; \
    9.42 -	sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=/setenv \1 /p' $?; \
    9.43 -	) > $@
    9.44 -
    9.45 -jdkpath.sh: $(BUILDTREE_MAKE)
    9.46 -	@echo Creating $@ ...
    9.47 -	$(QUIETLY) ( \
    9.48 -	$(BUILDTREE_COMMENT); \
    9.49 -	echo "JDK=${JAVA_HOME}"; \
    9.50 -	) > $@
    9.51 -
    9.52  FORCE:
    9.53  
    9.54  .PHONY:  all FORCE
    10.1 --- a/make/solaris/makefiles/launcher.make	Mon May 06 13:53:13 2013 -0700
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,108 +0,0 @@
    10.4 -#
    10.5 -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    10.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 -#
    10.8 -# This code is free software; you can redistribute it and/or modify it
    10.9 -# under the terms of the GNU General Public License version 2 only, as
   10.10 -# published by the Free Software Foundation.
   10.11 -#
   10.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 -# version 2 for more details (a copy is included in the LICENSE file that
   10.16 -# accompanied this code).
   10.17 -#
   10.18 -# You should have received a copy of the GNU General Public License version
   10.19 -# 2 along with this work; if not, write to the Free Software Foundation,
   10.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 -#
   10.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 -# or visit www.oracle.com if you need additional information or have any
   10.24 -# questions.
   10.25 -#  
   10.26 -#
   10.27 -
   10.28 -# Rules to build gamma launcher, used by vm.make
   10.29 -
   10.30 -LAUNCHER_SCRIPT = hotspot
   10.31 -LAUNCHER   = gamma
   10.32 -
   10.33 -LAUNCHERDIR   = $(GAMMADIR)/src/os/posix/launcher
   10.34 -LAUNCHERDIR_SHARE := $(GAMMADIR)/src/share/tools/launcher
   10.35 -LAUNCHERFLAGS = $(ARCHFLAG) \
   10.36 -                -I$(LAUNCHERDIR) -I$(GAMMADIR)/src/share/vm/prims \
   10.37 -                -I$(LAUNCHERDIR_SHARE) \
   10.38 -                -DFULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
   10.39 -                -DJDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
   10.40 -                -DJDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
   10.41 -                -DARCH=\"$(LIBARCH)\" \
   10.42 -                -DGAMMA \
   10.43 -                -DLAUNCHER_TYPE=\"gamma\" \
   10.44 -                -DLINK_INTO_$(LINK_INTO) \
   10.45 -                $(TARGET_DEFINES)
   10.46 -
   10.47 -ifeq ($(LINK_INTO),AOUT)
   10.48 -  LAUNCHER.o                 = launcher.o $(JVM_OBJ_FILES)
   10.49 -  LAUNCHER_MAPFILE           = mapfile_extended
   10.50 -  LFLAGS_LAUNCHER$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LAUNCHER_MAPFILE))
   10.51 -  LIBS_LAUNCHER             += $(LIBS)
   10.52 -else
   10.53 -  LAUNCHER.o                 = launcher.o
   10.54 -  LFLAGS_LAUNCHER           += -L `pwd`
   10.55 -  LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
   10.56 -endif
   10.57 -
   10.58 -LINK_LAUNCHER = $(LINK.CXX)
   10.59 -
   10.60 -LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
   10.61 -LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
   10.62 -
   10.63 -ifeq ("${Platform_compiler}", "sparcWorks")
   10.64 -# Enable the following LAUNCHERFLAGS addition if you need to compare the
   10.65 -# built ELF objects.
   10.66 -#
   10.67 -# The -g option makes static data global and the "-W0,-noglobal"
   10.68 -# option tells the compiler to not globalize static data using a unique
   10.69 -# globalization prefix. Instead force the use of a static globalization
   10.70 -# prefix based on the source filepath so the objects from two identical
   10.71 -# compilations are the same.
   10.72 -#
   10.73 -# Note: The blog says to use "-W0,-xglobalstatic", but that doesn't
   10.74 -#       seem to work. I got "-W0,-noglobal" from Kelly and that works.
   10.75 -#LAUNCHERFLAGS += -W0,-noglobal
   10.76 -endif # Platform_compiler == sparcWorks
   10.77 -
   10.78 -LAUNCHER_OUT = launcher
   10.79 -
   10.80 -SUFFIXES += .d
   10.81 -
   10.82 -SOURCES := $(shell find $(LAUNCHERDIR) -name "*.c")
   10.83 -SOURCES_SHARE := $(shell find $(LAUNCHERDIR_SHARE) -name "*.c")
   10.84 -
   10.85 -OBJS := $(patsubst $(LAUNCHERDIR)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES)) $(patsubst $(LAUNCHERDIR_SHARE)/%.c,$(LAUNCHER_OUT)/%.o,$(SOURCES_SHARE))
   10.86 -
   10.87 -DEPFILES := $(patsubst %.o,%.d,$(OBJS))
   10.88 --include $(DEPFILES)
   10.89 -
   10.90 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
   10.91 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
   10.92 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
   10.93 -
   10.94 -$(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
   10.95 -	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
   10.96 -	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
   10.97 -
   10.98 -$(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
   10.99 -ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
  10.100 -	$(QUIETLY) echo Linking launcher...
  10.101 -	$(QUIETLY) $(LINK_LAUNCHER/PRE_HOOK)
  10.102 -	$(QUIETLY) $(LINK_LAUNCHER) $(LFLAGS_LAUNCHER) -o $@ $(sort $(OBJS)) $(LIBS_LAUNCHER)
  10.103 -	$(QUIETLY) $(LINK_LAUNCHER/POST_HOOK)
  10.104 -endif # filter -sbfast -xsbfast
  10.105 -
  10.106 -$(LAUNCHER): $(LAUNCHER_SCRIPT)
  10.107 -
  10.108 -$(LAUNCHER_SCRIPT): $(LAUNCHERDIR)/launcher.script
  10.109 -	$(QUIETLY) sed -e 's/@@LIBARCH@@/$(LIBARCH)/g' $< > $@
  10.110 -	$(QUIETLY) chmod +x $@
  10.111 -
    11.1 --- a/make/solaris/makefiles/vm.make	Mon May 06 13:53:13 2013 -0700
    11.2 +++ b/make/solaris/makefiles/vm.make	Mon May 06 19:49:23 2013 -0700
    11.3 @@ -338,9 +338,6 @@
    11.4  #----------------------------------------------------------------------
    11.5  # Other files
    11.6  
    11.7 -# Gamma launcher
    11.8 -include $(MAKEFILES_DIR)/launcher.make
    11.9 -
   11.10  # Signal interposition library
   11.11  include $(MAKEFILES_DIR)/jsig.make
   11.12  
    12.1 --- a/make/windows/makefiles/debug.make	Mon May 06 13:53:13 2013 -0700
    12.2 +++ b/make/windows/makefiles/debug.make	Mon May 06 19:49:23 2013 -0700
    12.3 @@ -33,7 +33,7 @@
    12.4  BUILD_PCH_FILE=_build_pch_file.obj
    12.5  !endif
    12.6  
    12.7 -default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
    12.8 +default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
    12.9  
   12.10  !include ../local.make
   12.11  !include compile.make
   12.12 @@ -71,4 +71,3 @@
   12.13  
   12.14  !include $(WorkSpace)/make/windows/makefiles/shared.make
   12.15  !include $(WorkSpace)/make/windows/makefiles/sa.make
   12.16 -!include $(WorkSpace)/make/windows/makefiles/launcher.make
    13.1 --- a/make/windows/makefiles/fastdebug.make	Mon May 06 13:53:13 2013 -0700
    13.2 +++ b/make/windows/makefiles/fastdebug.make	Mon May 06 19:49:23 2013 -0700
    13.3 @@ -33,7 +33,7 @@
    13.4  BUILD_PCH_FILE=_build_pch_file.obj
    13.5  !endif
    13.6  
    13.7 -default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
    13.8 +default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
    13.9  
   13.10  !include ../local.make
   13.11  !include compile.make
   13.12 @@ -70,4 +70,3 @@
   13.13  
   13.14  !include $(WorkSpace)/make/windows/makefiles/shared.make
   13.15  !include $(WorkSpace)/make/windows/makefiles/sa.make
   13.16 -!include $(WorkSpace)/make/windows/makefiles/launcher.make
    14.1 --- a/make/windows/makefiles/launcher.make	Mon May 06 13:53:13 2013 -0700
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,73 +0,0 @@
    14.4 -#
    14.5 -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    14.6 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 -#
    14.8 -# This code is free software; you can redistribute it and/or modify it
    14.9 -# under the terms of the GNU General Public License version 2 only, as
   14.10 -# published by the Free Software Foundation.
   14.11 -#
   14.12 -# This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 -# version 2 for more details (a copy is included in the LICENSE file that
   14.16 -# accompanied this code).
   14.17 -#
   14.18 -# You should have received a copy of the GNU General Public License version
   14.19 -# 2 along with this work; if not, write to the Free Software Foundation,
   14.20 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 -#
   14.22 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 -# or visit www.oracle.com if you need additional information or have any
   14.24 -# questions.
   14.25 -#  
   14.26 -#
   14.27 -
   14.28 -
   14.29 -LAUNCHER_FLAGS=$(CXX_FLAGS) $(ARCHFLAG) \
   14.30 -	/D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
   14.31 -	/D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
   14.32 -	/D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
   14.33 -	/D GAMMA \
   14.34 -	/D LAUNCHER_TYPE=\"gamma\" \
   14.35 -	/D _CRT_SECURE_NO_WARNINGS \
   14.36 -	/D _CRT_SECURE_NO_DEPRECATE \
   14.37 -	/D LINK_INTO_LIBJVM \
   14.38 -	/I $(WorkSpace)\src\os\windows\launcher \
   14.39 -	/I $(WorkSpace)\src\share\tools\launcher \
   14.40 -	/I $(WorkSpace)\src\share\vm\prims \
   14.41 -	/I $(WorkSpace)\src\share\vm \
   14.42 -	/I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \
   14.43 -	/I $(WorkSpace)\src\os\windows\vm
   14.44 -
   14.45 -LD_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console 
   14.46 -
   14.47 -!if "$(COMPILER_NAME)" == "VS2005"
   14.48 -# This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib
   14.49 -#    on the link command line, otherwise we get missing __security_check_cookie
   14.50 -#    externals at link time. Even with /GS-, you need bufferoverflowU.lib.
   14.51 -BUFFEROVERFLOWLIB = bufferoverflowU.lib
   14.52 -LD_FLAGS = $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
   14.53 -!endif
   14.54 -
   14.55 -!if "$(COMPILER_NAME)" == "VS2010" && "$(BUILDARCH)" == "i486"
   14.56 -LD_FLAGS = /SAFESEH $(LD_FLAGS)
   14.57 -!endif
   14.58 -
   14.59 -LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher
   14.60 -LAUNCHERDIR_SHARE = $(WorkSpace)/src/share/tools/launcher
   14.61 -
   14.62 -OUTDIR = launcher
   14.63 -
   14.64 -{$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj:
   14.65 -	-mkdir $(OUTDIR) 2>NUL >NUL
   14.66 -        $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
   14.67 -
   14.68 -{$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj:
   14.69 -	-mkdir $(OUTDIR) 2>NUL >NUL
   14.70 -        $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
   14.71 -
   14.72 -$(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h
   14.73 -
   14.74 -launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj
   14.75 -	echo $(JAVA_HOME) > jdkpath.txt  
   14.76 -	$(LD) $(LD_FLAGS) /out:hotspot.exe $**
    15.1 --- a/make/windows/makefiles/product.make	Mon May 06 13:53:13 2013 -0700
    15.2 +++ b/make/windows/makefiles/product.make	Mon May 06 19:49:23 2013 -0700
    15.3 @@ -32,7 +32,7 @@
    15.4  BUILD_PCH_FILE=_build_pch_file.obj
    15.5  !endif
    15.6  
    15.7 -default:: $(BUILD_PCH_FILE) $(AOUT) launcher checkAndBuildSA
    15.8 +default:: $(BUILD_PCH_FILE) $(AOUT) checkAndBuildSA
    15.9  
   15.10  !include ../local.make
   15.11  !include compile.make
   15.12 @@ -73,4 +73,3 @@
   15.13  
   15.14  !include $(WorkSpace)/make/windows/makefiles/shared.make
   15.15  !include $(WorkSpace)/make/windows/makefiles/sa.make
   15.16 -!include $(WorkSpace)/make/windows/makefiles/launcher.make
    16.1 --- a/make/windows/makefiles/projectcreator.make	Mon May 06 13:53:13 2013 -0700
    16.2 +++ b/make/windows/makefiles/projectcreator.make	Mon May 06 19:49:23 2013 -0700
    16.3 @@ -59,7 +59,6 @@
    16.4          -relativeSrcInclude src \
    16.5          -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \
    16.6          -ignorePath $(HOTSPOTBUILDSPACE) \
    16.7 -        -ignorePath launcher \
    16.8          -ignorePath share\vm\adlc \
    16.9          -ignorePath share\vm\shark \
   16.10          -ignorePath share\tools \
   16.11 @@ -105,7 +104,6 @@
   16.12          -define ALIGN_STACK_FRAMES \
   16.13          -define VM_LITTLE_ENDIAN \
   16.14          -prelink  "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	set JAVA_HOME=$(HOTSPOTJDKDIST)	$(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \
   16.15 -        -postbuild "" "Building hotspot.exe..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	nmake -f $(HOTSPOTWORKSPACE)\make\windows\projectfiles\common\Makefile LOCAL_MAKE=$(HOTSPOTBUILDSPACE)\%f\local.make JAVA_HOME=$(HOTSPOTJDKDIST) launcher" \
   16.16          -ignoreFile jsig.c \
   16.17          -ignoreFile jvmtiEnvRecommended.cpp \
   16.18          -ignoreFile jvmtiEnvStub.cpp \
    17.1 --- a/make/windows/projectfiles/common/Makefile	Mon May 06 13:53:13 2013 -0700
    17.2 +++ b/make/windows/projectfiles/common/Makefile	Mon May 06 19:49:23 2013 -0700
    17.3 @@ -65,7 +65,6 @@
    17.4  !endif
    17.5  
    17.6  HS_INTERNAL_NAME=jvm
    17.7 -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/launcher.make
    17.8  
    17.9  default:: $(AdditionalTargets) $(JvmtiGeneratedFiles)
   17.10  
    18.1 --- a/src/os/posix/launcher/java_md.c	Mon May 06 13:53:13 2013 -0700
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,1936 +0,0 @@
    18.4 -/*
    18.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    18.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 - *
    18.8 - * This code is free software; you can redistribute it and/or modify it
    18.9 - * under the terms of the GNU General Public License version 2 only, as
   18.10 - * published by the Free Software Foundation.
   18.11 - *
   18.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 - * version 2 for more details (a copy is included in the LICENSE file that
   18.16 - * accompanied this code).
   18.17 - *
   18.18 - * You should have received a copy of the GNU General Public License version
   18.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 - *
   18.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 - * or visit www.oracle.com if you need additional information or have any
   18.24 - * questions.
   18.25 - *
   18.26 - */
   18.27 -
   18.28 -
   18.29 -#include "java.h"
   18.30 -#include <dirent.h>
   18.31 -#include <dlfcn.h>
   18.32 -#include <fcntl.h>
   18.33 -#include <inttypes.h>
   18.34 -#include <stdio.h>
   18.35 -#include <string.h>
   18.36 -#include <stdlib.h>
   18.37 -#include <limits.h>
   18.38 -#include <sys/stat.h>
   18.39 -#include <unistd.h>
   18.40 -#include <sys/types.h>
   18.41 -
   18.42 -#ifndef GAMMA
   18.43 -#include "manifest_info.h"
   18.44 -#include "version_comp.h"
   18.45 -#endif
   18.46 -
   18.47 -#if defined(__linux__) || defined(_ALLBSD_SOURCE)
   18.48 -#include <pthread.h>
   18.49 -#else
   18.50 -#include <thread.h>
   18.51 -#endif
   18.52 -
   18.53 -#ifdef __APPLE__
   18.54 -#define JVM_DLL "libjvm.dylib"
   18.55 -#define JAVA_DLL "libjava.dylib"
   18.56 -#define LD_LIBRARY_PATH "DYLD_LIBRARY_PATH"
   18.57 -#else
   18.58 -#define JVM_DLL "libjvm.so"
   18.59 -#define JAVA_DLL "libjava.so"
   18.60 -#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
   18.61 -#endif
   18.62 -
   18.63 -#ifndef GAMMA   /* launcher.make defines ARCH */
   18.64 -/*
   18.65 - * If a processor / os combination has the ability to run binaries of
   18.66 - * two data models and cohabitation of jre/jdk bits with both data
   18.67 - * models is supported, then DUAL_MODE is defined.  When DUAL_MODE is
   18.68 - * defined, the architecture names for the narrow and wide version of
   18.69 - * the architecture are defined in LIBARCH64NAME and LIBARCH32NAME.  Currently
   18.70 - * only Solaris on sparc/sparcv9 and i586/amd64 is DUAL_MODE; linux
   18.71 - * i586/amd64 could be defined as DUAL_MODE but that is not the
   18.72 - * current policy.
   18.73 - */
   18.74 -
   18.75 -#ifndef LIBARCHNAME
   18.76 -#  error "The macro LIBARCHNAME was not defined on the compile line"
   18.77 -#endif
   18.78 -
   18.79 -#ifdef __sun
   18.80 -#  define DUAL_MODE
   18.81 -#  ifndef LIBARCH32NAME
   18.82 -#    error "The macro LIBARCH32NAME was not defined on the compile line"
   18.83 -#  endif
   18.84 -#  ifndef LIBARCH64NAME
   18.85 -#    error "The macro LIBARCH64NAME was not defined on the compile line"
   18.86 -#  endif
   18.87 -#  include <sys/systeminfo.h>
   18.88 -#  include <sys/elf.h>
   18.89 -#  include <stdio.h>
   18.90 -#endif
   18.91 -
   18.92 -#endif /* ifndef GAMMA */
   18.93 -
   18.94 -/* pointer to environment */
   18.95 -extern char **environ;
   18.96 -
   18.97 -#ifndef GAMMA
   18.98 -/*
   18.99 - *      A collection of useful strings. One should think of these as #define
  18.100 - *      entries, but actual strings can be more efficient (with many compilers).
  18.101 - */
  18.102 -#ifdef __linux__
  18.103 -static const char *system_dir   = "/usr/java";
  18.104 -static const char *user_dir     = "/java";
  18.105 -#else /* Solaris */
  18.106 -static const char *system_dir   = "/usr/jdk";
  18.107 -static const char *user_dir     = "/jdk";
  18.108 -#endif
  18.109 -
  18.110 -#endif /* ifndef GAMMA */
  18.111 -
  18.112 -/*
  18.113 - * Flowchart of launcher execs and options processing on unix
  18.114 - *
  18.115 - * The selection of the proper vm shared library to open depends on
  18.116 - * several classes of command line options, including vm "flavor"
  18.117 - * options (-client, -server) and the data model options, -d32  and
  18.118 - * -d64, as well as a version specification which may have come from
  18.119 - * the command line or from the manifest of an executable jar file.
  18.120 - * The vm selection options are not passed to the running
  18.121 - * virtual machine; they must be screened out by the launcher.
  18.122 - *
  18.123 - * The version specification (if any) is processed first by the
  18.124 - * platform independent routine SelectVersion.  This may result in
  18.125 - * the exec of the specified launcher version.
  18.126 - *
  18.127 - * Typically, the launcher execs at least once to ensure a suitable
  18.128 - * LD_LIBRARY_PATH is in effect for the process.  The first exec
  18.129 - * screens out all the data model options; leaving the choice of data
  18.130 - * model implicit in the binary selected to run.  However, in case no
  18.131 - * exec is done, the data model options are screened out before the vm
  18.132 - * is invoked.
  18.133 - *
  18.134 - *  incoming argv ------------------------------
  18.135 - *  |                                          |
  18.136 - * \|/                                         |
  18.137 - * CheckJVMType                                |
  18.138 - * (removes -client, -server, etc.)            |
  18.139 - *                                            \|/
  18.140 - *                                            CreateExecutionEnvironment
  18.141 - *                                            (removes -d32 and -d64,
  18.142 - *                                             determines desired data model,
  18.143 - *                                             sets up LD_LIBRARY_PATH,
  18.144 - *                                             and exec's)
  18.145 - *                                             |
  18.146 - *  --------------------------------------------
  18.147 - *  |
  18.148 - * \|/
  18.149 - * exec child 1 incoming argv -----------------
  18.150 - *  |                                          |
  18.151 - * \|/                                         |
  18.152 - * CheckJVMType                                |
  18.153 - * (removes -client, -server, etc.)            |
  18.154 - *  |                                         \|/
  18.155 - *  |                                          CreateExecutionEnvironment
  18.156 - *  |                                          (verifies desired data model
  18.157 - *  |                                           is running and acceptable
  18.158 - *  |                                           LD_LIBRARY_PATH;
  18.159 - *  |                                           no-op in child)
  18.160 - *  |
  18.161 - * \|/
  18.162 - * TranslateDashJArgs...
  18.163 - * (Prepare to pass args to vm)
  18.164 - *  |
  18.165 - *  |
  18.166 - *  |
  18.167 - * \|/
  18.168 - * ParseArguments
  18.169 - * (ignores -d32 and -d64,
  18.170 - *  processes version options,
  18.171 - *  creates argument list for vm,
  18.172 - *  etc.)
  18.173 - *
  18.174 - */
  18.175 -
  18.176 -static char *SetExecname(char **argv);
  18.177 -static char * GetExecname();
  18.178 -static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
  18.179 -                           char *jvmpath, jint jvmpathsize, char * arch);
  18.180 -static jboolean GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative);
  18.181 -
  18.182 -#ifndef GAMMA
  18.183 -const char *
  18.184 -GetArch()
  18.185 -{
  18.186 -    return LIBARCHNAME;
  18.187 -}
  18.188 -#endif /* ifndef GAMMA */
  18.189 -
  18.190 -void
  18.191 -CreateExecutionEnvironment(int *_argcp,
  18.192 -                           char ***_argvp,
  18.193 -                           char jrepath[],
  18.194 -                           jint so_jrepath,
  18.195 -                           char jvmpath[],
  18.196 -                           jint so_jvmpath,
  18.197 -                           char **original_argv) {
  18.198 -  /*
  18.199 -   * First, determine if we are running the desired data model.  If we
  18.200 -   * are running the desired data model, all the error messages
  18.201 -   * associated with calling GetJREPath, ReadKnownVMs, etc. should be
  18.202 -   * output.  However, if we are not running the desired data model,
  18.203 -   * some of the errors should be suppressed since it is more
  18.204 -   * informative to issue an error message based on whether or not the
  18.205 -   * os/processor combination has dual mode capabilities.
  18.206 -   */
  18.207 -
  18.208 -    char *execname = NULL;
  18.209 -    int original_argc = *_argcp;
  18.210 -    jboolean jvmpathExists;
  18.211 -
  18.212 -    /* Compute the name of the executable */
  18.213 -    execname = SetExecname(*_argvp);
  18.214 -
  18.215 -#ifndef GAMMA
  18.216 -    /* Set the LD_LIBRARY_PATH environment variable, check data model
  18.217 -       flags, and exec process, if needed */
  18.218 -    {
  18.219 -      char *arch        = (char *)GetArch(); /* like sparc or sparcv9 */
  18.220 -      char * jvmtype    = NULL;
  18.221 -      int argc          = *_argcp;
  18.222 -      char **argv       = original_argv;
  18.223 -
  18.224 -      char *runpath     = NULL; /* existing effective LD_LIBRARY_PATH
  18.225 -                                   setting */
  18.226 -
  18.227 -      int running       =       /* What data model is being ILP32 =>
  18.228 -                                   32 bit vm; LP64 => 64 bit vm */
  18.229 -#ifdef _LP64
  18.230 -        64;
  18.231 -#else
  18.232 -      32;
  18.233 -#endif
  18.234 -
  18.235 -      int wanted        = running;      /* What data mode is being
  18.236 -                                           asked for? Current model is
  18.237 -                                           fine unless another model
  18.238 -                                           is asked for */
  18.239 -
  18.240 -      char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
  18.241 -      char* newpath     = NULL; /* path on new LD_LIBRARY_PATH */
  18.242 -      char* lastslash   = NULL;
  18.243 -
  18.244 -      char** newenvp    = NULL; /* current environment */
  18.245 -
  18.246 -      char** newargv    = NULL;
  18.247 -      int    newargc    = 0;
  18.248 -#ifdef __sun
  18.249 -      char*  dmpath     = NULL;  /* data model specific LD_LIBRARY_PATH,
  18.250 -                                    Solaris only */
  18.251 -#endif
  18.252 -
  18.253 -      /*
  18.254 -       * Starting in 1.5, all unix platforms accept the -d32 and -d64
  18.255 -       * options.  On platforms where only one data-model is supported
  18.256 -       * (e.g. ia-64 Linux), using the flag for the other data model is
  18.257 -       * an error and will terminate the program.
  18.258 -       */
  18.259 -
  18.260 -      { /* open new scope to declare local variables */
  18.261 -        int i;
  18.262 -
  18.263 -        newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(*newargv));
  18.264 -        newargv[newargc++] = argv[0];
  18.265 -
  18.266 -        /* scan for data model arguments and remove from argument list;
  18.267 -           last occurrence determines desired data model */
  18.268 -        for (i=1; i < argc; i++) {
  18.269 -
  18.270 -          if (strcmp(argv[i], "-J-d64") == 0 || strcmp(argv[i], "-d64") == 0) {
  18.271 -            wanted = 64;
  18.272 -            continue;
  18.273 -          }
  18.274 -          if (strcmp(argv[i], "-J-d32") == 0 || strcmp(argv[i], "-d32") == 0) {
  18.275 -            wanted = 32;
  18.276 -            continue;
  18.277 -          }
  18.278 -          newargv[newargc++] = argv[i];
  18.279 -
  18.280 -#ifdef JAVA_ARGS
  18.281 -          if (argv[i][0] != '-')
  18.282 -            continue;
  18.283 -#else
  18.284 -          if (strcmp(argv[i], "-classpath") == 0 || strcmp(argv[i], "-cp") == 0) {
  18.285 -            i++;
  18.286 -            if (i >= argc) break;
  18.287 -            newargv[newargc++] = argv[i];
  18.288 -            continue;
  18.289 -          }
  18.290 -          if (argv[i][0] != '-') { i++; break; }
  18.291 -#endif
  18.292 -        }
  18.293 -
  18.294 -        /* copy rest of args [i .. argc) */
  18.295 -        while (i < argc) {
  18.296 -          newargv[newargc++] = argv[i++];
  18.297 -        }
  18.298 -        newargv[newargc] = NULL;
  18.299 -
  18.300 -        /*
  18.301 -         * newargv has all proper arguments here
  18.302 -         */
  18.303 -
  18.304 -        argc = newargc;
  18.305 -        argv = newargv;
  18.306 -      }
  18.307 -
  18.308 -      /* If the data model is not changing, it is an error if the
  18.309 -         jvmpath does not exist */
  18.310 -      if (wanted == running) {
  18.311 -        /* Find out where the JRE is that we will be using. */
  18.312 -        if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
  18.313 -          fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
  18.314 -          exit(2);
  18.315 -        }
  18.316 -
  18.317 -        /* Find the specified JVM type */
  18.318 -        if (ReadKnownVMs(jrepath, arch, JNI_FALSE) < 1) {
  18.319 -          fprintf(stderr, "Error: no known VMs. (check for corrupt jvm.cfg file)\n");
  18.320 -          exit(1);
  18.321 -        }
  18.322 -
  18.323 -        jvmpath[0] = '\0';
  18.324 -        jvmtype = CheckJvmType(_argcp, _argvp, JNI_FALSE);
  18.325 -
  18.326 -        if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, arch )) {
  18.327 -          fprintf(stderr, "Error: no `%s' JVM at `%s'.\n", jvmtype, jvmpath);
  18.328 -          exit(4);
  18.329 -        }
  18.330 -      } else {  /* do the same speculatively or exit */
  18.331 -#ifdef DUAL_MODE
  18.332 -        if (running != wanted) {
  18.333 -          /* Find out where the JRE is that we will be using. */
  18.334 -          if (!GetJREPath(jrepath, so_jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME), JNI_TRUE)) {
  18.335 -            goto EndDataModelSpeculate;
  18.336 -          }
  18.337 -
  18.338 -          /*
  18.339 -           * Read in jvm.cfg for target data model and process vm
  18.340 -           * selection options.
  18.341 -           */
  18.342 -          if (ReadKnownVMs(jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME), JNI_TRUE) < 1) {
  18.343 -            goto EndDataModelSpeculate;
  18.344 -          }
  18.345 -          jvmpath[0] = '\0';
  18.346 -          jvmtype = CheckJvmType(_argcp, _argvp, JNI_TRUE);
  18.347 -          /* exec child can do error checking on the existence of the path */
  18.348 -          jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath,
  18.349 -                                     ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME));
  18.350 -
  18.351 -        }
  18.352 -      EndDataModelSpeculate: /* give up and let other code report error message */
  18.353 -        ;
  18.354 -#else
  18.355 -        fprintf(stderr, "Running a %d-bit JVM is not supported on this platform.\n", wanted);
  18.356 -        exit(1);
  18.357 -#endif
  18.358 -      }
  18.359 -
  18.360 -      /*
  18.361 -       * We will set the LD_LIBRARY_PATH as follows:
  18.362 -       *
  18.363 -       *     o          $JVMPATH (directory portion only)
  18.364 -       *     o          $JRE/lib/$LIBARCHNAME
  18.365 -       *     o          $JRE/../lib/$LIBARCHNAME
  18.366 -       *
  18.367 -       * followed by the user's previous effective LD_LIBRARY_PATH, if
  18.368 -       * any.
  18.369 -       */
  18.370 -
  18.371 -#ifdef __sun
  18.372 -      /*
  18.373 -       * Starting in Solaris 7, ld.so.1 supports three LD_LIBRARY_PATH
  18.374 -       * variables:
  18.375 -       *
  18.376 -       * 1. LD_LIBRARY_PATH -- used for 32 and 64 bit searches if
  18.377 -       * data-model specific variables are not set.
  18.378 -       *
  18.379 -       * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH
  18.380 -       * for 64-bit binaries.
  18.381 -       *
  18.382 -       * 3. LD_LIBRARY_PATH_32 -- overrides and replaces LD_LIBRARY_PATH
  18.383 -       * for 32-bit binaries.
  18.384 -       *
  18.385 -       * The vm uses LD_LIBRARY_PATH to set the java.library.path system
  18.386 -       * property.  To shield the vm from the complication of multiple
  18.387 -       * LD_LIBRARY_PATH variables, if the appropriate data model
  18.388 -       * specific variable is set, we will act as if LD_LIBRARY_PATH had
  18.389 -       * the value of the data model specific variant and the data model
  18.390 -       * specific variant will be unset.  Note that the variable for the
  18.391 -       * *wanted* data model must be used (if it is set), not simply the
  18.392 -       * current running data model.
  18.393 -       */
  18.394 -
  18.395 -      switch(wanted) {
  18.396 -      case 0:
  18.397 -        if(running == 32) {
  18.398 -          dmpath = getenv("LD_LIBRARY_PATH_32");
  18.399 -          wanted = 32;
  18.400 -        }
  18.401 -        else {
  18.402 -          dmpath = getenv("LD_LIBRARY_PATH_64");
  18.403 -          wanted = 64;
  18.404 -        }
  18.405 -        break;
  18.406 -
  18.407 -      case 32:
  18.408 -        dmpath = getenv("LD_LIBRARY_PATH_32");
  18.409 -        break;
  18.410 -
  18.411 -      case 64:
  18.412 -        dmpath = getenv("LD_LIBRARY_PATH_64");
  18.413 -        break;
  18.414 -
  18.415 -      default:
  18.416 -        fprintf(stderr, "Improper value at line %d.", __LINE__);
  18.417 -        exit(1); /* unknown value in wanted */
  18.418 -        break;
  18.419 -      }
  18.420 -
  18.421 -      /*
  18.422 -       * If dmpath is NULL, the relevant data model specific variable is
  18.423 -       * not set and normal LD_LIBRARY_PATH should be used.
  18.424 -       */
  18.425 -      if( dmpath == NULL) {
  18.426 -        runpath = getenv("LD_LIBRARY_PATH");
  18.427 -      }
  18.428 -      else {
  18.429 -        runpath = dmpath;
  18.430 -      }
  18.431 -#else
  18.432 -      /*
  18.433 -       * If not on Solaris, assume only a single LD_LIBRARY_PATH
  18.434 -       * variable.
  18.435 -       */
  18.436 -      runpath = getenv(LD_LIBRARY_PATH);
  18.437 -#endif /* __sun */
  18.438 -
  18.439 -#if defined(__linux__)
  18.440 -      /*
  18.441 -       * On linux, if a binary is running as sgid or suid, glibc sets
  18.442 -       * LD_LIBRARY_PATH to the empty string for security purposes.  (In
  18.443 -       * contrast, on Solaris the LD_LIBRARY_PATH variable for a
  18.444 -       * privileged binary does not lose its settings; but the dynamic
  18.445 -       * linker does apply more scrutiny to the path.) The launcher uses
  18.446 -       * the value of LD_LIBRARY_PATH to prevent an exec loop.
  18.447 -       * Therefore, if we are running sgid or suid, this function's
  18.448 -       * setting of LD_LIBRARY_PATH will be ineffective and we should
  18.449 -       * return from the function now.  Getting the right libraries to
  18.450 -       * be found must be handled through other mechanisms.
  18.451 -       */
  18.452 -      if((getgid() != getegid()) || (getuid() != geteuid()) ) {
  18.453 -        return;
  18.454 -      }
  18.455 -#elif defined(_ALLBSD_SOURCE)
  18.456 -      /*
  18.457 -       * On BSD, if a binary is running as sgid or suid, libc sets
  18.458 -       * LD_LIBRARY_PATH to the empty string for security purposes.  (In
  18.459 -       * contrast, on Solaris the LD_LIBRARY_PATH variable for a
  18.460 -       * privileged binary does not lose its settings; but the dynamic
  18.461 -       * linker does apply more scrutiny to the path.) The launcher uses
  18.462 -       * the value of LD_LIBRARY_PATH to prevent an exec loop.
  18.463 -       * Therefore, if we are running sgid or suid, this function's
  18.464 -       * setting of LD_LIBRARY_PATH will be ineffective and we should
  18.465 -       * return from the function now.  Getting the right libraries to
  18.466 -       * be found must be handled through other mechanisms.
  18.467 -       */
  18.468 -      if(issetugid()) {
  18.469 -        return;
  18.470 -      }
  18.471 -#endif
  18.472 -
  18.473 -      /* runpath contains current effective LD_LIBRARY_PATH setting */
  18.474 -
  18.475 -      jvmpath = JLI_StringDup(jvmpath);
  18.476 -      new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) +
  18.477 -                              2*strlen(jrepath) + 2*strlen(arch) +
  18.478 -                              strlen(jvmpath) + 52);
  18.479 -      newpath = new_runpath + strlen(LD_LIBRARY_PATH "=");
  18.480 -
  18.481 -
  18.482 -      /*
  18.483 -       * Create desired LD_LIBRARY_PATH value for target data model.
  18.484 -       */
  18.485 -      {
  18.486 -        /* remove the name of the .so from the JVM path */
  18.487 -        lastslash = strrchr(jvmpath, '/');
  18.488 -        if (lastslash)
  18.489 -          *lastslash = '\0';
  18.490 -
  18.491 -
  18.492 -        /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */
  18.493 -
  18.494 -        sprintf(new_runpath, LD_LIBRARY_PATH "="
  18.495 -                "%s:"
  18.496 -                "%s/lib/%s:"
  18.497 -                "%s/../lib/%s",
  18.498 -                jvmpath,
  18.499 -#ifdef DUAL_MODE
  18.500 -                jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME),
  18.501 -                jrepath, ((wanted==64)?LIBARCH64NAME:LIBARCH32NAME)
  18.502 -#else
  18.503 -                jrepath, arch,
  18.504 -                jrepath, arch
  18.505 -#endif
  18.506 -                );
  18.507 -
  18.508 -
  18.509 -        /*
  18.510 -         * Check to make sure that the prefix of the current path is the
  18.511 -         * desired environment variable setting.
  18.512 -         */
  18.513 -        if (runpath != NULL &&
  18.514 -            strncmp(newpath, runpath, strlen(newpath))==0 &&
  18.515 -            (runpath[strlen(newpath)] == 0 || runpath[strlen(newpath)] == ':') &&
  18.516 -            (running == wanted) /* data model does not have to be changed */
  18.517 -#ifdef __sun
  18.518 -            && (dmpath == NULL)    /* data model specific variables not set  */
  18.519 -#endif
  18.520 -            ) {
  18.521 -
  18.522 -          return;
  18.523 -
  18.524 -        }
  18.525 -      }
  18.526 -
  18.527 -      /*
  18.528 -       * Place the desired environment setting onto the prefix of
  18.529 -       * LD_LIBRARY_PATH.  Note that this prevents any possible infinite
  18.530 -       * loop of execv() because we test for the prefix, above.
  18.531 -       */
  18.532 -      if (runpath != 0) {
  18.533 -        strcat(new_runpath, ":");
  18.534 -        strcat(new_runpath, runpath);
  18.535 -      }
  18.536 -
  18.537 -      if( putenv(new_runpath) != 0) {
  18.538 -        exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set
  18.539 -                    properly */
  18.540 -      }
  18.541 -
  18.542 -      /*
  18.543 -       * Unix systems document that they look at LD_LIBRARY_PATH only
  18.544 -       * once at startup, so we have to re-exec the current executable
  18.545 -       * to get the changed environment variable to have an effect.
  18.546 -       */
  18.547 -
  18.548 -#ifdef __sun
  18.549 -      /*
  18.550 -       * If dmpath is not NULL, remove the data model specific string
  18.551 -       * in the environment for the exec'ed child.
  18.552 -       */
  18.553 -
  18.554 -      if( dmpath != NULL)
  18.555 -        (void)UnsetEnv((wanted==32)?"LD_LIBRARY_PATH_32":"LD_LIBRARY_PATH_64");
  18.556 -#endif
  18.557 -
  18.558 -      newenvp = environ;
  18.559 -
  18.560 -      {
  18.561 -        char *newexec = execname;
  18.562 -#ifdef DUAL_MODE
  18.563 -        /*
  18.564 -         * If the data model is being changed, the path to the
  18.565 -         * executable must be updated accordingly; the executable name
  18.566 -         * and directory the executable resides in are separate.  In the
  18.567 -         * case of 32 => 64, the new bits are assumed to reside in, e.g.
  18.568 -         * "olddir/LIBARCH64NAME/execname"; in the case of 64 => 32,
  18.569 -         * the bits are assumed to be in "olddir/../execname".  For example,
  18.570 -         *
  18.571 -         * olddir/sparcv9/execname
  18.572 -         * olddir/amd64/execname
  18.573 -         *
  18.574 -         * for Solaris SPARC and Linux amd64, respectively.
  18.575 -         */
  18.576 -
  18.577 -        if (running != wanted) {
  18.578 -          char *oldexec = strcpy(JLI_MemAlloc(strlen(execname) + 1), execname);
  18.579 -          char *olddir = oldexec;
  18.580 -          char *oldbase = strrchr(oldexec, '/');
  18.581 -
  18.582 -
  18.583 -          newexec = JLI_MemAlloc(strlen(execname) + 20);
  18.584 -          *oldbase++ = 0;
  18.585 -          sprintf(newexec, "%s/%s/%s", olddir,
  18.586 -                  ((wanted==64) ? LIBARCH64NAME : ".."), oldbase);
  18.587 -          argv[0] = newexec;
  18.588 -        }
  18.589 -#endif
  18.590 -
  18.591 -        (void)fflush(stdout);
  18.592 -        (void)fflush(stderr);
  18.593 -        execve(newexec, argv, newenvp);
  18.594 -        perror("execve()");
  18.595 -
  18.596 -        fprintf(stderr, "Error trying to exec %s.\n", newexec);
  18.597 -        fprintf(stderr, "Check if file exists and permissions are set correctly.\n");
  18.598 -
  18.599 -#ifdef DUAL_MODE
  18.600 -        if (running != wanted) {
  18.601 -          fprintf(stderr, "Failed to start a %d-bit JVM process from a %d-bit JVM.\n",
  18.602 -                  wanted, running);
  18.603 -#  ifdef __sun
  18.604 -
  18.605 -#    ifdef __sparc
  18.606 -          fprintf(stderr, "Verify all necessary J2SE components have been installed.\n" );
  18.607 -          fprintf(stderr,
  18.608 -                  "(Solaris SPARC 64-bit components must be installed after 32-bit components.)\n" );
  18.609 -#    else
  18.610 -          fprintf(stderr, "Either 64-bit processes are not supported by this platform\n");
  18.611 -          fprintf(stderr, "or the 64-bit components have not been installed.\n");
  18.612 -#    endif
  18.613 -        }
  18.614 -#  endif
  18.615 -#endif
  18.616 -
  18.617 -      }
  18.618 -
  18.619 -      exit(1);
  18.620 -    }
  18.621 -
  18.622 -#else  /* ifndef GAMMA */
  18.623 -
  18.624 -  /*
  18.625 -   * gamma launcher is simpler in that it doesn't handle VM flavors, data
  18.626 -   * model, LD_LIBRARY_PATH, etc. Assuming everything is set-up correctly
  18.627 -   * all we need to do here is to return correct path names. See also
  18.628 -   * GetJVMPath() and GetApplicationHome().
  18.629 -   */
  18.630 -
  18.631 -  { char *arch = (char *) ARCH; /* like sparc or sparcv9 */
  18.632 -    char *p;
  18.633 -
  18.634 -    if (!GetJREPath(jrepath, so_jrepath, arch, JNI_FALSE) ) {
  18.635 -      fprintf(stderr, "Error: could not find Java 2 Runtime Environment.\n");
  18.636 -      exit(2);
  18.637 -    }
  18.638 -
  18.639 -    if (!GetJVMPath(jrepath, NULL, jvmpath, so_jvmpath, arch )) {
  18.640 -      fprintf(stderr, "Error: no JVM at `%s'.\n", jvmpath);
  18.641 -      exit(4);
  18.642 -    }
  18.643 -  }
  18.644 -
  18.645 -#endif  /* ifndef GAMMA */
  18.646 -}
  18.647 -
  18.648 -
  18.649 -/*
  18.650 - * On Solaris VM choosing is done by the launcher (java.c).
  18.651 - */
  18.652 -static jboolean
  18.653 -GetJVMPath(const char *jrepath, const char *jvmtype,
  18.654 -           char *jvmpath, jint jvmpathsize, char * arch)
  18.655 -{
  18.656 -    struct stat s;
  18.657 -
  18.658 -#ifndef GAMMA
  18.659 -    if (strchr(jvmtype, '/')) {
  18.660 -        sprintf(jvmpath, "%s/" JVM_DLL, jvmtype);
  18.661 -    } else {
  18.662 -        sprintf(jvmpath, "%s/lib/%s/%s/" JVM_DLL, jrepath, arch, jvmtype);
  18.663 -    }
  18.664 -#else
  18.665 -    /*
  18.666 -     * For gamma launcher, JVM is either built-in or in the same directory.
  18.667 -     * Either way we return "<exe_path>/libjvm.so" where <exe_path> is the
  18.668 -     * directory where gamma launcher is located.
  18.669 -     */
  18.670 -
  18.671 -    char *p;
  18.672 -
  18.673 -    snprintf(jvmpath, jvmpathsize, "%s", GetExecname());
  18.674 -    p = strrchr(jvmpath, '/');
  18.675 -    if (p) {
  18.676 -       /* replace executable name with libjvm.so */
  18.677 -       snprintf(p + 1, jvmpathsize - (p + 1 - jvmpath), "%s", JVM_DLL);
  18.678 -    } else {
  18.679 -       /* this case shouldn't happen */
  18.680 -       snprintf(jvmpath, jvmpathsize, "%s", JVM_DLL);
  18.681 -    }
  18.682 -#endif /* ifndef GAMMA */
  18.683 -
  18.684 -    if (_launcher_debug)
  18.685 -      printf("Does `%s' exist ... ", jvmpath);
  18.686 -
  18.687 -    if (stat(jvmpath, &s) == 0) {
  18.688 -        if (_launcher_debug)
  18.689 -          printf("yes.\n");
  18.690 -        return JNI_TRUE;
  18.691 -    } else {
  18.692 -        if (_launcher_debug)
  18.693 -          printf("no.\n");
  18.694 -        return JNI_FALSE;
  18.695 -    }
  18.696 -}
  18.697 -
  18.698 -/*
  18.699 - * Find path to JRE based on .exe's location or registry settings.
  18.700 - */
  18.701 -static jboolean
  18.702 -GetJREPath(char *path, jint pathsize, char * arch, jboolean speculative)
  18.703 -{
  18.704 -    char libjava[MAXPATHLEN];
  18.705 -
  18.706 -    if (GetApplicationHome(path, pathsize)) {
  18.707 -
  18.708 -        /* Is the JRE universal, i.e. no arch dir? */
  18.709 -        sprintf(libjava, "%s/jre/lib/" JAVA_DLL, path);
  18.710 -        if (access(libjava, F_OK) == 0) {
  18.711 -            strcat(path, "/jre");
  18.712 -            goto found;
  18.713 -        }
  18.714 -
  18.715 -        /* Is JRE co-located with the application? */
  18.716 -        sprintf(libjava, "%s/lib/%s/" JAVA_DLL, path, arch);
  18.717 -        if (access(libjava, F_OK) == 0) {
  18.718 -            goto found;
  18.719 -        }
  18.720 -
  18.721 -        /* Does the app ship a private JRE in <apphome>/jre directory? */
  18.722 -        sprintf(libjava, "%s/jre/lib/%s/" JAVA_DLL, path, arch);
  18.723 -        if (access(libjava, F_OK) == 0) {
  18.724 -            strcat(path, "/jre");
  18.725 -            goto found;
  18.726 -        }
  18.727 -    }
  18.728 -
  18.729 -    if (!speculative)
  18.730 -      fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
  18.731 -    return JNI_FALSE;
  18.732 -
  18.733 - found:
  18.734 -    if (_launcher_debug)
  18.735 -      printf("JRE path is %s\n", path);
  18.736 -    return JNI_TRUE;
  18.737 -}
  18.738 -
  18.739 -jboolean
  18.740 -LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
  18.741 -{
  18.742 -#ifdef GAMMA
  18.743 -    /* JVM is directly linked with gamma launcher; no dlopen() */
  18.744 -    ifn->CreateJavaVM = JNI_CreateJavaVM;
  18.745 -    ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
  18.746 -    return JNI_TRUE;
  18.747 -#else
  18.748 -    Dl_info dlinfo;
  18.749 -    void *libjvm;
  18.750 -
  18.751 -    if (_launcher_debug) {
  18.752 -        printf("JVM path is %s\n", jvmpath);
  18.753 -    }
  18.754 -
  18.755 -    libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL);
  18.756 -    if (libjvm == NULL) {
  18.757 -#if defined(__sparc) && !defined(_LP64) /* i.e. 32-bit sparc */
  18.758 -      FILE * fp;
  18.759 -      Elf32_Ehdr elf_head;
  18.760 -      int count;
  18.761 -      int location;
  18.762 -
  18.763 -      fp = fopen(jvmpath, "r");
  18.764 -      if(fp == NULL)
  18.765 -        goto error;
  18.766 -
  18.767 -      /* read in elf header */
  18.768 -      count = fread((void*)(&elf_head), sizeof(Elf32_Ehdr), 1, fp);
  18.769 -      fclose(fp);
  18.770 -      if(count < 1)
  18.771 -        goto error;
  18.772 -
  18.773 -      /*
  18.774 -       * Check for running a server vm (compiled with -xarch=v8plus)
  18.775 -       * on a stock v8 processor.  In this case, the machine type in
  18.776 -       * the elf header would not be included the architecture list
  18.777 -       * provided by the isalist command, which is turn is gotten from
  18.778 -       * sysinfo.  This case cannot occur on 64-bit hardware and thus
  18.779 -       * does not have to be checked for in binaries with an LP64 data
  18.780 -       * model.
  18.781 -       */
  18.782 -      if(elf_head.e_machine == EM_SPARC32PLUS) {
  18.783 -        char buf[257];  /* recommended buffer size from sysinfo man
  18.784 -                           page */
  18.785 -        long length;
  18.786 -        char* location;
  18.787 -
  18.788 -        length = sysinfo(SI_ISALIST, buf, 257);
  18.789 -        if(length > 0) {
  18.790 -          location = strstr(buf, "sparcv8plus ");
  18.791 -          if(location == NULL) {
  18.792 -            fprintf(stderr, "SPARC V8 processor detected; Server compiler requires V9 or better.\n");
  18.793 -            fprintf(stderr, "Use Client compiler on V8 processors.\n");
  18.794 -            fprintf(stderr, "Could not create the Java virtual machine.\n");
  18.795 -            return JNI_FALSE;
  18.796 -          }
  18.797 -        }
  18.798 -      }
  18.799 -#endif
  18.800 -      fprintf(stderr, "dl failure on line %d", __LINE__);
  18.801 -      goto error;
  18.802 -    }
  18.803 -
  18.804 -    ifn->CreateJavaVM = (CreateJavaVM_t)
  18.805 -      dlsym(libjvm, "JNI_CreateJavaVM");
  18.806 -    if (ifn->CreateJavaVM == NULL)
  18.807 -        goto error;
  18.808 -
  18.809 -    ifn->GetDefaultJavaVMInitArgs = (GetDefaultJavaVMInitArgs_t)
  18.810 -        dlsym(libjvm, "JNI_GetDefaultJavaVMInitArgs");
  18.811 -    if (ifn->GetDefaultJavaVMInitArgs == NULL)
  18.812 -      goto error;
  18.813 -
  18.814 -    return JNI_TRUE;
  18.815 -
  18.816 -error:
  18.817 -    fprintf(stderr, "Error: failed %s, because %s\n", jvmpath, dlerror());
  18.818 -    return JNI_FALSE;
  18.819 -#endif /* ifndef GAMMA */
  18.820 -}
  18.821 -
  18.822 -/*
  18.823 - * If app is "/foo/bin/javac", or "/foo/bin/sparcv9/javac" then put
  18.824 - * "/foo" into buf.
  18.825 - */
  18.826 -jboolean
  18.827 -GetApplicationHome(char *buf, jint bufsize)
  18.828 -{
  18.829 -#if defined(__linux__) || defined(_ALLBSD_SOURCE)
  18.830 -    char *execname = GetExecname();
  18.831 -    if (execname) {
  18.832 -        strncpy(buf, execname, bufsize-1);
  18.833 -        buf[bufsize-1] = '\0';
  18.834 -    } else {
  18.835 -        return JNI_FALSE;
  18.836 -    }
  18.837 -#else
  18.838 -    Dl_info dlinfo;
  18.839 -
  18.840 -    dladdr((void *)GetApplicationHome, &dlinfo);
  18.841 -    if (realpath(dlinfo.dli_fname, buf) == NULL) {
  18.842 -        fprintf(stderr, "Error: realpath(`%s') failed.\n", dlinfo.dli_fname);
  18.843 -        return JNI_FALSE;
  18.844 -    }
  18.845 -#endif
  18.846 -
  18.847 -#ifdef GAMMA
  18.848 -    {
  18.849 -       /* gamma launcher uses JAVA_HOME environment variable to find JDK/JRE */
  18.850 -       char* java_home_var = getenv("JAVA_HOME");
  18.851 -       if (java_home_var == NULL) {
  18.852 -          printf("JAVA_HOME must point to a valid JDK/JRE to run gamma\n");
  18.853 -          return JNI_FALSE;
  18.854 -       }
  18.855 -       snprintf(buf, bufsize, "%s", java_home_var);
  18.856 -    }
  18.857 -#else
  18.858 -    if (strrchr(buf, '/') == 0) {
  18.859 -        buf[0] = '\0';
  18.860 -        return JNI_FALSE;
  18.861 -    }
  18.862 -    *(strrchr(buf, '/')) = '\0';        /* executable file      */
  18.863 -    if (strlen(buf) < 4 || strrchr(buf, '/') == 0) {
  18.864 -        buf[0] = '\0';
  18.865 -        return JNI_FALSE;
  18.866 -    }
  18.867 -    if (strcmp("/bin", buf + strlen(buf) - 4) != 0)
  18.868 -        *(strrchr(buf, '/')) = '\0';    /* sparcv9 or amd64     */
  18.869 -    if (strlen(buf) < 4 || strcmp("/bin", buf + strlen(buf) - 4) != 0) {
  18.870 -        buf[0] = '\0';
  18.871 -        return JNI_FALSE;
  18.872 -    }
  18.873 -    *(strrchr(buf, '/')) = '\0';        /* bin                  */
  18.874 -#endif /* ifndef GAMMA */
  18.875 -
  18.876 -    return JNI_TRUE;
  18.877 -}
  18.878 -
  18.879 -
  18.880 -/*
  18.881 - * Return true if the named program exists
  18.882 - */
  18.883 -static int
  18.884 -ProgramExists(char *name)
  18.885 -{
  18.886 -    struct stat sb;
  18.887 -    if (stat(name, &sb) != 0) return 0;
  18.888 -    if (S_ISDIR(sb.st_mode)) return 0;
  18.889 -    return (sb.st_mode & S_IEXEC) != 0;
  18.890 -}
  18.891 -
  18.892 -
  18.893 -/*
  18.894 - * Find a command in a directory, returning the path.
  18.895 - */
  18.896 -static char *
  18.897 -Resolve(char *indir, char *cmd)
  18.898 -{
  18.899 -    char name[PATH_MAX + 2], *real;
  18.900 -
  18.901 -    if ((strlen(indir) + strlen(cmd) + 1)  > PATH_MAX) return 0;
  18.902 -    sprintf(name, "%s%c%s", indir, FILE_SEPARATOR, cmd);
  18.903 -    if (!ProgramExists(name)) return 0;
  18.904 -    real = JLI_MemAlloc(PATH_MAX + 2);
  18.905 -    if (!realpath(name, real))
  18.906 -        strcpy(real, name);
  18.907 -    return real;
  18.908 -}
  18.909 -
  18.910 -
  18.911 -/*
  18.912 - * Find a path for the executable
  18.913 - */
  18.914 -static char *
  18.915 -FindExecName(char *program)
  18.916 -{
  18.917 -    char cwdbuf[PATH_MAX+2];
  18.918 -    char *path;
  18.919 -    char *tmp_path;
  18.920 -    char *f;
  18.921 -    char *result = NULL;
  18.922 -
  18.923 -    /* absolute path? */
  18.924 -    if (*program == FILE_SEPARATOR ||
  18.925 -        (FILE_SEPARATOR=='\\' && strrchr(program, ':')))
  18.926 -        return Resolve("", program+1);
  18.927 -
  18.928 -    /* relative path? */
  18.929 -    if (strrchr(program, FILE_SEPARATOR) != 0) {
  18.930 -        char buf[PATH_MAX+2];
  18.931 -        return Resolve(getcwd(cwdbuf, sizeof(cwdbuf)), program);
  18.932 -    }
  18.933 -
  18.934 -    /* from search path? */
  18.935 -    path = getenv("PATH");
  18.936 -    if (!path || !*path) path = ".";
  18.937 -    tmp_path = JLI_MemAlloc(strlen(path) + 2);
  18.938 -    strcpy(tmp_path, path);
  18.939 -
  18.940 -    for (f=tmp_path; *f && result==0; ) {
  18.941 -        char *s = f;
  18.942 -        while (*f && (*f != PATH_SEPARATOR)) ++f;
  18.943 -        if (*f) *f++ = 0;
  18.944 -        if (*s == FILE_SEPARATOR)
  18.945 -            result = Resolve(s, program);
  18.946 -        else {
  18.947 -            /* relative path element */
  18.948 -            char dir[2*PATH_MAX];
  18.949 -            sprintf(dir, "%s%c%s", getcwd(cwdbuf, sizeof(cwdbuf)),
  18.950 -                    FILE_SEPARATOR, s);
  18.951 -            result = Resolve(dir, program);
  18.952 -        }
  18.953 -        if (result != 0) break;
  18.954 -    }
  18.955 -
  18.956 -    JLI_MemFree(tmp_path);
  18.957 -    return result;
  18.958 -}
  18.959 -
  18.960 -
  18.961 -/* Store the name of the executable once computed */
  18.962 -static char *execname = NULL;
  18.963 -
  18.964 -/*
  18.965 - * Compute the name of the executable
  18.966 - *
  18.967 - * In order to re-exec securely we need the absolute path of the
  18.968 - * executable. On Solaris getexecname(3c) may not return an absolute
  18.969 - * path so we use dladdr to get the filename of the executable and
  18.970 - * then use realpath to derive an absolute path. From Solaris 9
  18.971 - * onwards the filename returned in DL_info structure from dladdr is
  18.972 - * an absolute pathname so technically realpath isn't required.
  18.973 - * On Linux we read the executable name from /proc/self/exe.
  18.974 - * As a fallback, and for platforms other than Solaris and Linux,
  18.975 - * we use FindExecName to compute the executable name.
  18.976 - */
  18.977 -static char *
  18.978 -SetExecname(char **argv)
  18.979 -{
  18.980 -    char* exec_path = NULL;
  18.981 -
  18.982 -    if (execname != NULL)       /* Already determined */
  18.983 -        return (execname);
  18.984 -
  18.985 -#if defined(__sun)
  18.986 -    {
  18.987 -        Dl_info dlinfo;
  18.988 -        if (dladdr((void*)&SetExecname, &dlinfo)) {
  18.989 -            char *resolved = (char*)JLI_MemAlloc(PATH_MAX+1);
  18.990 -            if (resolved != NULL) {
  18.991 -                exec_path = realpath(dlinfo.dli_fname, resolved);
  18.992 -                if (exec_path == NULL) {
  18.993 -                    JLI_MemFree(resolved);
  18.994 -                }
  18.995 -            }
  18.996 -        }
  18.997 -    }
  18.998 -#elif defined(__linux__)
  18.999 -    {
 18.1000 -        const char* self = "/proc/self/exe";
 18.1001 -        char buf[PATH_MAX+1];
 18.1002 -        int len = readlink(self, buf, PATH_MAX);
 18.1003 -        if (len >= 0) {
 18.1004 -            buf[len] = '\0';            /* readlink doesn't nul terminate */
 18.1005 -            exec_path = JLI_StringDup(buf);
 18.1006 -        }
 18.1007 -    }
 18.1008 -#else /* !__sun && !__linux */
 18.1009 -    {
 18.1010 -        /* Not implemented */
 18.1011 -    }
 18.1012 -#endif
 18.1013 -
 18.1014 -    if (exec_path == NULL) {
 18.1015 -        exec_path = FindExecName(argv[0]);
 18.1016 -    }
 18.1017 -    execname = exec_path;
 18.1018 -    return exec_path;
 18.1019 -}
 18.1020 -
 18.1021 -/*
 18.1022 - * Return the name of the executable.  Used in java_md.c to find the JRE area.
 18.1023 - */
 18.1024 -static char *
 18.1025 -GetExecname() {
 18.1026 -  return execname;
 18.1027 -}
 18.1028 -
 18.1029 -void ReportErrorMessage(char * message, jboolean always) {
 18.1030 -  if (always) {
 18.1031 -    fprintf(stderr, "%s\n", message);
 18.1032 -  }
 18.1033 -}
 18.1034 -
 18.1035 -void ReportErrorMessage2(char * format, char * string, jboolean always) {
 18.1036 -  if (always) {
 18.1037 -    fprintf(stderr, format, string);
 18.1038 -    fprintf(stderr, "\n");
 18.1039 -  }
 18.1040 -}
 18.1041 -
 18.1042 -void  ReportExceptionDescription(JNIEnv * env) {
 18.1043 -  (*env)->ExceptionDescribe(env);
 18.1044 -}
 18.1045 -
 18.1046 -/*
 18.1047 - * Return JNI_TRUE for an option string that has no effect but should
 18.1048 - * _not_ be passed on to the vm; return JNI_FALSE otherwise.  On
 18.1049 - * Solaris SPARC, this screening needs to be done if:
 18.1050 - * 1) LD_LIBRARY_PATH does _not_ need to be reset and
 18.1051 - * 2) -d32 or -d64 is passed to a binary with a matching data model
 18.1052 - *    (the exec in SetLibraryPath removes -d<n> options and points the
 18.1053 - *    exec to the proper binary).  When this exec is not done, these options
 18.1054 - *    would end up getting passed onto the vm.
 18.1055 - */
 18.1056 -jboolean RemovableMachineDependentOption(char * option) {
 18.1057 -  /*
 18.1058 -   * Unconditionally remove both -d32 and -d64 options since only
 18.1059 -   * the last such options has an effect; e.g.
 18.1060 -   * java -d32 -d64 -d32 -version
 18.1061 -   * is equivalent to
 18.1062 -   * java -d32 -version
 18.1063 -   */
 18.1064 -
 18.1065 -  if( (strcmp(option, "-d32")  == 0 ) ||
 18.1066 -      (strcmp(option, "-d64")  == 0 ))
 18.1067 -    return JNI_TRUE;
 18.1068 -  else
 18.1069 -    return JNI_FALSE;
 18.1070 -}
 18.1071 -
 18.1072 -void PrintMachineDependentOptions() {
 18.1073 -      fprintf(stdout,
 18.1074 -        "    -d32          use a 32-bit data model if available\n"
 18.1075 -        "\n"
 18.1076 -        "    -d64          use a 64-bit data model if available\n");
 18.1077 -      return;
 18.1078 -}
 18.1079 -
 18.1080 -#ifndef GAMMA
 18.1081 -/*
 18.1082 - * The following methods (down to ServerClassMachine()) answer
 18.1083 - * the question about whether a machine is a "server-class"
 18.1084 - * machine.  A server-class machine is loosely defined as one
 18.1085 - * with 2 or more processors and 2 gigabytes or more physical
 18.1086 - * memory.  The definition of a processor is a physical package,
 18.1087 - * not a hyperthreaded chip masquerading as a multi-processor.
 18.1088 - * The definition of memory is also somewhat fuzzy, since x86
 18.1089 - * machines seem not to report all the memory in their DIMMs, we
 18.1090 - * think because of memory mapping of graphics cards, etc.
 18.1091 - *
 18.1092 - * This code is somewhat more confused with #ifdef's than we'd
 18.1093 - * like because this file is used by both Solaris and Linux
 18.1094 - * platforms, and so needs to be parameterized for SPARC and
 18.1095 - * i586 hardware.  The other Linux platforms (amd64 and ia64)
 18.1096 - * don't even ask this question, because they only come with
 18.1097 - * server JVMs.  */
 18.1098 -
 18.1099 -# define KB (1024UL)
 18.1100 -# define MB (1024UL * KB)
 18.1101 -# define GB (1024UL * MB)
 18.1102 -
 18.1103 -/* Compute physical memory by asking the OS */
 18.1104 -uint64_t
 18.1105 -physical_memory(void) {
 18.1106 -  const uint64_t pages     = (uint64_t) sysconf(_SC_PHYS_PAGES);
 18.1107 -  const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE);
 18.1108 -  const uint64_t result    = pages * page_size;
 18.1109 -# define UINT64_FORMAT "%" PRIu64
 18.1110 -
 18.1111 -  if (_launcher_debug) {
 18.1112 -    printf("pages: " UINT64_FORMAT
 18.1113 -           "  page_size: " UINT64_FORMAT
 18.1114 -           "  physical memory: " UINT64_FORMAT " (%.3fGB)\n",
 18.1115 -           pages, page_size, result, result / (double) GB);
 18.1116 -  }
 18.1117 -  return result;
 18.1118 -}
 18.1119 -
 18.1120 -#if defined(__sun) && defined(__sparc)
 18.1121 -
 18.1122 -/* Methods for solaris-sparc: these are easy. */
 18.1123 -
 18.1124 -/* Ask the OS how many processors there are. */
 18.1125 -unsigned long
 18.1126 -physical_processors(void) {
 18.1127 -  const unsigned long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
 18.1128 -
 18.1129 -  if (_launcher_debug) {
 18.1130 -    printf("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
 18.1131 -  }
 18.1132 -  return sys_processors;
 18.1133 -}
 18.1134 -
 18.1135 -/* The solaris-sparc version of the "server-class" predicate. */
 18.1136 -jboolean
 18.1137 -solaris_sparc_ServerClassMachine(void) {
 18.1138 -  jboolean            result            = JNI_FALSE;
 18.1139 -  /* How big is a server class machine? */
 18.1140 -  const unsigned long server_processors = 2UL;
 18.1141 -  const uint64_t      server_memory     = 2UL * GB;
 18.1142 -  const uint64_t      actual_memory     = physical_memory();
 18.1143 -
 18.1144 -  /* Is this a server class machine? */
 18.1145 -  if (actual_memory >= server_memory) {
 18.1146 -    const unsigned long actual_processors = physical_processors();
 18.1147 -    if (actual_processors >= server_processors) {
 18.1148 -      result = JNI_TRUE;
 18.1149 -    }
 18.1150 -  }
 18.1151 -  if (_launcher_debug) {
 18.1152 -    printf("solaris_" LIBARCHNAME "_ServerClassMachine: %s\n",
 18.1153 -           (result == JNI_TRUE ? "JNI_TRUE" : "JNI_FALSE"));
 18.1154 -  }
 18.1155 -  return result;
 18.1156 -}
 18.1157 -
 18.1158 -#endif /* __sun && __sparc */
 18.1159 -
 18.1160 -#if defined(__sun) && defined(i586)
 18.1161 -
 18.1162 -/*
 18.1163 - * A utility method for asking the CPU about itself.
 18.1164 - * There's a corresponding version of linux-i586
 18.1165 - * because the compilers are different.
 18.1166 - */
 18.1167 -void
 18.1168 -get_cpuid(uint32_t arg,
 18.1169 -          uint32_t* eaxp,
 18.1170 -          uint32_t* ebxp,
 18.1171 -          uint32_t* ecxp,
 18.1172 -          uint32_t* edxp) {
 18.1173 -#ifdef _LP64
 18.1174 -  asm(
 18.1175 -  /* rbx is a callee-saved register */
 18.1176 -      " movq    %rbx, %r11  \n"
 18.1177 -  /* rdx and rcx are 3rd and 4th argument registers */
 18.1178 -      " movq    %rdx, %r10  \n"
 18.1179 -      " movq    %rcx, %r9   \n"
 18.1180 -      " movl    %edi, %eax  \n"
 18.1181 -      " cpuid               \n"
 18.1182 -      " movl    %eax, (%rsi)\n"
 18.1183 -      " movl    %ebx, (%r10)\n"
 18.1184 -      " movl    %ecx, (%r9) \n"
 18.1185 -      " movl    %edx, (%r8) \n"
 18.1186 -  /* Restore rbx */
 18.1187 -      " movq    %r11, %rbx");
 18.1188 -#else
 18.1189 -  /* EBX is a callee-saved register */
 18.1190 -  asm(" pushl   %ebx");
 18.1191 -  /* Need ESI for storing through arguments */
 18.1192 -  asm(" pushl   %esi");
 18.1193 -  asm(" movl    8(%ebp), %eax   \n"
 18.1194 -      " cpuid                   \n"
 18.1195 -      " movl    12(%ebp), %esi  \n"
 18.1196 -      " movl    %eax, (%esi)    \n"
 18.1197 -      " movl    16(%ebp), %esi  \n"
 18.1198 -      " movl    %ebx, (%esi)    \n"
 18.1199 -      " movl    20(%ebp), %esi  \n"
 18.1200 -      " movl    %ecx, (%esi)    \n"
 18.1201 -      " movl    24(%ebp), %esi  \n"
 18.1202 -      " movl    %edx, (%esi)      ");
 18.1203 -  /* Restore ESI and EBX */
 18.1204 -  asm(" popl    %esi");
 18.1205 -  /* Restore EBX */
 18.1206 -  asm(" popl    %ebx");
 18.1207 -#endif
 18.1208 -}
 18.1209 -
 18.1210 -#endif /* __sun && i586 */
 18.1211 -
 18.1212 -#if (defined(__linux__) || defined(_ALLBSD_SOURCE)) && defined(i586)
 18.1213 -
 18.1214 -/*
 18.1215 - * A utility method for asking the CPU about itself.
 18.1216 - * There's a corresponding version of solaris-i586
 18.1217 - * because the compilers are different.
 18.1218 - */
 18.1219 -void
 18.1220 -get_cpuid(uint32_t arg,
 18.1221 -          uint32_t* eaxp,
 18.1222 -          uint32_t* ebxp,
 18.1223 -          uint32_t* ecxp,
 18.1224 -          uint32_t* edxp) {
 18.1225 -#ifdef _LP64
 18.1226 -  __asm__ volatile (/* Instructions */
 18.1227 -                    "   movl    %4, %%eax  \n"
 18.1228 -                    "   cpuid              \n"
 18.1229 -                    "   movl    %%eax, (%0)\n"
 18.1230 -                    "   movl    %%ebx, (%1)\n"
 18.1231 -                    "   movl    %%ecx, (%2)\n"
 18.1232 -                    "   movl    %%edx, (%3)\n"
 18.1233 -                    : /* Outputs */
 18.1234 -                    : /* Inputs */
 18.1235 -                    "r" (eaxp),
 18.1236 -                    "r" (ebxp),
 18.1237 -                    "r" (ecxp),
 18.1238 -                    "r" (edxp),
 18.1239 -                    "r" (arg)
 18.1240 -                    : /* Clobbers */
 18.1241 -                    "%rax", "%rbx", "%rcx", "%rdx", "memory"
 18.1242 -                    );
 18.1243 -#else
 18.1244 -  uint32_t value_of_eax = 0;
 18.1245 -  uint32_t value_of_ebx = 0;
 18.1246 -  uint32_t value_of_ecx = 0;
 18.1247 -  uint32_t value_of_edx = 0;
 18.1248 -  __asm__ volatile (/* Instructions */
 18.1249 -                        /* ebx is callee-save, so push it */
 18.1250 -                    "   pushl   %%ebx      \n"
 18.1251 -                    "   movl    %4, %%eax  \n"
 18.1252 -                    "   cpuid              \n"
 18.1253 -                    "   movl    %%eax, %0  \n"
 18.1254 -                    "   movl    %%ebx, %1  \n"
 18.1255 -                    "   movl    %%ecx, %2  \n"
 18.1256 -                    "   movl    %%edx, %3  \n"
 18.1257 -                        /* restore ebx */
 18.1258 -                    "   popl    %%ebx      \n"
 18.1259 -
 18.1260 -                    : /* Outputs */
 18.1261 -                    "=m" (value_of_eax),
 18.1262 -                    "=m" (value_of_ebx),
 18.1263 -                    "=m" (value_of_ecx),
 18.1264 -                    "=m" (value_of_edx)
 18.1265 -                    : /* Inputs */
 18.1266 -                    "m" (arg)
 18.1267 -                    : /* Clobbers */
 18.1268 -                    "%eax", "%ecx", "%edx"
 18.1269 -                    );
 18.1270 -  *eaxp = value_of_eax;
 18.1271 -  *ebxp = value_of_ebx;
 18.1272 -  *ecxp = value_of_ecx;
 18.1273 -  *edxp = value_of_edx;
 18.1274 -#endif
 18.1275 -}
 18.1276 -
 18.1277 -#endif /* __linux__ && i586 */
 18.1278 -
 18.1279 -#ifdef i586
 18.1280 -/*
 18.1281 - * Routines shared by solaris-i586 and linux-i586.
 18.1282 - */
 18.1283 -
 18.1284 -enum HyperThreadingSupport_enum {
 18.1285 -  hts_supported        =  1,
 18.1286 -  hts_too_soon_to_tell =  0,
 18.1287 -  hts_not_supported    = -1,
 18.1288 -  hts_not_pentium4     = -2,
 18.1289 -  hts_not_intel        = -3
 18.1290 -};
 18.1291 -typedef enum HyperThreadingSupport_enum HyperThreadingSupport;
 18.1292 -
 18.1293 -/* Determine if hyperthreading is supported */
 18.1294 -HyperThreadingSupport
 18.1295 -hyperthreading_support(void) {
 18.1296 -  HyperThreadingSupport result = hts_too_soon_to_tell;
 18.1297 -  /* Bits 11 through 8 is family processor id */
 18.1298 -# define FAMILY_ID_SHIFT 8
 18.1299 -# define FAMILY_ID_MASK 0xf
 18.1300 -  /* Bits 23 through 20 is extended family processor id */
 18.1301 -# define EXT_FAMILY_ID_SHIFT 20
 18.1302 -# define EXT_FAMILY_ID_MASK 0xf
 18.1303 -  /* Pentium 4 family processor id */
 18.1304 -# define PENTIUM4_FAMILY_ID 0xf
 18.1305 -  /* Bit 28 indicates Hyper-Threading Technology support */
 18.1306 -# define HT_BIT_SHIFT 28
 18.1307 -# define HT_BIT_MASK 1
 18.1308 -  uint32_t vendor_id[3] = { 0U, 0U, 0U };
 18.1309 -  uint32_t value_of_eax = 0U;
 18.1310 -  uint32_t value_of_edx = 0U;
 18.1311 -  uint32_t dummy        = 0U;
 18.1312 -
 18.1313 -  /* Yes, this is supposed to be [0], [2], [1] */
 18.1314 -  get_cpuid(0, &dummy, &vendor_id[0], &vendor_id[2], &vendor_id[1]);
 18.1315 -  if (_launcher_debug) {
 18.1316 -    printf("vendor: %c %c %c %c %c %c %c %c %c %c %c %c \n",
 18.1317 -           ((vendor_id[0] >>  0) & 0xff),
 18.1318 -           ((vendor_id[0] >>  8) & 0xff),
 18.1319 -           ((vendor_id[0] >> 16) & 0xff),
 18.1320 -           ((vendor_id[0] >> 24) & 0xff),
 18.1321 -           ((vendor_id[1] >>  0) & 0xff),
 18.1322 -           ((vendor_id[1] >>  8) & 0xff),
 18.1323 -           ((vendor_id[1] >> 16) & 0xff),
 18.1324 -           ((vendor_id[1] >> 24) & 0xff),
 18.1325 -           ((vendor_id[2] >>  0) & 0xff),
 18.1326 -           ((vendor_id[2] >>  8) & 0xff),
 18.1327 -           ((vendor_id[2] >> 16) & 0xff),
 18.1328 -           ((vendor_id[2] >> 24) & 0xff));
 18.1329 -  }
 18.1330 -  get_cpuid(1, &value_of_eax, &dummy, &dummy, &value_of_edx);
 18.1331 -  if (_launcher_debug) {
 18.1332 -    printf("value_of_eax: 0x%x  value_of_edx: 0x%x\n",
 18.1333 -           value_of_eax, value_of_edx);
 18.1334 -  }
 18.1335 -  if ((((value_of_eax >> FAMILY_ID_SHIFT) & FAMILY_ID_MASK) == PENTIUM4_FAMILY_ID) ||
 18.1336 -      (((value_of_eax >> EXT_FAMILY_ID_SHIFT) & EXT_FAMILY_ID_MASK) != 0)) {
 18.1337 -    if ((((vendor_id[0] >>  0) & 0xff) == 'G') &&
 18.1338 -        (((vendor_id[0] >>  8) & 0xff) == 'e') &&
 18.1339 -        (((vendor_id[0] >> 16) & 0xff) == 'n') &&
 18.1340 -        (((vendor_id[0] >> 24) & 0xff) == 'u') &&
 18.1341 -        (((vendor_id[1] >>  0) & 0xff) == 'i') &&
 18.1342 -        (((vendor_id[1] >>  8) & 0xff) == 'n') &&
 18.1343 -        (((vendor_id[1] >> 16) & 0xff) == 'e') &&
 18.1344 -        (((vendor_id[1] >> 24) & 0xff) == 'I') &&
 18.1345 -        (((vendor_id[2] >>  0) & 0xff) == 'n') &&
 18.1346 -        (((vendor_id[2] >>  8) & 0xff) == 't') &&
 18.1347 -        (((vendor_id[2] >> 16) & 0xff) == 'e') &&
 18.1348 -        (((vendor_id[2] >> 24) & 0xff) == 'l')) {
 18.1349 -      if (((value_of_edx >> HT_BIT_SHIFT) & HT_BIT_MASK) == HT_BIT_MASK) {
 18.1350 -        if (_launcher_debug) {
 18.1351 -          printf("Hyperthreading supported\n");
 18.1352 -        }
 18.1353 -        result = hts_supported;
 18.1354 -      } else {
 18.1355 -        if (_launcher_debug) {
 18.1356 -          printf("Hyperthreading not supported\n");
 18.1357 -        }
 18.1358 -        result = hts_not_supported;
 18.1359 -      }
 18.1360 -    } else {
 18.1361 -      if (_launcher_debug) {
 18.1362 -        printf("Not GenuineIntel\n");
 18.1363 -      }
 18.1364 -      result = hts_not_intel;
 18.1365 -    }
 18.1366 -  } else {
 18.1367 -    if (_launcher_debug) {
 18.1368 -      printf("not Pentium 4 or extended\n");
 18.1369 -    }
 18.1370 -    result = hts_not_pentium4;
 18.1371 -  }
 18.1372 -  return result;
 18.1373 -}
 18.1374 -
 18.1375 -/* Determine how many logical processors there are per CPU */
 18.1376 -unsigned int
 18.1377 -logical_processors_per_package(void) {
 18.1378 -  /*
 18.1379 -   * After CPUID with EAX==1, register EBX bits 23 through 16
 18.1380 -   * indicate the number of logical processors per package
 18.1381 -   */
 18.1382 -# define NUM_LOGICAL_SHIFT 16
 18.1383 -# define NUM_LOGICAL_MASK 0xff
 18.1384 -  unsigned int result                        = 1U;
 18.1385 -  const HyperThreadingSupport hyperthreading = hyperthreading_support();
 18.1386 -
 18.1387 -  if (hyperthreading == hts_supported) {
 18.1388 -    uint32_t value_of_ebx = 0U;
 18.1389 -    uint32_t dummy        = 0U;
 18.1390 -
 18.1391 -    get_cpuid(1, &dummy, &value_of_ebx, &dummy, &dummy);
 18.1392 -    result = (value_of_ebx >> NUM_LOGICAL_SHIFT) & NUM_LOGICAL_MASK;
 18.1393 -    if (_launcher_debug) {
 18.1394 -      printf("logical processors per package: %u\n", result);
 18.1395 -    }
 18.1396 -  }
 18.1397 -  return result;
 18.1398 -}
 18.1399 -
 18.1400 -/* Compute the number of physical processors, not logical processors */
 18.1401 -unsigned long
 18.1402 -physical_processors(void) {
 18.1403 -  const long sys_processors = sysconf(_SC_NPROCESSORS_CONF);
 18.1404 -  unsigned long result      = sys_processors;
 18.1405 -
 18.1406 -  if (_launcher_debug) {
 18.1407 -    printf("sysconf(_SC_NPROCESSORS_CONF): %lu\n", sys_processors);
 18.1408 -  }
 18.1409 -  if (sys_processors > 1) {
 18.1410 -    unsigned int logical_processors = logical_processors_per_package();
 18.1411 -    if (logical_processors > 1) {
 18.1412 -      result = (unsigned long) sys_processors / logical_processors;
 18.1413 -    }
 18.1414 -  }
 18.1415 -  if (_launcher_debug) {
 18.1416 -    printf("physical processors: %lu\n", result);
 18.1417 -  }
 18.1418 -  return result;
 18.1419 -}
 18.1420 -
 18.1421 -#endif /* i586 */
 18.1422 -
 18.1423 -#if defined(__sun) && defined(i586)
 18.1424 -
 18.1425 -/* The definition of a server-class machine for solaris-i586/amd64 */
 18.1426 -jboolean
 18.1427 -solaris_i586_ServerClassMachine(void) {
 18.1428 -  jboolean            result            = JNI_FALSE;
 18.1429 -  /* How big is a server class machine? */
 18.1430 -  const unsigned long server_processors = 2UL;
 18.1431 -  const uint64_t      server_memory     = 2UL * GB;
 18.1432 -  /*
 18.1433 -   * We seem not to get our full complement of memory.
 18.1434 -   *     We allow some part (1/8?) of the memory to be "missing",
 18.1435 -   *     based on the sizes of DIMMs, and maybe graphics cards.
 18.1436 -   */
 18.1437 -  const uint64_t      missing_memory    = 256UL * MB;
 18.1438 -  const uint64_t      actual_memory     = physical_memory();
 18.1439 -
 18.1440 -  /* Is this a server class machine? */
 18.1441 -  if (actual_memory >= (server_memory - missing_memory)) {
 18.1442 -    const unsigned long actual_processors = physical_processors();
 18.1443 -    if (actual_processors >= server_processors) {
 18.1444 -      result = JNI_TRUE;
 18.1445 -    }
 18.1446 -  }
 18.1447 -  if (_launcher_debug) {
 18.1448 -    printf("solaris_" LIBARCHNAME "_ServerClassMachine: %s\n",
 18.1449 -           (result == JNI_TRUE ? "true" : "false"));
 18.1450 -  }
 18.1451 -  return result;
 18.1452 -}
 18.1453 -
 18.1454 -#endif /* __sun && i586 */
 18.1455 -
 18.1456 -#if defined(__linux__) && defined(i586)
 18.1457 -
 18.1458 -/* The definition of a server-class machine for linux-i586 */
 18.1459 -jboolean
 18.1460 -linux_i586_ServerClassMachine(void) {
 18.1461 -  jboolean            result            = JNI_FALSE;
 18.1462 -  /* How big is a server class machine? */
 18.1463 -  const unsigned long server_processors = 2UL;
 18.1464 -  const uint64_t      server_memory     = 2UL * GB;
 18.1465 -  /*
 18.1466 -   * We seem not to get our full complement of memory.
 18.1467 -   *     We allow some part (1/8?) of the memory to be "missing",
 18.1468 -   *     based on the sizes of DIMMs, and maybe graphics cards.
 18.1469 -   */
 18.1470 -  const uint64_t      missing_memory    = 256UL * MB;
 18.1471 -  const uint64_t      actual_memory     = physical_memory();
 18.1472 -
 18.1473 -  /* Is this a server class machine? */
 18.1474 -  if (actual_memory >= (server_memory - missing_memory)) {
 18.1475 -    const unsigned long actual_processors = physical_processors();
 18.1476 -    if (actual_processors >= server_processors) {
 18.1477 -      result = JNI_TRUE;
 18.1478 -    }
 18.1479 -  }
 18.1480 -  if (_launcher_debug) {
 18.1481 -    printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
 18.1482 -           (result == JNI_TRUE ? "true" : "false"));
 18.1483 -  }
 18.1484 -  return result;
 18.1485 -}
 18.1486 -
 18.1487 -#endif /* __linux__ && i586 */
 18.1488 -
 18.1489 -#if defined(_ALLBSD_SOURCE) && defined(i586)
 18.1490 -
 18.1491 -/* The definition of a server-class machine for bsd-i586 */
 18.1492 -jboolean
 18.1493 -bsd_i586_ServerClassMachine(void) {
 18.1494 -  jboolean            result            = JNI_FALSE;
 18.1495 -  /* How big is a server class machine? */
 18.1496 -  const unsigned long server_processors = 2UL;
 18.1497 -  const uint64_t      server_memory     = 2UL * GB;
 18.1498 -  /*
 18.1499 -   * We seem not to get our full complement of memory.
 18.1500 -   *     We allow some part (1/8?) of the memory to be "missing",
 18.1501 -   *     based on the sizes of DIMMs, and maybe graphics cards.
 18.1502 -   */
 18.1503 -  const uint64_t      missing_memory    = 256UL * MB;
 18.1504 -  const uint64_t      actual_memory     = physical_memory();
 18.1505 -
 18.1506 -  /* Is this a server class machine? */
 18.1507 -  if (actual_memory >= (server_memory - missing_memory)) {
 18.1508 -    const unsigned long actual_processors = physical_processors();
 18.1509 -    if (actual_processors >= server_processors) {
 18.1510 -      result = JNI_TRUE;
 18.1511 -    }
 18.1512 -  }
 18.1513 -  if (_launcher_debug) {
 18.1514 -    printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n",
 18.1515 -           (result == JNI_TRUE ? "true" : "false"));
 18.1516 -  }
 18.1517 -  return result;
 18.1518 -}
 18.1519 -
 18.1520 -#endif /* _ALLBSD_SOURCE && i586 */
 18.1521 -
 18.1522 -/* Dispatch to the platform-specific definition of "server-class" */
 18.1523 -jboolean
 18.1524 -ServerClassMachine(void) {
 18.1525 -  jboolean result = JNI_FALSE;
 18.1526 -#if   defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
 18.1527 -  result = JNI_FALSE;
 18.1528 -#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
 18.1529 -  result = JNI_TRUE;
 18.1530 -#elif defined(__sun) && defined(__sparc)
 18.1531 -  result = solaris_sparc_ServerClassMachine();
 18.1532 -#elif defined(__sun) && defined(i586)
 18.1533 -  result = solaris_i586_ServerClassMachine();
 18.1534 -#elif defined(__linux__) && defined(i586)
 18.1535 -  result = linux_i586_ServerClassMachine();
 18.1536 -#elif defined(_ALLBSD_SOURCE) && defined(i586)
 18.1537 -  result = bsd_i586_ServerClassMachine();
 18.1538 -#else
 18.1539 -  if (_launcher_debug) {
 18.1540 -    printf("ServerClassMachine: returns default value of %s\n",
 18.1541 -           (result == JNI_TRUE ? "true" : "false"));
 18.1542 -  }
 18.1543 -#endif
 18.1544 -  return result;
 18.1545 -}
 18.1546 -
 18.1547 -/*
 18.1548 - *      Since using the file system as a registry is a bit risky, perform
 18.1549 - *      additional sanity checks on the identified directory to validate
 18.1550 - *      it as a valid jre/sdk.
 18.1551 - *
 18.1552 - *      Return 0 if the tests fail; otherwise return non-zero (true).
 18.1553 - *
 18.1554 - *      Note that checking for anything more than the existence of an
 18.1555 - *      executable object at bin/java relative to the path being checked
 18.1556 - *      will break the regression tests.
 18.1557 - */
 18.1558 -static int
 18.1559 -CheckSanity(char *path, char *dir)
 18.1560 -{
 18.1561 -    char    buffer[PATH_MAX];
 18.1562 -
 18.1563 -    if (strlen(path) + strlen(dir) + 11 > PATH_MAX)
 18.1564 -        return (0);     /* Silently reject "impossibly" long paths */
 18.1565 -
 18.1566 -    (void)strcat(strcat(strcat(strcpy(buffer, path), "/"), dir), "/bin/java");
 18.1567 -    return ((access(buffer, X_OK) == 0) ? 1 : 0);
 18.1568 -}
 18.1569 -
 18.1570 -/*
 18.1571 - *      Determine if there is an acceptable JRE in the directory dirname.
 18.1572 - *      Upon locating the "best" one, return a fully qualified path to
 18.1573 - *      it. "Best" is defined as the most advanced JRE meeting the
 18.1574 - *      constraints contained in the manifest_info. If no JRE in this
 18.1575 - *      directory meets the constraints, return NULL.
 18.1576 - *
 18.1577 - *      Note that we don't check for errors in reading the directory
 18.1578 - *      (which would be done by checking errno).  This is because it
 18.1579 - *      doesn't matter if we get an error reading the directory, or
 18.1580 - *      we just don't find anything interesting in the directory.  We
 18.1581 - *      just return NULL in either case.
 18.1582 - *
 18.1583 - *      The historical names of j2sdk and j2re were changed to jdk and
 18.1584 - *      jre respecively as part of the 1.5 rebranding effort.  Since the
 18.1585 - *      former names are legacy on Linux, they must be recognized for
 18.1586 - *      all time.  Fortunately, this is a minor cost.
 18.1587 - */
 18.1588 -static char
 18.1589 -*ProcessDir(manifest_info *info, char *dirname)
 18.1590 -{
 18.1591 -    DIR     *dirp;
 18.1592 -    struct dirent *dp;
 18.1593 -    char    *best = NULL;
 18.1594 -    int     offset;
 18.1595 -    int     best_offset = 0;
 18.1596 -    char    *ret_str = NULL;
 18.1597 -    char    buffer[PATH_MAX];
 18.1598 -
 18.1599 -    if ((dirp = opendir(dirname)) == NULL)
 18.1600 -        return (NULL);
 18.1601 -
 18.1602 -    do {
 18.1603 -        if ((dp = readdir(dirp)) != NULL) {
 18.1604 -            offset = 0;
 18.1605 -            if ((strncmp(dp->d_name, "jre", 3) == 0) ||
 18.1606 -                (strncmp(dp->d_name, "jdk", 3) == 0))
 18.1607 -                offset = 3;
 18.1608 -            else if (strncmp(dp->d_name, "j2re", 4) == 0)
 18.1609 -                offset = 4;
 18.1610 -            else if (strncmp(dp->d_name, "j2sdk", 5) == 0)
 18.1611 -                offset = 5;
 18.1612 -            if (offset > 0) {
 18.1613 -                if ((JLI_AcceptableRelease(dp->d_name + offset,
 18.1614 -                    info->jre_version)) && CheckSanity(dirname, dp->d_name))
 18.1615 -                    if ((best == NULL) || (JLI_ExactVersionId(
 18.1616 -                      dp->d_name + offset, best + best_offset) > 0)) {
 18.1617 -                        if (best != NULL)
 18.1618 -                            JLI_MemFree(best);
 18.1619 -                        best = JLI_StringDup(dp->d_name);
 18.1620 -                        best_offset = offset;
 18.1621 -                    }
 18.1622 -            }
 18.1623 -        }
 18.1624 -    } while (dp != NULL);
 18.1625 -    (void) closedir(dirp);
 18.1626 -    if (best == NULL)
 18.1627 -        return (NULL);
 18.1628 -    else {
 18.1629 -        ret_str = JLI_MemAlloc(strlen(dirname) + strlen(best) + 2);
 18.1630 -        ret_str = strcat(strcat(strcpy(ret_str, dirname), "/"), best);
 18.1631 -        JLI_MemFree(best);
 18.1632 -        return (ret_str);
 18.1633 -    }
 18.1634 -}
 18.1635 -
 18.1636 -/*
 18.1637 - *      This is the global entry point. It examines the host for the optimal
 18.1638 - *      JRE to be used by scanning a set of directories.  The set of directories
 18.1639 - *      is platform dependent and can be overridden by the environment
 18.1640 - *      variable JAVA_VERSION_PATH.
 18.1641 - *
 18.1642 - *      This routine itself simply determines the set of appropriate
 18.1643 - *      directories before passing control onto ProcessDir().
 18.1644 - */
 18.1645 -char*
 18.1646 -LocateJRE(manifest_info* info)
 18.1647 -{
 18.1648 -    char        *path;
 18.1649 -    char        *home;
 18.1650 -    char        *target = NULL;
 18.1651 -    char        *dp;
 18.1652 -    char        *cp;
 18.1653 -
 18.1654 -    /*
 18.1655 -     * Start by getting JAVA_VERSION_PATH
 18.1656 -     */
 18.1657 -    if (info->jre_restrict_search)
 18.1658 -        path = JLI_StringDup(system_dir);
 18.1659 -    else if ((path = getenv("JAVA_VERSION_PATH")) != NULL)
 18.1660 -        path = JLI_StringDup(path);
 18.1661 -    else
 18.1662 -        if ((home = getenv("HOME")) != NULL) {
 18.1663 -            path = (char *)JLI_MemAlloc(strlen(home) + strlen(system_dir) +
 18.1664 -                strlen(user_dir) + 2);
 18.1665 -            path = strcat(strcat(strcat(strcpy(path, home),
 18.1666 -                user_dir), ":"), system_dir);
 18.1667 -        } else
 18.1668 -            path = JLI_StringDup(system_dir);
 18.1669 -
 18.1670 -    /*
 18.1671 -     * Step through each directory on the path. Terminate the scan with
 18.1672 -     * the first directory with an acceptable JRE.
 18.1673 -     */
 18.1674 -    cp = dp = path;
 18.1675 -    while (dp != NULL) {
 18.1676 -        cp = strchr(dp, (int)':');
 18.1677 -        if (cp != NULL)
 18.1678 -            *cp = (char)NULL;
 18.1679 -        if ((target = ProcessDir(info, dp)) != NULL)
 18.1680 -            break;
 18.1681 -        dp = cp;
 18.1682 -        if (dp != NULL)
 18.1683 -            dp++;
 18.1684 -    }
 18.1685 -    JLI_MemFree(path);
 18.1686 -    return (target);
 18.1687 -}
 18.1688 -
 18.1689 -/*
 18.1690 - * Given a path to a jre to execute, this routine checks if this process
 18.1691 - * is indeed that jre.  If not, it exec's that jre.
 18.1692 - *
 18.1693 - * We want to actually check the paths rather than just the version string
 18.1694 - * built into the executable, so that given version specification (and
 18.1695 - * JAVA_VERSION_PATH) will yield the exact same Java environment, regardless
 18.1696 - * of the version of the arbitrary launcher we start with.
 18.1697 - */
 18.1698 -void
 18.1699 -ExecJRE(char *jre, char **argv)
 18.1700 -{
 18.1701 -    char    wanted[PATH_MAX];
 18.1702 -    char    *execname;
 18.1703 -    char    *progname;
 18.1704 -
 18.1705 -    /*
 18.1706 -     * Resolve the real path to the directory containing the selected JRE.
 18.1707 -     */
 18.1708 -    if (realpath(jre, wanted) == NULL) {
 18.1709 -        fprintf(stderr, "Unable to resolve %s\n", jre);
 18.1710 -        exit(1);
 18.1711 -    }
 18.1712 -
 18.1713 -    /*
 18.1714 -     * Resolve the real path to the currently running launcher.
 18.1715 -     */
 18.1716 -    execname = SetExecname(argv);
 18.1717 -    if (execname == NULL) {
 18.1718 -        fprintf(stderr, "Unable to resolve current executable\n");
 18.1719 -        exit(1);
 18.1720 -    }
 18.1721 -
 18.1722 -    /*
 18.1723 -     * If the path to the selected JRE directory is a match to the initial
 18.1724 -     * portion of the path to the currently executing JRE, we have a winner!
 18.1725 -     * If so, just return.
 18.1726 -     */
 18.1727 -    if (strncmp(wanted, execname, strlen(wanted)) == 0)
 18.1728 -        return;                 /* I am the droid you were looking for */
 18.1729 -
 18.1730 -    /*
 18.1731 -     * If this isn't the selected version, exec the selected version.
 18.1732 -     */
 18.1733 -#ifdef JAVA_ARGS  /* javac, jar and friends. */
 18.1734 -    progname = "java";
 18.1735 -#else             /* java, oldjava, javaw and friends */
 18.1736 -#ifdef PROGNAME
 18.1737 -    progname = PROGNAME;
 18.1738 -#else
 18.1739 -    progname = *argv;
 18.1740 -    if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
 18.1741 -        progname = s + 1;
 18.1742 -    }
 18.1743 -#endif /* PROGNAME */
 18.1744 -#endif /* JAVA_ARGS */
 18.1745 -
 18.1746 -    /*
 18.1747 -     * This should never happen (because of the selection code in SelectJRE),
 18.1748 -     * but check for "impossibly" long path names just because buffer overruns
 18.1749 -     * can be so deadly.
 18.1750 -     */
 18.1751 -    if (strlen(wanted) + strlen(progname) + 6 > PATH_MAX) {
 18.1752 -        fprintf(stderr, "Path length exceeds maximum length (PATH_MAX)\n");
 18.1753 -        exit(1);
 18.1754 -    }
 18.1755 -
 18.1756 -    /*
 18.1757 -     * Construct the path and exec it.
 18.1758 -     */
 18.1759 -    (void)strcat(strcat(wanted, "/bin/"), progname);
 18.1760 -    argv[0] = progname;
 18.1761 -    if (_launcher_debug) {
 18.1762 -        int i;
 18.1763 -        printf("ReExec Command: %s (%s)\n", wanted, argv[0]);
 18.1764 -        printf("ReExec Args:");
 18.1765 -        for (i = 1; argv[i] != NULL; i++)
 18.1766 -            printf(" %s", argv[i]);
 18.1767 -        printf("\n");
 18.1768 -    }
 18.1769 -    (void)fflush(stdout);
 18.1770 -    (void)fflush(stderr);
 18.1771 -    execv(wanted, argv);
 18.1772 -    perror("execv()");
 18.1773 -    fprintf(stderr, "Exec of %s failed\n", wanted);
 18.1774 -    exit(1);
 18.1775 -}
 18.1776 -#endif /* ifndef GAMMA */
 18.1777 -
 18.1778 -/*
 18.1779 - * "Borrowed" from Solaris 10 where the unsetenv() function is being added
 18.1780 - * to libc thanks to SUSv3 (Standard Unix Specification, version 3). As
 18.1781 - * such, in the fullness of time this will appear in libc on all relevant
 18.1782 - * Solaris/Linux platforms and maybe even the Windows platform.  At that
 18.1783 - * time, this stub can be removed.
 18.1784 - *
 18.1785 - * This implementation removes the environment locking for multithreaded
 18.1786 - * applications.  (We don't have access to these mutexes within libc and
 18.1787 - * the launcher isn't multithreaded.)  Note that what remains is platform
 18.1788 - * independent, because it only relies on attributes that a POSIX environment
 18.1789 - * defines.
 18.1790 - *
 18.1791 - * Returns 0 on success, -1 on failure.
 18.1792 - *
 18.1793 - * Also removed was the setting of errno.  The only value of errno set
 18.1794 - * was EINVAL ("Invalid Argument").
 18.1795 - */
 18.1796 -
 18.1797 -/*
 18.1798 - * s1(environ) is name=value
 18.1799 - * s2(name) is name(not the form of name=value).
 18.1800 - * if names match, return value of 1, else return 0
 18.1801 - */
 18.1802 -static int
 18.1803 -match_noeq(const char *s1, const char *s2)
 18.1804 -{
 18.1805 -        while (*s1 == *s2++) {
 18.1806 -                if (*s1++ == '=')
 18.1807 -                        return (1);
 18.1808 -        }
 18.1809 -        if (*s1 == '=' && s2[-1] == '\0')
 18.1810 -                return (1);
 18.1811 -        return (0);
 18.1812 -}
 18.1813 -
 18.1814 -/*
 18.1815 - * added for SUSv3 standard
 18.1816 - *
 18.1817 - * Delete entry from environ.
 18.1818 - * Do not free() memory!  Other threads may be using it.
 18.1819 - * Keep it around forever.
 18.1820 - */
 18.1821 -static int
 18.1822 -borrowed_unsetenv(const char *name)
 18.1823 -{
 18.1824 -        long    idx;            /* index into environ */
 18.1825 -
 18.1826 -        if (name == NULL || *name == '\0' ||
 18.1827 -            strchr(name, '=') != NULL) {
 18.1828 -                return (-1);
 18.1829 -        }
 18.1830 -
 18.1831 -        for (idx = 0; environ[idx] != NULL; idx++) {
 18.1832 -                if (match_noeq(environ[idx], name))
 18.1833 -                        break;
 18.1834 -        }
 18.1835 -        if (environ[idx] == NULL) {
 18.1836 -                /* name not found but still a success */
 18.1837 -                return (0);
 18.1838 -        }
 18.1839 -        /* squeeze up one entry */
 18.1840 -        do {
 18.1841 -                environ[idx] = environ[idx+1];
 18.1842 -        } while (environ[++idx] != NULL);
 18.1843 -
 18.1844 -        return (0);
 18.1845 -}
 18.1846 -/* --- End of "borrowed" code --- */
 18.1847 -
 18.1848 -/*
 18.1849 - * Wrapper for unsetenv() function.
 18.1850 - */
 18.1851 -int
 18.1852 -UnsetEnv(char *name)
 18.1853 -{
 18.1854 -    return(borrowed_unsetenv(name));
 18.1855 -}
 18.1856 -
 18.1857 -/* --- Splash Screen shared library support --- */
 18.1858 -
 18.1859 -static const char* SPLASHSCREEN_SO = "libsplashscreen.so";
 18.1860 -
 18.1861 -static void* hSplashLib = NULL;
 18.1862 -
 18.1863 -void* SplashProcAddress(const char* name) {
 18.1864 -    if (!hSplashLib) {
 18.1865 -        hSplashLib = dlopen(SPLASHSCREEN_SO, RTLD_LAZY | RTLD_GLOBAL);
 18.1866 -    }
 18.1867 -    if (hSplashLib) {
 18.1868 -        void* sym = dlsym(hSplashLib, name);
 18.1869 -        return sym;
 18.1870 -    } else {
 18.1871 -        return NULL;
 18.1872 -    }
 18.1873 -}
 18.1874 -
 18.1875 -void SplashFreeLibrary() {
 18.1876 -    if (hSplashLib) {
 18.1877 -        dlclose(hSplashLib);
 18.1878 -        hSplashLib = NULL;
 18.1879 -    }
 18.1880 -}
 18.1881 -
 18.1882 -/*
 18.1883 - * Block current thread and continue execution in a new thread
 18.1884 - */
 18.1885 -int
 18.1886 -ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 18.1887 -    int rslt;
 18.1888 -#if defined(__linux__) || defined(_ALLBSD_SOURCE)
 18.1889 -    pthread_t tid;
 18.1890 -    pthread_attr_t attr;
 18.1891 -    pthread_attr_init(&attr);
 18.1892 -    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
 18.1893 -
 18.1894 -    if (stack_size > 0) {
 18.1895 -      pthread_attr_setstacksize(&attr, stack_size);
 18.1896 -    }
 18.1897 -
 18.1898 -    if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) {
 18.1899 -      void * tmp;
 18.1900 -      pthread_join(tid, &tmp);
 18.1901 -      rslt = (int)(intptr_t)tmp;
 18.1902 -    } else {
 18.1903 -     /*
 18.1904 -      * Continue execution in current thread if for some reason (e.g. out of
 18.1905 -      * memory/LWP)  a new thread can't be created. This will likely fail
 18.1906 -      * later in continuation as JNI_CreateJavaVM needs to create quite a
 18.1907 -      * few new threads, anyway, just give it a try..
 18.1908 -      */
 18.1909 -      rslt = continuation(args);
 18.1910 -    }
 18.1911 -
 18.1912 -    pthread_attr_destroy(&attr);
 18.1913 -#else
 18.1914 -    thread_t tid;
 18.1915 -    long flags = 0;
 18.1916 -    if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) {
 18.1917 -      void * tmp;
 18.1918 -      thr_join(tid, NULL, &tmp);
 18.1919 -      rslt = (int)(intptr_t)tmp;
 18.1920 -    } else {
 18.1921 -      /* See above. Continue in current thread if thr_create() failed */
 18.1922 -      rslt = continuation(args);
 18.1923 -    }
 18.1924 -#endif
 18.1925 -    return rslt;
 18.1926 -}
 18.1927 -
 18.1928 -/* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */
 18.1929 -#define MAX_PID_STR_SZ   20
 18.1930 -
 18.1931 -void SetJavaLauncherPlatformProps() {
 18.1932 -   /* Linux only */
 18.1933 -#ifdef __linux__
 18.1934 -    const char *substr = "-Dsun.java.launcher.pid=";
 18.1935 -    char *pid_prop_str = (char *)JLI_MemAlloc(strlen(substr) + MAX_PID_STR_SZ + 1);
 18.1936 -    sprintf(pid_prop_str, "%s%d", substr, getpid());
 18.1937 -    AddOption(pid_prop_str, NULL);
 18.1938 -#endif
 18.1939 -}
    19.1 --- a/src/os/posix/launcher/java_md.h	Mon May 06 13:53:13 2013 -0700
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,82 +0,0 @@
    19.4 -/*
    19.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    19.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 - *
    19.8 - * This code is free software; you can redistribute it and/or modify it
    19.9 - * under the terms of the GNU General Public License version 2 only, as
   19.10 - * published by the Free Software Foundation.
   19.11 - *
   19.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 - * version 2 for more details (a copy is included in the LICENSE file that
   19.16 - * accompanied this code).
   19.17 - *
   19.18 - * You should have received a copy of the GNU General Public License version
   19.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 - *
   19.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 - * or visit www.oracle.com if you need additional information or have any
   19.24 - * questions.
   19.25 - *
   19.26 - */
   19.27 -
   19.28 -#ifndef JAVA_MD_H
   19.29 -#define JAVA_MD_H
   19.30 -
   19.31 -#include <limits.h>
   19.32 -#include <unistd.h>
   19.33 -#include <sys/param.h>
   19.34 -#ifndef GAMMA
   19.35 -#include "manifest_info.h"
   19.36 -#endif
   19.37 -#include "jli_util.h"
   19.38 -
   19.39 -#define PATH_SEPARATOR          ':'
   19.40 -#define FILESEP                 "/"
   19.41 -#define FILE_SEPARATOR          '/'
   19.42 -#define IS_FILE_SEPARATOR(c) ((c) == '/')
   19.43 -#ifndef MAXNAMELEN
   19.44 -#define MAXNAMELEN              PATH_MAX
   19.45 -#endif
   19.46 -
   19.47 -#ifdef JAVA_ARGS
   19.48 -/*
   19.49 - * ApplicationHome is prepended to each of these entries; the resulting
   19.50 - * strings are concatenated (separated by PATH_SEPARATOR) and used as the
   19.51 - * value of -cp option to the launcher.
   19.52 - */
   19.53 -#ifndef APP_CLASSPATH
   19.54 -#define APP_CLASSPATH        { "/lib/tools.jar", "/classes" }
   19.55 -#endif
   19.56 -#endif
   19.57 -
   19.58 -#ifdef HAVE_GETHRTIME
   19.59 -/*
   19.60 - * Support for doing cheap, accurate interval timing.
   19.61 - */
   19.62 -#include <sys/time.h>
   19.63 -#define CounterGet()              (gethrtime()/1000)
   19.64 -#define Counter2Micros(counts)    (counts)
   19.65 -#else
   19.66 -#define CounterGet()              (0)
   19.67 -#define Counter2Micros(counts)    (1)
   19.68 -#endif /* HAVE_GETHRTIME */
   19.69 -
   19.70 -#ifdef _LP64
   19.71 -#define JLONG_FORMAT "%ld"
   19.72 -#else
   19.73 -#define JLONG_FORMAT "%lld"
   19.74 -#endif
   19.75 -
   19.76 -/*
   19.77 - * Function prototypes.
   19.78 - */
   19.79 -#ifndef GAMMA
   19.80 -char *LocateJRE(manifest_info *info);
   19.81 -void ExecJRE(char *jre, char **argv);
   19.82 -#endif
   19.83 -int UnsetEnv(char *name);
   19.84 -
   19.85 -#endif
    20.1 --- a/src/os/posix/launcher/launcher.script	Mon May 06 13:53:13 2013 -0700
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,218 +0,0 @@
    20.4 -#!/bin/sh
    20.5 -
    20.6 -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    20.7 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.8 -#
    20.9 -# This code is free software; you can redistribute it and/or modify it
   20.10 -# under the terms of the GNU General Public License version 2 only, as
   20.11 -# published by the Free Software Foundation.
   20.12 -#
   20.13 -# This code is distributed in the hope that it will be useful, but WITHOUT
   20.14 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.15 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.16 -# version 2 for more details (a copy is included in the LICENSE file that
   20.17 -# accompanied this code).
   20.18 -#
   20.19 -# You should have received a copy of the GNU General Public License version
   20.20 -# 2 along with this work; if not, write to the Free Software Foundation,
   20.21 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.22 -#
   20.23 -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.24 -# or visit www.oracle.com if you need additional information or have any
   20.25 -# questions.
   20.26 -
   20.27 -
   20.28 -# This script launches HotSpot.
   20.29 -#
   20.30 -# If the first parameter is either "-gdb" or "-gud", HotSpot will be
   20.31 -# launched inside gdb. "-gud" means "open an Emacs window and run gdb
   20.32 -# inside Emacs".
   20.33 -#
   20.34 -# If the first parameter is "-dbx", HotSpot will be launched inside dbx.
   20.35 -#
   20.36 -# If the first parameter is "-valgrind", HotSpot will be launched
   20.37 -# inside Valgrind (http://valgrind.kde.org) using the Memcheck skin,
   20.38 -# and with memory leak detection enabled.  This currently (2005jan19)
   20.39 -# requires at least Valgrind 2.3.0.  -Xmx16m will also be passed as
   20.40 -# the first parameter to HotSpot, since lowering HotSpot's memory
   20.41 -# consumption makes execution inside of Valgrind *a lot* faster.
   20.42 -#
   20.43 -
   20.44 -
   20.45 -#
   20.46 -# User changeable parameters ------------------------------------------------
   20.47 -#
   20.48 -
   20.49 -# This is the name of the gdb binary to use
   20.50 -if [ ! "$GDB" ]
   20.51 -then
   20.52 -    GDB=gdb
   20.53 -fi
   20.54 -
   20.55 -# This is the name of the gdb binary to use
   20.56 -if [ ! "$DBX" ]
   20.57 -then
   20.58 -    DBX=dbx
   20.59 -fi
   20.60 -
   20.61 -# This is the name of the Valgrind binary to use
   20.62 -if [ ! "$VALGRIND" ]
   20.63 -then
   20.64 -    VALGRIND=valgrind
   20.65 -fi
   20.66 -
   20.67 -# This is the name of Emacs for running GUD
   20.68 -EMACS=emacs
   20.69 -
   20.70 -#
   20.71 -# End of user changeable parameters -----------------------------------------
   20.72 -#
   20.73 -
   20.74 -# Make sure the paths are fully specified, i.e. they must begin with /.
   20.75 -REL_MYDIR=`dirname $0`
   20.76 -MYDIR=`cd $REL_MYDIR && pwd`
   20.77 -
   20.78 -# Look whether the user wants to run inside gdb
   20.79 -case "$1" in
   20.80 -    -gdb)
   20.81 -        MODE=gdb
   20.82 -        shift
   20.83 -        ;;
   20.84 -    -gud)
   20.85 -        MODE=gud
   20.86 -        shift
   20.87 -        ;;
   20.88 -    -dbx)
   20.89 -        MODE=dbx
   20.90 -        shift
   20.91 -        ;;
   20.92 -    -valgrind)
   20.93 -        MODE=valgrind
   20.94 -        shift
   20.95 -        ;;
   20.96 -    *)
   20.97 -        MODE=run
   20.98 -        ;;
   20.99 -esac
  20.100 -
  20.101 -JDK=
  20.102 -if [ "${ALT_JAVA_HOME}" = "" ]; then
  20.103 -    . ${MYDIR}/jdkpath.sh
  20.104 -else
  20.105 -    JDK=${ALT_JAVA_HOME%%/jre};
  20.106 -fi
  20.107 -
  20.108 -if [ "${JDK}" = "" ]; then
  20.109 -    echo Failed to find JDK. ALT_JAVA_HOME is not set or ./jdkpath.sh is empty or not found.
  20.110 -    exit 1
  20.111 -fi
  20.112 -
  20.113 -# We will set the LD_LIBRARY_PATH as follows:
  20.114 -#     o		$JVMPATH (directory portion only)
  20.115 -#     o		$JRE/lib/$ARCH
  20.116 -# followed by the user's previous effective LD_LIBRARY_PATH, if
  20.117 -# any.
  20.118 -JRE=$JDK/jre
  20.119 -JAVA_HOME=$JDK
  20.120 -export JAVA_HOME
  20.121 -
  20.122 -ARCH=@@LIBARCH@@
  20.123 -SBP=${MYDIR}:${JRE}/lib/${ARCH}
  20.124 -
  20.125 -
  20.126 -# Set up a suitable LD_LIBRARY_PATH or DYLD_LIBRARY_PATH
  20.127 -OS=`uname -s`
  20.128 -if [ "${OS}" = "Darwin" ]
  20.129 -then
  20.130 -    if [ -z "$DYLD_LIBRARY_PATH" ]
  20.131 -    then
  20.132 -        DYLD_LIBRARY_PATH="$SBP"
  20.133 -    else
  20.134 -        DYLD_LIBRARY_PATH="$SBP:$DYLD_LIBRARY_PATH"
  20.135 -    fi
  20.136 -    export DYLD_LIBRARY_PATH
  20.137 -else
  20.138 -    # not 'Darwin'
  20.139 -    if [ -z "$LD_LIBRARY_PATH" ]
  20.140 -    then
  20.141 -        LD_LIBRARY_PATH="$SBP"
  20.142 -    else
  20.143 -        LD_LIBRARY_PATH="$SBP:$LD_LIBRARY_PATH"
  20.144 -    fi
  20.145 -    export LD_LIBRARY_PATH
  20.146 -fi
  20.147 -
  20.148 -JPARMS="$@ $JAVA_ARGS";
  20.149 -
  20.150 -# Locate the gamma development launcher
  20.151 -LAUNCHER=${MYDIR}/gamma
  20.152 -if [ ! -x $LAUNCHER ] ; then
  20.153 -    echo Error: Cannot find the gamma development launcher \"$LAUNCHER\"
  20.154 -    exit 1
  20.155 -fi
  20.156 -
  20.157 -GDBSRCDIR=$MYDIR
  20.158 -BASEDIR=`cd $MYDIR/../../.. && pwd`
  20.159 -
  20.160 -init_gdb() {
  20.161 -# Create a gdb script in case we should run inside gdb
  20.162 -    GDBSCR=/tmp/hsl.$$
  20.163 -    rm -f $GDBSCR
  20.164 -    cat >>$GDBSCR <<EOF
  20.165 -cd `pwd`
  20.166 -handle SIGUSR1 nostop noprint
  20.167 -handle SIGUSR2 nostop noprint
  20.168 -set args $JPARMS
  20.169 -file $LAUNCHER
  20.170 -directory $GDBSRCDIR
  20.171 -# Get us to a point where we can set breakpoints in libjvm.so
  20.172 -break InitializeJVM
  20.173 -run
  20.174 -# Stop in InitializeJVM
  20.175 -delete 1
  20.176 -# We can now set breakpoints wherever we like
  20.177 -EOF
  20.178 -}
  20.179 -
  20.180 -
  20.181 -case "$MODE" in
  20.182 -    gdb)
  20.183 -	init_gdb
  20.184 -        $GDB -x $GDBSCR
  20.185 -	rm -f $GDBSCR
  20.186 -        ;;
  20.187 -    gud)
  20.188 -	init_gdb
  20.189 -# First find out what emacs version we're using, so that we can
  20.190 -# use the new pretty GDB mode if emacs -version >= 22.1
  20.191 -	case `$EMACS -version 2> /dev/null` in
  20.192 -	    *GNU\ Emacs\ 2[23]*)
  20.193 -	    emacs_gud_cmd="gdba"
  20.194 -	    emacs_gud_args="--annotate=3"
  20.195 -	    ;;
  20.196 -	    *)
  20.197 -		emacs_gud_cmd="gdb"
  20.198 -		emacs_gud_args=
  20.199 -		;;
  20.200 -	esac
  20.201 -        $EMACS --eval "($emacs_gud_cmd \"$GDB $emacs_gud_args -x $GDBSCR\")";
  20.202 -	rm -f $GDBSCR
  20.203 -        ;;
  20.204 -    dbx)
  20.205 -        $DBX -s $HOME/.dbxrc $LAUNCHER $JPARMS
  20.206 -        ;;
  20.207 -    valgrind)
  20.208 -        echo Warning: Defaulting to 16Mb heap to make Valgrind run faster, use -Xmx for larger heap
  20.209 -        echo
  20.210 -        $VALGRIND --tool=memcheck --leak-check=yes --num-callers=50 $LAUNCHER -Xmx16m $JPARMS
  20.211 -        ;;
  20.212 -    run)
  20.213 -        LD_PRELOAD=$PRELOADING exec $LAUNCHER $JPARMS
  20.214 -        ;;
  20.215 -    *)
  20.216 -        echo Error: Internal error, unknown launch mode \"$MODE\"
  20.217 -        exit 1
  20.218 -        ;;
  20.219 -esac
  20.220 -RETVAL=$?
  20.221 -exit $RETVAL
    21.1 --- a/src/os/windows/launcher/java_md.c	Mon May 06 13:53:13 2013 -0700
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,1507 +0,0 @@
    21.4 -/*
    21.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    21.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 - *
    21.8 - * This code is free software; you can redistribute it and/or modify it
    21.9 - * under the terms of the GNU General Public License version 2 only, as
   21.10 - * published by the Free Software Foundation.
   21.11 - *
   21.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 - * version 2 for more details (a copy is included in the LICENSE file that
   21.16 - * accompanied this code).
   21.17 - *
   21.18 - * You should have received a copy of the GNU General Public License version
   21.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 - *
   21.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 - * or visit www.oracle.com if you need additional information or have any
   21.24 - * questions.
   21.25 - *
   21.26 - */
   21.27 -
   21.28 -#include <ctype.h>
   21.29 -#include <windows.h>
   21.30 -#include <io.h>
   21.31 -#include <process.h>
   21.32 -#include <stdlib.h>
   21.33 -#include <stdio.h>
   21.34 -#include <string.h>
   21.35 -#include <sys/types.h>
   21.36 -#include <sys/stat.h>
   21.37 -
   21.38 -#include <jni.h>
   21.39 -#include "java.h"
   21.40 -#ifndef GAMMA
   21.41 -#include "version_comp.h"
   21.42 -#endif
   21.43 -
   21.44 -#define JVM_DLL "jvm.dll"
   21.45 -#define JAVA_DLL "java.dll"
   21.46 -#define CRT_DLL "msvcr71.dll"
   21.47 -
   21.48 -/*
   21.49 - * Prototypes.
   21.50 - */
   21.51 -static jboolean GetPublicJREHome(char *path, jint pathsize);
   21.52 -static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
   21.53 -                           char *jvmpath, jint jvmpathsize);
   21.54 -static jboolean GetJREPath(char *path, jint pathsize);
   21.55 -static void EnsureJreInstallation(const char *jrepath);
   21.56 -
   21.57 -/* We supports warmup for UI stack that is performed in parallel
   21.58 - * to VM initialization.
   21.59 - * This helps to improve startup of UI application as warmup phase
   21.60 - * might be long due to initialization of OS or hardware resources.
   21.61 - * It is not CPU bound and therefore it does not interfere with VM init.
   21.62 - * Obviously such warmup only has sense for UI apps and therefore it needs
   21.63 - * to be explicitly requested by passing -Dsun.awt.warmup=true property
   21.64 - * (this is always the case for plugin/javaws).
   21.65 - *
   21.66 - * Implementation launches new thread after VM starts and use it to perform
   21.67 - * warmup code (platform dependent).
   21.68 - * This thread is later reused as AWT toolkit thread as graphics toolkit
   21.69 - * often assume that they are used from the same thread they were launched on.
   21.70 - *
   21.71 - * At the moment we only support warmup for D3D. It only possible on windows
   21.72 - * and only if other flags do not prohibit this (e.g. OpenGL support requested).
   21.73 - */
   21.74 -#undef ENABLE_AWT_PRELOAD
   21.75 -#ifndef JAVA_ARGS /* turn off AWT preloading for javac, jar, etc */
   21.76 -  #ifdef _X86_ /* for now disable AWT preloading for 64bit */
   21.77 -    #define ENABLE_AWT_PRELOAD
   21.78 -  #endif
   21.79 -#endif
   21.80 -
   21.81 -#ifdef ENABLE_AWT_PRELOAD
   21.82 -/* "AWT was preloaded" flag;
   21.83 - * Turned on by AWTPreload().
   21.84 - */
   21.85 -int awtPreloaded = 0;
   21.86 -
   21.87 -/* Calls a function with the name specified.
   21.88 - * The function must be int(*fn)(void).
   21.89 - */
   21.90 -int AWTPreload(const char *funcName);
   21.91 -/* Stops AWT preloading. */
   21.92 -void AWTPreloadStop();
   21.93 -
   21.94 -/* D3D preloading */
   21.95 -/* -1: not initialized; 0: OFF, 1: ON */
   21.96 -int awtPreloadD3D = -1;
   21.97 -/* Command line parameter to swith D3D preloading on. */
   21.98 -#define PARAM_PRELOAD_D3D "-Dsun.awt.warmup"
   21.99 -/* D3D/OpenGL management parameters (may disable D3D preloading) */
  21.100 -#define PARAM_NODDRAW "-Dsun.java2d.noddraw"
  21.101 -#define PARAM_D3D "-Dsun.java2d.d3d"
  21.102 -#define PARAM_OPENGL "-Dsun.java2d.opengl"
  21.103 -/* funtion in awt.dll (src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp) */
  21.104 -#define D3D_PRELOAD_FUNC "preloadD3D"
  21.105 -
  21.106 -
  21.107 -/* Extracts value of a parameter with the specified name
  21.108 - * from command line argument (returns pointer in the argument).
  21.109 - * Returns NULL if the argument does not contains the parameter.
  21.110 - * e.g.:
  21.111 - * GetParamValue("theParam", "theParam=value") returns pointer to "value".
  21.112 - */
  21.113 -const char * GetParamValue(const char *paramName, const char *arg) {
  21.114 -    int nameLen = strlen(paramName);
  21.115 -    if (strncmp(paramName, arg, nameLen) == 0) {
  21.116 -        // arg[nameLen] is valid (may contain final NULL)
  21.117 -        if (arg[nameLen] == '=') {
  21.118 -            return arg + nameLen + 1;
  21.119 -        }
  21.120 -    }
  21.121 -    return NULL;
  21.122 -}
  21.123 -
  21.124 -/* Checks if commandline argument contains property specified
  21.125 - * and analyze it as boolean property (true/false).
  21.126 - * Returns -1 if the argument does not contain the parameter;
  21.127 - * Returns 1 if the argument contains the parameter and its value is "true";
  21.128 - * Returns 0 if the argument contains the parameter and its value is "false".
  21.129 - */
  21.130 -int GetBoolParamValue(const char *paramName, const char *arg) {
  21.131 -    const char * paramValue = GetParamValue(paramName, arg);
  21.132 -    if (paramValue != NULL) {
  21.133 -        if (stricmp(paramValue, "true") == 0) {
  21.134 -            return 1;
  21.135 -        }
  21.136 -        if (stricmp(paramValue, "false") == 0) {
  21.137 -            return 0;
  21.138 -        }
  21.139 -    }
  21.140 -    return -1;
  21.141 -}
  21.142 -#endif /* ENABLE_AWT_PRELOAD */
  21.143 -
  21.144 -
  21.145 -const char *
  21.146 -GetArch()
  21.147 -{
  21.148 -
  21.149 -#ifdef _M_AMD64
  21.150 -    return "amd64";
  21.151 -#elif defined(_M_IA64)
  21.152 -    return "ia64";
  21.153 -#else
  21.154 -    return "i386";
  21.155 -#endif
  21.156 -}
  21.157 -
  21.158 -/*
  21.159 - *
  21.160 - */
  21.161 -void
  21.162 -CreateExecutionEnvironment(int *_argc,
  21.163 -                           char ***_argv,
  21.164 -                           char jrepath[],
  21.165 -                           jint so_jrepath,
  21.166 -                           char jvmpath[],
  21.167 -                           jint so_jvmpath,
  21.168 -                           char **original_argv) {
  21.169 -#ifndef GAMMA
  21.170 -   char * jvmtype;
  21.171 -
  21.172 -    /* Find out where the JRE is that we will be using. */
  21.173 -    if (!GetJREPath(jrepath, so_jrepath)) {
  21.174 -        ReportErrorMessage("Error: could not find Java SE Runtime Environment.",
  21.175 -                           JNI_TRUE);
  21.176 -        exit(2);
  21.177 -    }
  21.178 -
  21.179 -    /* Do this before we read jvm.cfg */
  21.180 -    EnsureJreInstallation(jrepath);
  21.181 -
  21.182 -    /* Find the specified JVM type */
  21.183 -    if (ReadKnownVMs(jrepath, (char*)GetArch(), JNI_FALSE) < 1) {
  21.184 -        ReportErrorMessage("Error: no known VMs. (check for corrupt jvm.cfg file)",
  21.185 -                           JNI_TRUE);
  21.186 -        exit(1);
  21.187 -    }
  21.188 -    jvmtype = CheckJvmType(_argc, _argv, JNI_FALSE);
  21.189 -
  21.190 -    jvmpath[0] = '\0';
  21.191 -    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
  21.192 -        char * message=NULL;
  21.193 -        const char * format = "Error: no `%s' JVM at `%s'.";
  21.194 -        message = (char *)JLI_MemAlloc((strlen(format)+strlen(jvmtype)+
  21.195 -                                    strlen(jvmpath)) * sizeof(char));
  21.196 -        sprintf(message,format, jvmtype, jvmpath);
  21.197 -        ReportErrorMessage(message, JNI_TRUE);
  21.198 -        exit(4);
  21.199 -    }
  21.200 -    /* If we got here, jvmpath has been correctly initialized. */
  21.201 -
  21.202 -#else  /* ifndef GAMMA */
  21.203 -
  21.204 -    /*
  21.205 -     * gamma launcher is simpler in that it doesn't handle VM flavors, data
  21.206 -     * model, etc. Assuming everything is set-up correctly
  21.207 -     * all we need to do here is to return correct path names. See also
  21.208 -     * GetJVMPath() and GetApplicationHome().
  21.209 -     */
  21.210 -
  21.211 -  {
  21.212 -    if (!GetJREPath(jrepath, so_jrepath) ) {
  21.213 -       ReportErrorMessage("Error: could not find Java SE Runtime Environment.",
  21.214 -                          JNI_TRUE);
  21.215 -       exit(2);
  21.216 -    }
  21.217 -
  21.218 -    if (!GetJVMPath(jrepath, NULL, jvmpath, so_jvmpath)) {
  21.219 -       char * message=NULL;
  21.220 -       const char * format = "Error: no JVM at `%s'.";
  21.221 -       message = (char *)JLI_MemAlloc((strlen(format)+
  21.222 -                                       strlen(jvmpath)) * sizeof(char));
  21.223 -       sprintf(message, format, jvmpath);
  21.224 -       ReportErrorMessage(message, JNI_TRUE);
  21.225 -       exit(4);
  21.226 -    }
  21.227 -  }
  21.228 -
  21.229 -#endif  /* ifndef GAMMA */
  21.230 -
  21.231 -}
  21.232 -
  21.233 -
  21.234 -static jboolean
  21.235 -LoadMSVCRT()
  21.236 -{
  21.237 -    // Only do this once
  21.238 -    static int loaded = 0;
  21.239 -    char crtpath[MAXPATHLEN];
  21.240 -
  21.241 -    if (!loaded) {
  21.242 -        /*
  21.243 -         * The Microsoft C Runtime Library needs to be loaded first.  A copy is
  21.244 -         * assumed to be present in the "JRE path" directory.  If it is not found
  21.245 -         * there (or "JRE path" fails to resolve), skip the explicit load and let
  21.246 -         * nature take its course, which is likely to be a failure to execute.
  21.247 -         */
  21.248 -        if (GetJREPath(crtpath, MAXPATHLEN)) {
  21.249 -            (void)strcat(crtpath, "\\bin\\" CRT_DLL);   /* Add crt dll */
  21.250 -            if (_launcher_debug) {
  21.251 -                printf("CRT path is %s\n", crtpath);
  21.252 -            }
  21.253 -            if (_access(crtpath, 0) == 0) {
  21.254 -                if (LoadLibrary(crtpath) == 0) {
  21.255 -                    ReportErrorMessage2("Error loading: %s", crtpath, JNI_TRUE);
  21.256 -                    return JNI_FALSE;
  21.257 -                }
  21.258 -            }
  21.259 -        }
  21.260 -        loaded = 1;
  21.261 -    }
  21.262 -    return JNI_TRUE;
  21.263 -}
  21.264 -
  21.265 -/*
  21.266 - * The preJVMStart is a function in the jkernel.dll, which
  21.267 - * performs the final step of synthesizing back the decomposed
  21.268 - * modules  (partial install) to the full JRE. Any tool which
  21.269 - * uses the  JRE must peform this step to ensure the complete synthesis.
  21.270 - * The EnsureJreInstallation function calls preJVMStart based on
  21.271 - * the conditions outlined below, noting that the operation
  21.272 - * will fail silently if any of conditions are not met.
  21.273 - * NOTE: this call must be made before jvm.dll is loaded, or jvm.cfg
  21.274 - * is read, since jvm.cfg will be modified by the preJVMStart.
  21.275 - * 1. Are we on a supported platform.
  21.276 - * 2. Find the location of the JRE or the Kernel JRE.
  21.277 - * 3. check existence of JREHOME/lib/bundles
  21.278 - * 4. check jkernel.dll and invoke the entry-point
  21.279 - */
  21.280 -typedef VOID (WINAPI *PREJVMSTART)();
  21.281 -
  21.282 -static void
  21.283 -EnsureJreInstallation(const char* jrepath)
  21.284 -{
  21.285 -    HINSTANCE handle;
  21.286 -    char tmpbuf[MAXPATHLEN];
  21.287 -    PREJVMSTART PreJVMStart;
  21.288 -    struct stat s;
  21.289 -
  21.290 -    /* 32 bit windows only please */
  21.291 -    if (strcmp(GetArch(), "i386") != 0 ) {
  21.292 -        if (_launcher_debug) {
  21.293 -            printf("EnsureJreInstallation:unsupported platform\n");
  21.294 -        }
  21.295 -        return;
  21.296 -    }
  21.297 -    /* Does our bundle directory exist ? */
  21.298 -    strcpy(tmpbuf, jrepath);
  21.299 -    strcat(tmpbuf, "\\lib\\bundles");
  21.300 -    if (stat(tmpbuf, &s) != 0) {
  21.301 -        if (_launcher_debug) {
  21.302 -            printf("EnsureJreInstallation:<%s>:not found\n", tmpbuf);
  21.303 -        }
  21.304 -        return;
  21.305 -    }
  21.306 -    /* Does our jkernel dll exist ? */
  21.307 -    strcpy(tmpbuf, jrepath);
  21.308 -    strcat(tmpbuf, "\\bin\\jkernel.dll");
  21.309 -    if (stat(tmpbuf, &s) != 0) {
  21.310 -        if (_launcher_debug) {
  21.311 -            printf("EnsureJreInstallation:<%s>:not found\n", tmpbuf);
  21.312 -        }
  21.313 -        return;
  21.314 -    }
  21.315 -    /* The Microsoft C Runtime Library needs to be loaded first. */
  21.316 -    if (!LoadMSVCRT()) {
  21.317 -        if (_launcher_debug) {
  21.318 -            printf("EnsureJreInstallation:could not load C runtime DLL\n");
  21.319 -        }
  21.320 -        return;
  21.321 -    }
  21.322 -    /* Load the jkernel.dll */
  21.323 -    if ((handle = LoadLibrary(tmpbuf)) == 0) {
  21.324 -        if (_launcher_debug) {
  21.325 -            printf("EnsureJreInstallation:%s:load failed\n", tmpbuf);
  21.326 -        }
  21.327 -        return;
  21.328 -    }
  21.329 -    /* Get the function address */
  21.330 -    PreJVMStart = (PREJVMSTART)GetProcAddress(handle, "preJVMStart");
  21.331 -    if (PreJVMStart == NULL) {
  21.332 -        if (_launcher_debug) {
  21.333 -            printf("EnsureJreInstallation:preJVMStart:function lookup failed\n");
  21.334 -        }
  21.335 -        FreeLibrary(handle);
  21.336 -        return;
  21.337 -    }
  21.338 -    PreJVMStart();
  21.339 -    if (_launcher_debug) {
  21.340 -        printf("EnsureJreInstallation:preJVMStart:called\n");
  21.341 -    }
  21.342 -    FreeLibrary(handle);
  21.343 -    return;
  21.344 -}
  21.345 -
  21.346 -/*
  21.347 - * Find path to JRE based on .exe's location or registry settings.
  21.348 - */
  21.349 -jboolean
  21.350 -GetJREPath(char *path, jint pathsize)
  21.351 -{
  21.352 -    char javadll[MAXPATHLEN];
  21.353 -    struct stat s;
  21.354 -
  21.355 -    if (GetApplicationHome(path, pathsize)) {
  21.356 -        /* Is JRE co-located with the application? */
  21.357 -        sprintf(javadll, "%s\\bin\\" JAVA_DLL, path);
  21.358 -        if (stat(javadll, &s) == 0) {
  21.359 -            goto found;
  21.360 -        }
  21.361 -
  21.362 -        /* Does this app ship a private JRE in <apphome>\jre directory? */
  21.363 -        sprintf(javadll, "%s\\jre\\bin\\" JAVA_DLL, path);
  21.364 -        if (stat(javadll, &s) == 0) {
  21.365 -            strcat(path, "\\jre");
  21.366 -            goto found;
  21.367 -        }
  21.368 -    }
  21.369 -
  21.370 -#ifndef GAMMA
  21.371 -    /* Look for a public JRE on this machine. */
  21.372 -    if (GetPublicJREHome(path, pathsize)) {
  21.373 -        goto found;
  21.374 -    }
  21.375 -#endif
  21.376 -
  21.377 -    fprintf(stderr, "Error: could not find " JAVA_DLL "\n");
  21.378 -    return JNI_FALSE;
  21.379 -
  21.380 - found:
  21.381 -    if (_launcher_debug)
  21.382 -      printf("JRE path is %s\n", path);
  21.383 -    return JNI_TRUE;
  21.384 -}
  21.385 -
  21.386 -/*
  21.387 - * Given a JRE location and a JVM type, construct what the name the
  21.388 - * JVM shared library will be.  Return true, if such a library
  21.389 - * exists, false otherwise.
  21.390 - */
  21.391 -static jboolean
  21.392 -GetJVMPath(const char *jrepath, const char *jvmtype,
  21.393 -           char *jvmpath, jint jvmpathsize)
  21.394 -{
  21.395 -    struct stat s;
  21.396 -
  21.397 -#ifndef GAMMA
  21.398 -    if (strchr(jvmtype, '/') || strchr(jvmtype, '\\')) {
  21.399 -        sprintf(jvmpath, "%s\\" JVM_DLL, jvmtype);
  21.400 -    } else {
  21.401 -        sprintf(jvmpath, "%s\\bin\\%s\\" JVM_DLL, jrepath, jvmtype);
  21.402 -    }
  21.403 -#else
  21.404 -    /*
  21.405 -     * For gamma launcher, JVM is either built-in or in the same directory.
  21.406 -     * Either way we return "<exe_path>/jvm.dll" where <exe_path> is the
  21.407 -     * directory where gamma launcher is located.
  21.408 -     */
  21.409 -
  21.410 -    char *p;
  21.411 -    GetModuleFileName(0, jvmpath, jvmpathsize);
  21.412 -
  21.413 -    p = strrchr(jvmpath, '\\');
  21.414 -    if (p) {
  21.415 -       /* replace executable name with libjvm.so */
  21.416 -       snprintf(p + 1, jvmpathsize - (p + 1 - jvmpath), "%s", JVM_DLL);
  21.417 -    } else {
  21.418 -       /* this case shouldn't happen */
  21.419 -       snprintf(jvmpath, jvmpathsize, "%s", JVM_DLL);
  21.420 -    }
  21.421 -#endif /* ifndef GAMMA */
  21.422 -
  21.423 -    if (stat(jvmpath, &s) == 0) {
  21.424 -        return JNI_TRUE;
  21.425 -    } else {
  21.426 -        return JNI_FALSE;
  21.427 -    }
  21.428 -}
  21.429 -
  21.430 -/*
  21.431 - * Load a jvm from "jvmpath" and initialize the invocation functions.
  21.432 - */
  21.433 -jboolean
  21.434 -LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
  21.435 -{
  21.436 -#ifdef GAMMA
  21.437 -    /* JVM is directly linked with gamma launcher; no Loadlibrary() */
  21.438 -    ifn->CreateJavaVM = JNI_CreateJavaVM;
  21.439 -    ifn->GetDefaultJavaVMInitArgs = JNI_GetDefaultJavaVMInitArgs;
  21.440 -    return JNI_TRUE;
  21.441 -#else
  21.442 -    HINSTANCE handle;
  21.443 -
  21.444 -    if (_launcher_debug) {
  21.445 -        printf("JVM path is %s\n", jvmpath);
  21.446 -    }
  21.447 -
  21.448 -    /* The Microsoft C Runtime Library needs to be loaded first. */
  21.449 -    LoadMSVCRT();
  21.450 -
  21.451 -    /* Load the Java VM DLL */
  21.452 -    if ((handle = LoadLibrary(jvmpath)) == 0) {
  21.453 -        ReportErrorMessage2("Error loading: %s", (char *)jvmpath, JNI_TRUE);
  21.454 -        return JNI_FALSE;
  21.455 -    }
  21.456 -
  21.457 -    /* Now get the function addresses */
  21.458 -    ifn->CreateJavaVM =
  21.459 -        (void *)GetProcAddress(handle, "JNI_CreateJavaVM");
  21.460 -    ifn->GetDefaultJavaVMInitArgs =
  21.461 -        (void *)GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
  21.462 -    if (ifn->CreateJavaVM == 0 || ifn->GetDefaultJavaVMInitArgs == 0) {
  21.463 -        ReportErrorMessage2("Error: can't find JNI interfaces in: %s",
  21.464 -                            (char *)jvmpath, JNI_TRUE);
  21.465 -        return JNI_FALSE;
  21.466 -    }
  21.467 -
  21.468 -    return JNI_TRUE;
  21.469 -#endif /* ifndef GAMMA */
  21.470 -}
  21.471 -
  21.472 -/*
  21.473 - * If app is "c:\foo\bin\javac", then put "c:\foo" into buf.
  21.474 - */
  21.475 -jboolean
  21.476 -GetApplicationHome(char *buf, jint bufsize)
  21.477 -{
  21.478 -#ifndef GAMMA
  21.479 -    char *cp;
  21.480 -    GetModuleFileName(0, buf, bufsize);
  21.481 -    *strrchr(buf, '\\') = '\0'; /* remove .exe file name */
  21.482 -    if ((cp = strrchr(buf, '\\')) == 0) {
  21.483 -        /* This happens if the application is in a drive root, and
  21.484 -         * there is no bin directory. */
  21.485 -        buf[0] = '\0';
  21.486 -        return JNI_FALSE;
  21.487 -    }
  21.488 -    *cp = '\0';  /* remove the bin\ part */
  21.489 -    return JNI_TRUE;
  21.490 -
  21.491 -#else /* ifndef GAMMA */
  21.492 -
  21.493 -    char env[MAXPATHLEN + 1];
  21.494 -
  21.495 -    /* gamma launcher uses ALT_JAVA_HOME environment variable or jdkpath.txt file to find JDK/JRE */
  21.496 -
  21.497 -    if (getenv("ALT_JAVA_HOME") != NULL) {
  21.498 -       snprintf(buf, bufsize, "%s", getenv("ALT_JAVA_HOME"));
  21.499 -    }
  21.500 -    else {
  21.501 -       char path[MAXPATHLEN + 1];
  21.502 -       char* p;
  21.503 -       int len;
  21.504 -       FILE* fp;
  21.505 -
  21.506 -       // find the path to the currect executable
  21.507 -       len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
  21.508 -       if (len == 0 || len > MAXPATHLEN) {
  21.509 -          printf("Could not get directory of current executable.");
  21.510 -          return JNI_FALSE;
  21.511 -       }
  21.512 -       // remove last path component ("hotspot.exe")
  21.513 -       p = strrchr(path, '\\');
  21.514 -       if (p == NULL) {
  21.515 -          printf("Could not parse directory of current executable.\n");
  21.516 -          return JNI_FALSE;
  21.517 -       }
  21.518 -       *p = '\0';
  21.519 -
  21.520 -       // open jdkpath.txt and read JAVA_HOME from it
  21.521 -       if (strlen(path) + strlen("\\jdkpath.txt") + 1 >= MAXPATHLEN) {
  21.522 -          printf("Path too long: %s\n", path);
  21.523 -          return JNI_FALSE;
  21.524 -       }
  21.525 -       strcat(path, "\\jdkpath.txt");
  21.526 -       fp = fopen(path, "r");
  21.527 -       if (fp == NULL) {
  21.528 -          printf("Could not open file %s to get path to JDK.\n", path);
  21.529 -          return JNI_FALSE;
  21.530 -       }
  21.531 -
  21.532 -       if (fgets(buf, bufsize, fp) == NULL) {
  21.533 -          printf("Could not read from file %s to get path to JDK.\n", path);
  21.534 -          fclose(fp);
  21.535 -          return JNI_FALSE;
  21.536 -       }
  21.537 -       // trim the buffer
  21.538 -       p = buf + strlen(buf) - 1;
  21.539 -       while(isspace(*p)) {
  21.540 -          *p = '\0';
  21.541 -          p--;
  21.542 -       }
  21.543 -       fclose(fp);
  21.544 -    }
  21.545 -
  21.546 -    _snprintf(env, MAXPATHLEN, "JAVA_HOME=%s", buf);
  21.547 -    _putenv(env);
  21.548 -
  21.549 -    return JNI_TRUE;
  21.550 -#endif /* ifndef GAMMA */
  21.551 -}
  21.552 -
  21.553 -#ifdef JAVAW
  21.554 -__declspec(dllimport) char **__initenv;
  21.555 -
  21.556 -int WINAPI
  21.557 -WinMain(HINSTANCE inst, HINSTANCE previnst, LPSTR cmdline, int cmdshow)
  21.558 -{
  21.559 -    int   ret;
  21.560 -
  21.561 -    __initenv = _environ;
  21.562 -    ret = main(__argc, __argv);
  21.563 -
  21.564 -    return ret;
  21.565 -}
  21.566 -#endif
  21.567 -
  21.568 -#ifndef GAMMA
  21.569 -
  21.570 -/*
  21.571 - * Helpers to look in the registry for a public JRE.
  21.572 - */
  21.573 -                    /* Same for 1.5.0, 1.5.1, 1.5.2 etc. */
  21.574 -#define DOTRELEASE  JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
  21.575 -#define JRE_KEY     "Software\\JavaSoft\\Java Runtime Environment"
  21.576 -
  21.577 -static jboolean
  21.578 -GetStringFromRegistry(HKEY key, const char *name, char *buf, jint bufsize)
  21.579 -{
  21.580 -    DWORD type, size;
  21.581 -
  21.582 -    if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0
  21.583 -        && type == REG_SZ
  21.584 -        && (size < (unsigned int)bufsize)) {
  21.585 -        if (RegQueryValueEx(key, name, 0, 0, buf, &size) == 0) {
  21.586 -            return JNI_TRUE;
  21.587 -        }
  21.588 -    }
  21.589 -    return JNI_FALSE;
  21.590 -}
  21.591 -
  21.592 -static jboolean
  21.593 -GetPublicJREHome(char *buf, jint bufsize)
  21.594 -{
  21.595 -    HKEY key, subkey;
  21.596 -    char version[MAXPATHLEN];
  21.597 -
  21.598 -    /*
  21.599 -     * Note: There is a very similar implementation of the following
  21.600 -     * registry reading code in the Windows java control panel (javacp.cpl).
  21.601 -     * If there are bugs here, a similar bug probably exists there.  Hence,
  21.602 -     * changes here require inspection there.
  21.603 -     */
  21.604 -
  21.605 -    /* Find the current version of the JRE */
  21.606 -    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) != 0) {
  21.607 -        fprintf(stderr, "Error opening registry key '" JRE_KEY "'\n");
  21.608 -        return JNI_FALSE;
  21.609 -    }
  21.610 -
  21.611 -    if (!GetStringFromRegistry(key, "CurrentVersion",
  21.612 -                               version, sizeof(version))) {
  21.613 -        fprintf(stderr, "Failed reading value of registry key:\n\t"
  21.614 -                JRE_KEY "\\CurrentVersion\n");
  21.615 -        RegCloseKey(key);
  21.616 -        return JNI_FALSE;
  21.617 -    }
  21.618 -
  21.619 -    if (strcmp(version, DOTRELEASE) != 0) {
  21.620 -        fprintf(stderr, "Registry key '" JRE_KEY "\\CurrentVersion'\nhas "
  21.621 -                "value '%s', but '" DOTRELEASE "' is required.\n", version);
  21.622 -        RegCloseKey(key);
  21.623 -        return JNI_FALSE;
  21.624 -    }
  21.625 -
  21.626 -    /* Find directory where the current version is installed. */
  21.627 -    if (RegOpenKeyEx(key, version, 0, KEY_READ, &subkey) != 0) {
  21.628 -        fprintf(stderr, "Error opening registry key '"
  21.629 -                JRE_KEY "\\%s'\n", version);
  21.630 -        RegCloseKey(key);
  21.631 -        return JNI_FALSE;
  21.632 -    }
  21.633 -
  21.634 -    if (!GetStringFromRegistry(subkey, "JavaHome", buf, bufsize)) {
  21.635 -        fprintf(stderr, "Failed reading value of registry key:\n\t"
  21.636 -                JRE_KEY "\\%s\\JavaHome\n", version);
  21.637 -        RegCloseKey(key);
  21.638 -        RegCloseKey(subkey);
  21.639 -        return JNI_FALSE;
  21.640 -    }
  21.641 -
  21.642 -    if (_launcher_debug) {
  21.643 -        char micro[MAXPATHLEN];
  21.644 -        if (!GetStringFromRegistry(subkey, "MicroVersion", micro,
  21.645 -                                   sizeof(micro))) {
  21.646 -            printf("Warning: Can't read MicroVersion\n");
  21.647 -            micro[0] = '\0';
  21.648 -        }
  21.649 -        printf("Version major.minor.micro = %s.%s\n", version, micro);
  21.650 -    }
  21.651 -
  21.652 -    RegCloseKey(key);
  21.653 -    RegCloseKey(subkey);
  21.654 -    return JNI_TRUE;
  21.655 -}
  21.656 -
  21.657 -#endif /* ifndef GAMMA */
  21.658 -
  21.659 -/*
  21.660 - * Support for doing cheap, accurate interval timing.
  21.661 - */
  21.662 -static jboolean counterAvailable = JNI_FALSE;
  21.663 -static jboolean counterInitialized = JNI_FALSE;
  21.664 -static LARGE_INTEGER counterFrequency;
  21.665 -
  21.666 -jlong CounterGet()
  21.667 -{
  21.668 -    LARGE_INTEGER count;
  21.669 -
  21.670 -    if (!counterInitialized) {
  21.671 -        counterAvailable = QueryPerformanceFrequency(&counterFrequency);
  21.672 -        counterInitialized = JNI_TRUE;
  21.673 -    }
  21.674 -    if (!counterAvailable) {
  21.675 -        return 0;
  21.676 -    }
  21.677 -    QueryPerformanceCounter(&count);
  21.678 -    return (jlong)(count.QuadPart);
  21.679 -}
  21.680 -
  21.681 -jlong Counter2Micros(jlong counts)
  21.682 -{
  21.683 -    if (!counterAvailable || !counterInitialized) {
  21.684 -        return 0;
  21.685 -    }
  21.686 -    return (counts * 1000 * 1000)/counterFrequency.QuadPart;
  21.687 -}
  21.688 -
  21.689 -void ReportErrorMessage(char * message, jboolean always) {
  21.690 -#ifdef JAVAW
  21.691 -  if (message != NULL) {
  21.692 -    MessageBox(NULL, message, "Java Virtual Machine Launcher",
  21.693 -               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
  21.694 -  }
  21.695 -#else
  21.696 -  if (always) {
  21.697 -    fprintf(stderr, "%s\n", message);
  21.698 -  }
  21.699 -#endif
  21.700 -}
  21.701 -
  21.702 -void ReportErrorMessage2(char * format, char * string, jboolean always) {
  21.703 -  /*
  21.704 -   * The format argument must be a printf format string with one %s
  21.705 -   * argument, which is passed the string argument.
  21.706 -   */
  21.707 -#ifdef JAVAW
  21.708 -  size_t size;
  21.709 -  char * message;
  21.710 -  size = strlen(format) + strlen(string);
  21.711 -  message = (char*)JLI_MemAlloc(size*sizeof(char));
  21.712 -  sprintf(message, (const char *)format, string);
  21.713 -
  21.714 -  if (message != NULL) {
  21.715 -    MessageBox(NULL, message, "Java Virtual Machine Launcher",
  21.716 -               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
  21.717 -    JLI_MemFree(message);
  21.718 -  }
  21.719 -#else
  21.720 -  if (always) {
  21.721 -    fprintf(stderr, (const char *)format, string);
  21.722 -    fprintf(stderr, "\n");
  21.723 -  }
  21.724 -#endif
  21.725 -}
  21.726 -
  21.727 -/*
  21.728 - * As ReportErrorMessage2 (above) except the system message (if any)
  21.729 - * associated with this error is written to a second %s format specifier
  21.730 - * in the format argument.
  21.731 - */
  21.732 -void ReportSysErrorMessage2(char * format, char * string, jboolean always) {
  21.733 -  int   save_errno = errno;
  21.734 -  DWORD errval;
  21.735 -  int   freeit = 0;
  21.736 -  char  *errtext = NULL;
  21.737 -
  21.738 -  if ((errval = GetLastError()) != 0) {         /* Platform SDK / DOS Error */
  21.739 -    int n = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|
  21.740 -      FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_ALLOCATE_BUFFER,
  21.741 -      NULL, errval, 0, (LPTSTR)&errtext, 0, NULL);
  21.742 -    if (errtext == NULL || n == 0) {            /* Paranoia check */
  21.743 -      errtext = "";
  21.744 -      n = 0;
  21.745 -    } else {
  21.746 -      freeit = 1;
  21.747 -      if (n > 2) {                              /* Drop final CR, LF */
  21.748 -        if (errtext[n - 1] == '\n') n--;
  21.749 -        if (errtext[n - 1] == '\r') n--;
  21.750 -        errtext[n] = '\0';
  21.751 -      }
  21.752 -    }
  21.753 -  } else        /* C runtime error that has no corresponding DOS error code */
  21.754 -    errtext = strerror(save_errno);
  21.755 -
  21.756 -#ifdef JAVAW
  21.757 -  {
  21.758 -    size_t size;
  21.759 -    char * message;
  21.760 -    size = strlen(format) + strlen(string) + strlen(errtext);
  21.761 -    message = (char*)JLI_MemAlloc(size*sizeof(char));
  21.762 -    sprintf(message, (const char *)format, string, errtext);
  21.763 -
  21.764 -    if (message != NULL) {
  21.765 -      MessageBox(NULL, message, "Java Virtual Machine Launcher",
  21.766 -               (MB_OK|MB_ICONSTOP|MB_APPLMODAL));
  21.767 -      JLI_MemFree(message);
  21.768 -    }
  21.769 -  }
  21.770 -#else
  21.771 -  if (always) {
  21.772 -    fprintf(stderr, (const char *)format, string, errtext);
  21.773 -    fprintf(stderr, "\n");
  21.774 -  }
  21.775 -#endif
  21.776 -  if (freeit)
  21.777 -    (void)LocalFree((HLOCAL)errtext);
  21.778 -}
  21.779 -
  21.780 -void  ReportExceptionDescription(JNIEnv * env) {
  21.781 -#ifdef JAVAW
  21.782 -  /*
  21.783 -   * This code should be replaced by code which opens a window with
  21.784 -   * the exception detail message.
  21.785 -   */
  21.786 -  (*env)->ExceptionDescribe(env);
  21.787 -#else
  21.788 -  (*env)->ExceptionDescribe(env);
  21.789 -#endif
  21.790 -}
  21.791 -
  21.792 -
  21.793 -/*
  21.794 - * Return JNI_TRUE for an option string that has no effect but should
  21.795 - * _not_ be passed on to the vm; return JNI_FALSE otherwise. On
  21.796 - * windows, there are no options that should be screened in this
  21.797 - * manner.
  21.798 - */
  21.799 -jboolean RemovableMachineDependentOption(char * option) {
  21.800 -#ifdef ENABLE_AWT_PRELOAD
  21.801 -    if (awtPreloadD3D < 0) {
  21.802 -        /* Tests the command line parameter only if not set yet. */
  21.803 -        if (GetBoolParamValue(PARAM_PRELOAD_D3D, option) == 1) {
  21.804 -            awtPreloadD3D = 1;
  21.805 -        }
  21.806 -    }
  21.807 -    if (awtPreloadD3D != 0) {
  21.808 -        /* Don't test the command line parameters if already disabled. */
  21.809 -        if (GetBoolParamValue(PARAM_NODDRAW, option) == 1
  21.810 -            || GetBoolParamValue(PARAM_D3D, option) == 0
  21.811 -            || GetBoolParamValue(PARAM_OPENGL, option) == 1)
  21.812 -        {
  21.813 -            awtPreloadD3D = 0;
  21.814 -        }
  21.815 -    }
  21.816 -#endif /* ENABLE_AWT_PRELOAD */
  21.817 -
  21.818 -    return JNI_FALSE;
  21.819 -}
  21.820 -
  21.821 -void PrintMachineDependentOptions() {
  21.822 -  return;
  21.823 -}
  21.824 -
  21.825 -#ifndef GAMMA
  21.826 -
  21.827 -jboolean
  21.828 -ServerClassMachine() {
  21.829 -  jboolean result = JNI_FALSE;
  21.830 -#if   defined(NEVER_ACT_AS_SERVER_CLASS_MACHINE)
  21.831 -  result = JNI_FALSE;
  21.832 -#elif defined(ALWAYS_ACT_AS_SERVER_CLASS_MACHINE)
  21.833 -  result = JNI_TRUE;
  21.834 -#endif
  21.835 -  return result;
  21.836 -}
  21.837 -
  21.838 -/*
  21.839 - * Determine if there is an acceptable JRE in the registry directory top_key.
  21.840 - * Upon locating the "best" one, return a fully qualified path to it.
  21.841 - * "Best" is defined as the most advanced JRE meeting the constraints
  21.842 - * contained in the manifest_info. If no JRE in this directory meets the
  21.843 - * constraints, return NULL.
  21.844 - *
  21.845 - * It doesn't matter if we get an error reading the registry, or we just
  21.846 - * don't find anything interesting in the directory.  We just return NULL
  21.847 - * in either case.
  21.848 - */
  21.849 -static char *
  21.850 -ProcessDir(manifest_info* info, HKEY top_key) {
  21.851 -    DWORD   index = 0;
  21.852 -    HKEY    ver_key;
  21.853 -    char    name[MAXNAMELEN];
  21.854 -    int     len;
  21.855 -    char    *best = NULL;
  21.856 -
  21.857 -    /*
  21.858 -     * Enumerate "<top_key>/SOFTWARE/JavaSoft/Java Runtime Environment"
  21.859 -     * searching for the best available version.
  21.860 -     */
  21.861 -    while (RegEnumKey(top_key, index, name, MAXNAMELEN) == ERROR_SUCCESS) {
  21.862 -        index++;
  21.863 -        if (JLI_AcceptableRelease(name, info->jre_version))
  21.864 -            if ((best == NULL) || (JLI_ExactVersionId(name, best) > 0)) {
  21.865 -                if (best != NULL)
  21.866 -                    JLI_MemFree(best);
  21.867 -                best = JLI_StringDup(name);
  21.868 -            }
  21.869 -    }
  21.870 -
  21.871 -    /*
  21.872 -     * Extract "JavaHome" from the "best" registry directory and return
  21.873 -     * that path.  If no appropriate version was located, or there is an
  21.874 -     * error in extracting the "JavaHome" string, return null.
  21.875 -     */
  21.876 -    if (best == NULL)
  21.877 -        return (NULL);
  21.878 -    else {
  21.879 -        if (RegOpenKeyEx(top_key, best, 0, KEY_READ, &ver_key)
  21.880 -          != ERROR_SUCCESS) {
  21.881 -            JLI_MemFree(best);
  21.882 -            if (ver_key != NULL)
  21.883 -                RegCloseKey(ver_key);
  21.884 -            return (NULL);
  21.885 -        }
  21.886 -        JLI_MemFree(best);
  21.887 -        len = MAXNAMELEN;
  21.888 -        if (RegQueryValueEx(ver_key, "JavaHome", NULL, NULL, (LPBYTE)name, &len)
  21.889 -          != ERROR_SUCCESS) {
  21.890 -            if (ver_key != NULL)
  21.891 -                RegCloseKey(ver_key);
  21.892 -            return (NULL);
  21.893 -        }
  21.894 -        if (ver_key != NULL)
  21.895 -            RegCloseKey(ver_key);
  21.896 -        return (JLI_StringDup(name));
  21.897 -    }
  21.898 -}
  21.899 -
  21.900 -/*
  21.901 - * This is the global entry point. It examines the host for the optimal
  21.902 - * JRE to be used by scanning a set of registry entries.  This set of entries
  21.903 - * is hardwired on Windows as "Software\JavaSoft\Java Runtime Environment"
  21.904 - * under the set of roots "{ HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }".
  21.905 - *
  21.906 - * This routine simply opens each of these registry directories before passing
  21.907 - * control onto ProcessDir().
  21.908 - */
  21.909 -char *
  21.910 -LocateJRE(manifest_info* info) {
  21.911 -    HKEY    key = NULL;
  21.912 -    char    *path;
  21.913 -    int     key_index;
  21.914 -    HKEY    root_keys[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
  21.915 -
  21.916 -    for (key_index = 0; key_index <= 1; key_index++) {
  21.917 -        if (RegOpenKeyEx(root_keys[key_index], JRE_KEY, 0, KEY_READ, &key)
  21.918 -          == ERROR_SUCCESS)
  21.919 -            if ((path = ProcessDir(info, key)) != NULL) {
  21.920 -                if (key != NULL)
  21.921 -                    RegCloseKey(key);
  21.922 -                return (path);
  21.923 -            }
  21.924 -        if (key != NULL)
  21.925 -            RegCloseKey(key);
  21.926 -    }
  21.927 -    return NULL;
  21.928 -}
  21.929 -
  21.930 -
  21.931 -/*
  21.932 - * Local helper routine to isolate a single token (option or argument)
  21.933 - * from the command line.
  21.934 - *
  21.935 - * This routine accepts a pointer to a character pointer.  The first
  21.936 - * token (as defined by MSDN command-line argument syntax) is isolated
  21.937 - * from that string.
  21.938 - *
  21.939 - * Upon return, the input character pointer pointed to by the parameter s
  21.940 - * is updated to point to the remainding, unscanned, portion of the string,
  21.941 - * or to a null character if the entire string has been consummed.
  21.942 - *
  21.943 - * This function returns a pointer to a null-terminated string which
  21.944 - * contains the isolated first token, or to the null character if no
  21.945 - * token could be isolated.
  21.946 - *
  21.947 - * Note the side effect of modifying the input string s by the insertion
  21.948 - * of a null character, making it two strings.
  21.949 - *
  21.950 - * See "Parsing C Command-Line Arguments" in the MSDN Library for the
  21.951 - * parsing rule details.  The rule summary from that specification is:
  21.952 - *
  21.953 - *  * Arguments are delimited by white space, which is either a space or a tab.
  21.954 - *
  21.955 - *  * A string surrounded by double quotation marks is interpreted as a single
  21.956 - *    argument, regardless of white space contained within. A quoted string can
  21.957 - *    be embedded in an argument. Note that the caret (^) is not recognized as
  21.958 - *    an escape character or delimiter.
  21.959 - *
  21.960 - *  * A double quotation mark preceded by a backslash, \", is interpreted as a
  21.961 - *    literal double quotation mark (").
  21.962 - *
  21.963 - *  * Backslashes are interpreted literally, unless they immediately precede a
  21.964 - *    double quotation mark.
  21.965 - *
  21.966 - *  * If an even number of backslashes is followed by a double quotation mark,
  21.967 - *    then one backslash (\) is placed in the argv array for every pair of
  21.968 - *    backslashes (\\), and the double quotation mark (") is interpreted as a
  21.969 - *    string delimiter.
  21.970 - *
  21.971 - *  * If an odd number of backslashes is followed by a double quotation mark,
  21.972 - *    then one backslash (\) is placed in the argv array for every pair of
  21.973 - *    backslashes (\\) and the double quotation mark is interpreted as an
  21.974 - *    escape sequence by the remaining backslash, causing a literal double
  21.975 - *    quotation mark (") to be placed in argv.
  21.976 - */
  21.977 -static char*
  21.978 -nextarg(char** s) {
  21.979 -    char    *p = *s;
  21.980 -    char    *head;
  21.981 -    int     slashes = 0;
  21.982 -    int     inquote = 0;
  21.983 -
  21.984 -    /*
  21.985 -     * Strip leading whitespace, which MSDN defines as only space or tab.
  21.986 -     * (Hence, no locale specific "isspace" here.)
  21.987 -     */
  21.988 -    while (*p != (char)0 && (*p == ' ' || *p == '\t'))
  21.989 -        p++;
  21.990 -    head = p;                   /* Save the start of the token to return */
  21.991 -
  21.992 -    /*
  21.993 -     * Isolate a token from the command line.
  21.994 -     */
  21.995 -    while (*p != (char)0 && (inquote || !(*p == ' ' || *p == '\t'))) {
  21.996 -        if (*p == '\\' && *(p+1) == '"' && slashes % 2 == 0)
  21.997 -            p++;
  21.998 -        else if (*p == '"')
  21.999 -            inquote = !inquote;
 21.1000 -        slashes = (*p++ == '\\') ? slashes + 1 : 0;
 21.1001 -    }
 21.1002 -
 21.1003 -    /*
 21.1004 -     * If the token isolated isn't already terminated in a "char zero",
 21.1005 -     * then replace the whitespace character with one and move to the
 21.1006 -     * next character.
 21.1007 -     */
 21.1008 -    if (*p != (char)0)
 21.1009 -        *p++ = (char)0;
 21.1010 -
 21.1011 -    /*
 21.1012 -     * Update the parameter to point to the head of the remaining string
 21.1013 -     * reflecting the command line and return a pointer to the leading
 21.1014 -     * token which was isolated from the command line.
 21.1015 -     */
 21.1016 -    *s = p;
 21.1017 -    return (head);
 21.1018 -}
 21.1019 -
 21.1020 -/*
 21.1021 - * Local helper routine to return a string equivalent to the input string
 21.1022 - * s, but with quotes removed so the result is a string as would be found
 21.1023 - * in argv[].  The returned string should be freed by a call to JLI_MemFree().
 21.1024 - *
 21.1025 - * The rules for quoting (and escaped quotes) are:
 21.1026 - *
 21.1027 - *  1 A double quotation mark preceded by a backslash, \", is interpreted as a
 21.1028 - *    literal double quotation mark (").
 21.1029 - *
 21.1030 - *  2 Backslashes are interpreted literally, unless they immediately precede a
 21.1031 - *    double quotation mark.
 21.1032 - *
 21.1033 - *  3 If an even number of backslashes is followed by a double quotation mark,
 21.1034 - *    then one backslash (\) is placed in the argv array for every pair of
 21.1035 - *    backslashes (\\), and the double quotation mark (") is interpreted as a
 21.1036 - *    string delimiter.
 21.1037 - *
 21.1038 - *  4 If an odd number of backslashes is followed by a double quotation mark,
 21.1039 - *    then one backslash (\) is placed in the argv array for every pair of
 21.1040 - *    backslashes (\\) and the double quotation mark is interpreted as an
 21.1041 - *    escape sequence by the remaining backslash, causing a literal double
 21.1042 - *    quotation mark (") to be placed in argv.
 21.1043 - */
 21.1044 -static char*
 21.1045 -unquote(const char *s) {
 21.1046 -    const char *p = s;          /* Pointer to the tail of the original string */
 21.1047 -    char *un = (char*)JLI_MemAlloc(strlen(s) + 1);  /* Ptr to unquoted string */
 21.1048 -    char *pun = un;             /* Pointer to the tail of the unquoted string */
 21.1049 -
 21.1050 -    while (*p != '\0') {
 21.1051 -        if (*p == '"') {
 21.1052 -            p++;
 21.1053 -        } else if (*p == '\\') {
 21.1054 -            const char *q = p + strspn(p,"\\");
 21.1055 -            if (*q == '"')
 21.1056 -                do {
 21.1057 -                    *pun++ = '\\';
 21.1058 -                    p += 2;
 21.1059 -                 } while (*p == '\\' && p < q);
 21.1060 -            else
 21.1061 -                while (p < q)
 21.1062 -                    *pun++ = *p++;
 21.1063 -        } else {
 21.1064 -            *pun++ = *p++;
 21.1065 -        }
 21.1066 -    }
 21.1067 -    *pun = '\0';
 21.1068 -    return un;
 21.1069 -}
 21.1070 -
 21.1071 -/*
 21.1072 - * Given a path to a jre to execute, this routine checks if this process
 21.1073 - * is indeed that jre.  If not, it exec's that jre.
 21.1074 - *
 21.1075 - * We want to actually check the paths rather than just the version string
 21.1076 - * built into the executable, so that given version specification will yield
 21.1077 - * the exact same Java environment, regardless of the version of the arbitrary
 21.1078 - * launcher we start with.
 21.1079 - */
 21.1080 -void
 21.1081 -ExecJRE(char *jre, char **argv) {
 21.1082 -    int     len;
 21.1083 -    char    *progname;
 21.1084 -    char    path[MAXPATHLEN + 1];
 21.1085 -
 21.1086 -    /*
 21.1087 -     * Determine the executable we are building (or in the rare case, running).
 21.1088 -     */
 21.1089 -#ifdef JAVA_ARGS  /* javac, jar and friends. */
 21.1090 -    progname = "java";
 21.1091 -#else             /* java, oldjava, javaw and friends */
 21.1092 -#ifdef PROGNAME
 21.1093 -    progname = PROGNAME;
 21.1094 -#else
 21.1095 -    {
 21.1096 -        char *s;
 21.1097 -        progname = *argv;
 21.1098 -        if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
 21.1099 -            progname = s + 1;
 21.1100 -        }
 21.1101 -    }
 21.1102 -#endif /* PROGNAME */
 21.1103 -#endif /* JAVA_ARGS */
 21.1104 -
 21.1105 -    /*
 21.1106 -     * Resolve the real path to the currently running launcher.
 21.1107 -     */
 21.1108 -    len = GetModuleFileName(NULL, path, MAXPATHLEN + 1);
 21.1109 -    if (len == 0 || len > MAXPATHLEN) {
 21.1110 -        ReportSysErrorMessage2(
 21.1111 -          "Unable to resolve path to current %s executable: %s",
 21.1112 -          progname, JNI_TRUE);
 21.1113 -        exit(1);
 21.1114 -    }
 21.1115 -
 21.1116 -    if (_launcher_debug) {
 21.1117 -        printf("ExecJRE: old: %s\n", path);
 21.1118 -        printf("ExecJRE: new: %s\n", jre);
 21.1119 -    }
 21.1120 -
 21.1121 -    /*
 21.1122 -     * If the path to the selected JRE directory is a match to the initial
 21.1123 -     * portion of the path to the currently executing JRE, we have a winner!
 21.1124 -     * If so, just return. (strnicmp() is the Windows equiv. of strncasecmp().)
 21.1125 -     */
 21.1126 -    if (strnicmp(jre, path, strlen(jre)) == 0)
 21.1127 -        return;                 /* I am the droid you were looking for */
 21.1128 -
 21.1129 -    /*
 21.1130 -     * If this isn't the selected version, exec the selected version.
 21.1131 -     */
 21.1132 -    (void)strcat(strcat(strcpy(path, jre), "\\bin\\"), progname);
 21.1133 -    (void)strcat(path, ".exe");
 21.1134 -
 21.1135 -    /*
 21.1136 -     * Although Windows has an execv() entrypoint, it doesn't actually
 21.1137 -     * overlay a process: it can only create a new process and terminate
 21.1138 -     * the old process.  Therefore, any processes waiting on the initial
 21.1139 -     * process wake up and they shouldn't.  Hence, a chain of pseudo-zombie
 21.1140 -     * processes must be retained to maintain the proper wait semantics.
 21.1141 -     * Fortunately the image size of the launcher isn't too large at this
 21.1142 -     * time.
 21.1143 -     *
 21.1144 -     * If it weren't for this semantic flaw, the code below would be ...
 21.1145 -     *
 21.1146 -     *     execv(path, argv);
 21.1147 -     *     ReportErrorMessage2("Exec of %s failed\n", path, JNI_TRUE);
 21.1148 -     *     exit(1);
 21.1149 -     *
 21.1150 -     * The incorrect exec semantics could be addressed by:
 21.1151 -     *
 21.1152 -     *     exit((int)spawnv(_P_WAIT, path, argv));
 21.1153 -     *
 21.1154 -     * Unfortunately, a bug in Windows spawn/exec impementation prevents
 21.1155 -     * this from completely working.  All the Windows POSIX process creation
 21.1156 -     * interfaces are implemented as wrappers around the native Windows
 21.1157 -     * function CreateProcess().  CreateProcess() takes a single string
 21.1158 -     * to specify command line options and arguments, so the POSIX routine
 21.1159 -     * wrappers build a single string from the argv[] array and in the
 21.1160 -     * process, any quoting information is lost.
 21.1161 -     *
 21.1162 -     * The solution to this to get the original command line, to process it
 21.1163 -     * to remove the new multiple JRE options (if any) as was done for argv
 21.1164 -     * in the common SelectVersion() routine and finally to pass it directly
 21.1165 -     * to the native CreateProcess() Windows process control interface.
 21.1166 -     */
 21.1167 -    {
 21.1168 -        char    *cmdline;
 21.1169 -        char    *p;
 21.1170 -        char    *np;
 21.1171 -        char    *ocl;
 21.1172 -        char    *ccl;
 21.1173 -        char    *unquoted;
 21.1174 -        DWORD   exitCode;
 21.1175 -        STARTUPINFO si;
 21.1176 -        PROCESS_INFORMATION pi;
 21.1177 -
 21.1178 -        /*
 21.1179 -         * The following code block gets and processes the original command
 21.1180 -         * line, replacing the argv[0] equivalent in the command line with
 21.1181 -         * the path to the new executable and removing the appropriate
 21.1182 -         * Multiple JRE support options. Note that similar logic exists
 21.1183 -         * in the platform independent SelectVersion routine, but is
 21.1184 -         * replicated here due to the syntax of CreateProcess().
 21.1185 -         *
 21.1186 -         * The magic "+ 4" characters added to the command line length are
 21.1187 -         * 2 possible quotes around the path (argv[0]), a space after the
 21.1188 -         * path and a terminating null character.
 21.1189 -         */
 21.1190 -        ocl = GetCommandLine();
 21.1191 -        np = ccl = JLI_StringDup(ocl);
 21.1192 -        p = nextarg(&np);               /* Discard argv[0] */
 21.1193 -        cmdline = (char *)JLI_MemAlloc(strlen(path) + strlen(np) + 4);
 21.1194 -        if (strchr(path, (int)' ') == NULL && strchr(path, (int)'\t') == NULL)
 21.1195 -            cmdline = strcpy(cmdline, path);
 21.1196 -        else
 21.1197 -            cmdline = strcat(strcat(strcpy(cmdline, "\""), path), "\"");
 21.1198 -
 21.1199 -        while (*np != (char)0) {                /* While more command-line */
 21.1200 -            p = nextarg(&np);
 21.1201 -            if (*p != (char)0) {                /* If a token was isolated */
 21.1202 -                unquoted = unquote(p);
 21.1203 -                if (*unquoted == '-') {         /* Looks like an option */
 21.1204 -                    if (strcmp(unquoted, "-classpath") == 0 ||
 21.1205 -                      strcmp(unquoted, "-cp") == 0) {   /* Unique cp syntax */
 21.1206 -                        cmdline = strcat(strcat(cmdline, " "), p);
 21.1207 -                        p = nextarg(&np);
 21.1208 -                        if (*p != (char)0)      /* If a token was isolated */
 21.1209 -                            cmdline = strcat(strcat(cmdline, " "), p);
 21.1210 -                    } else if (strncmp(unquoted, "-version:", 9) != 0 &&
 21.1211 -                      strcmp(unquoted, "-jre-restrict-search") != 0 &&
 21.1212 -                      strcmp(unquoted, "-no-jre-restrict-search") != 0) {
 21.1213 -                        cmdline = strcat(strcat(cmdline, " "), p);
 21.1214 -                    }
 21.1215 -                } else {                        /* End of options */
 21.1216 -                    cmdline = strcat(strcat(cmdline, " "), p);
 21.1217 -                    cmdline = strcat(strcat(cmdline, " "), np);
 21.1218 -                    JLI_MemFree((void *)unquoted);
 21.1219 -                    break;
 21.1220 -                }
 21.1221 -                JLI_MemFree((void *)unquoted);
 21.1222 -            }
 21.1223 -        }
 21.1224 -        JLI_MemFree((void *)ccl);
 21.1225 -
 21.1226 -        if (_launcher_debug) {
 21.1227 -            np = ccl = JLI_StringDup(cmdline);
 21.1228 -            p = nextarg(&np);
 21.1229 -            printf("ReExec Command: %s (%s)\n", path, p);
 21.1230 -            printf("ReExec Args: %s\n", np);
 21.1231 -            JLI_MemFree((void *)ccl);
 21.1232 -        }
 21.1233 -        (void)fflush(stdout);
 21.1234 -        (void)fflush(stderr);
 21.1235 -
 21.1236 -        /*
 21.1237 -         * The following code is modeled after a model presented in the
 21.1238 -         * Microsoft Technical Article "Moving Unix Applications to
 21.1239 -         * Windows NT" (March 6, 1994) and "Creating Processes" on MSDN
 21.1240 -         * (Februrary 2005).  It approximates UNIX spawn semantics with
 21.1241 -         * the parent waiting for termination of the child.
 21.1242 -         */
 21.1243 -        memset(&si, 0, sizeof(si));
 21.1244 -        si.cb =sizeof(STARTUPINFO);
 21.1245 -        memset(&pi, 0, sizeof(pi));
 21.1246 -
 21.1247 -        if (!CreateProcess((LPCTSTR)path,       /* executable name */
 21.1248 -          (LPTSTR)cmdline,                      /* command line */
 21.1249 -          (LPSECURITY_ATTRIBUTES)NULL,          /* process security attr. */
 21.1250 -          (LPSECURITY_ATTRIBUTES)NULL,          /* thread security attr. */
 21.1251 -          (BOOL)TRUE,                           /* inherits system handles */
 21.1252 -          (DWORD)0,                             /* creation flags */
 21.1253 -          (LPVOID)NULL,                         /* environment block */
 21.1254 -          (LPCTSTR)NULL,                        /* current directory */
 21.1255 -          (LPSTARTUPINFO)&si,                   /* (in) startup information */
 21.1256 -          (LPPROCESS_INFORMATION)&pi)) {        /* (out) process information */
 21.1257 -            ReportSysErrorMessage2("CreateProcess(%s, ...) failed: %s",
 21.1258 -              path, JNI_TRUE);
 21.1259 -              exit(1);
 21.1260 -        }
 21.1261 -
 21.1262 -        if (WaitForSingleObject(pi.hProcess, INFINITE) != WAIT_FAILED) {
 21.1263 -            if (GetExitCodeProcess(pi.hProcess, &exitCode) == FALSE)
 21.1264 -                exitCode = 1;
 21.1265 -        } else {
 21.1266 -            ReportErrorMessage("WaitForSingleObject() failed.", JNI_TRUE);
 21.1267 -            exitCode = 1;
 21.1268 -        }
 21.1269 -
 21.1270 -        CloseHandle(pi.hThread);
 21.1271 -        CloseHandle(pi.hProcess);
 21.1272 -
 21.1273 -        exit(exitCode);
 21.1274 -    }
 21.1275 -
 21.1276 -}
 21.1277 -
 21.1278 -#endif /* ifndef GAMMA */
 21.1279 -
 21.1280 -
 21.1281 -/*
 21.1282 - * Wrapper for platform dependent unsetenv function.
 21.1283 - */
 21.1284 -int
 21.1285 -UnsetEnv(char *name)
 21.1286 -{
 21.1287 -    int ret;
 21.1288 -    char *buf = JLI_MemAlloc(strlen(name) + 2);
 21.1289 -    buf = strcat(strcpy(buf, name), "=");
 21.1290 -    ret = _putenv(buf);
 21.1291 -    JLI_MemFree(buf);
 21.1292 -    return (ret);
 21.1293 -}
 21.1294 -
 21.1295 -/* --- Splash Screen shared library support --- */
 21.1296 -
 21.1297 -static const char* SPLASHSCREEN_SO = "\\bin\\splashscreen.dll";
 21.1298 -
 21.1299 -static HMODULE hSplashLib = NULL;
 21.1300 -
 21.1301 -void* SplashProcAddress(const char* name) {
 21.1302 -    char libraryPath[MAXPATHLEN]; /* some extra space for strcat'ing SPLASHSCREEN_SO */
 21.1303 -
 21.1304 -    if (!GetJREPath(libraryPath, MAXPATHLEN)) {
 21.1305 -        return NULL;
 21.1306 -    }
 21.1307 -    if (strlen(libraryPath)+strlen(SPLASHSCREEN_SO) >= MAXPATHLEN) {
 21.1308 -        return NULL;
 21.1309 -    }
 21.1310 -    strcat(libraryPath, SPLASHSCREEN_SO);
 21.1311 -
 21.1312 -    if (!hSplashLib) {
 21.1313 -        hSplashLib = LoadLibrary(libraryPath);
 21.1314 -    }
 21.1315 -    if (hSplashLib) {
 21.1316 -        return GetProcAddress(hSplashLib, name);
 21.1317 -    } else {
 21.1318 -        return NULL;
 21.1319 -    }
 21.1320 -}
 21.1321 -
 21.1322 -void SplashFreeLibrary() {
 21.1323 -    if (hSplashLib) {
 21.1324 -        FreeLibrary(hSplashLib);
 21.1325 -        hSplashLib = NULL;
 21.1326 -    }
 21.1327 -}
 21.1328 -
 21.1329 -/*
 21.1330 - * Block current thread and continue execution in a new thread
 21.1331 - */
 21.1332 -int
 21.1333 -ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) {
 21.1334 -    int rslt = 0;
 21.1335 -    unsigned thread_id;
 21.1336 -
 21.1337 -#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
 21.1338 -#define STACK_SIZE_PARAM_IS_A_RESERVATION  (0x10000)
 21.1339 -#endif
 21.1340 -
 21.1341 -    /*
 21.1342 -     * STACK_SIZE_PARAM_IS_A_RESERVATION is what we want, but it's not
 21.1343 -     * supported on older version of Windows. Try first with the flag; and
 21.1344 -     * if that fails try again without the flag. See MSDN document or HotSpot
 21.1345 -     * source (os_win32.cpp) for details.
 21.1346 -     */
 21.1347 -    HANDLE thread_handle =
 21.1348 -      (HANDLE)_beginthreadex(NULL,
 21.1349 -                             (unsigned)stack_size,
 21.1350 -                             continuation,
 21.1351 -                             args,
 21.1352 -                             STACK_SIZE_PARAM_IS_A_RESERVATION,
 21.1353 -                             &thread_id);
 21.1354 -    if (thread_handle == NULL) {
 21.1355 -      thread_handle =
 21.1356 -      (HANDLE)_beginthreadex(NULL,
 21.1357 -                             (unsigned)stack_size,
 21.1358 -                             continuation,
 21.1359 -                             args,
 21.1360 -                             0,
 21.1361 -                             &thread_id);
 21.1362 -    }
 21.1363 -
 21.1364 -    /* AWT preloading (AFTER main thread start) */
 21.1365 -#ifdef ENABLE_AWT_PRELOAD
 21.1366 -    /* D3D preloading */
 21.1367 -    if (awtPreloadD3D != 0) {
 21.1368 -        char *envValue;
 21.1369 -        /* D3D routines checks env.var J2D_D3D if no appropriate
 21.1370 -         * command line params was specified
 21.1371 -         */
 21.1372 -        envValue = getenv("J2D_D3D");
 21.1373 -        if (envValue != NULL && stricmp(envValue, "false") == 0) {
 21.1374 -            awtPreloadD3D = 0;
 21.1375 -        }
 21.1376 -        /* Test that AWT preloading isn't disabled by J2D_D3D_PRELOAD env.var */
 21.1377 -        envValue = getenv("J2D_D3D_PRELOAD");
 21.1378 -        if (envValue != NULL && stricmp(envValue, "false") == 0) {
 21.1379 -            awtPreloadD3D = 0;
 21.1380 -        }
 21.1381 -        if (awtPreloadD3D < 0) {
 21.1382 -            /* If awtPreloadD3D is still undefined (-1), test
 21.1383 -             * if it is turned on by J2D_D3D_PRELOAD env.var.
 21.1384 -             * By default it's turned OFF.
 21.1385 -             */
 21.1386 -            awtPreloadD3D = 0;
 21.1387 -            if (envValue != NULL && stricmp(envValue, "true") == 0) {
 21.1388 -                awtPreloadD3D = 1;
 21.1389 -            }
 21.1390 -        }
 21.1391 -    }
 21.1392 -    if (awtPreloadD3D) {
 21.1393 -        AWTPreload(D3D_PRELOAD_FUNC);
 21.1394 -    }
 21.1395 -#endif /* ENABLE_AWT_PRELOAD */
 21.1396 -
 21.1397 -    if (thread_handle) {
 21.1398 -      WaitForSingleObject(thread_handle, INFINITE);
 21.1399 -      GetExitCodeThread(thread_handle, &rslt);
 21.1400 -      CloseHandle(thread_handle);
 21.1401 -    } else {
 21.1402 -      rslt = continuation(args);
 21.1403 -    }
 21.1404 -
 21.1405 -#ifdef ENABLE_AWT_PRELOAD
 21.1406 -    if (awtPreloaded) {
 21.1407 -        AWTPreloadStop();
 21.1408 -    }
 21.1409 -#endif /* ENABLE_AWT_PRELOAD */
 21.1410 -
 21.1411 -    return rslt;
 21.1412 -}
 21.1413 -
 21.1414 -/* Linux only, empty on windows. */
 21.1415 -void SetJavaLauncherPlatformProps() {}
 21.1416 -
 21.1417 -
 21.1418 -//==============================
 21.1419 -// AWT preloading
 21.1420 -#ifdef ENABLE_AWT_PRELOAD
 21.1421 -
 21.1422 -typedef int FnPreloadStart(void);
 21.1423 -typedef void FnPreloadStop(void);
 21.1424 -static FnPreloadStop *fnPreloadStop = NULL;
 21.1425 -static HMODULE hPreloadAwt = NULL;
 21.1426 -
 21.1427 -/*
 21.1428 - * Starts AWT preloading
 21.1429 - */
 21.1430 -int AWTPreload(const char *funcName)
 21.1431 -{
 21.1432 -    int result = -1;
 21.1433 -
 21.1434 -    // load AWT library once (if several preload function should be called)
 21.1435 -    if (hPreloadAwt == NULL) {
 21.1436 -        // awt.dll is not loaded yet
 21.1437 -        char libraryPath[MAXPATHLEN];
 21.1438 -        int jrePathLen = 0;
 21.1439 -        HMODULE hJava = NULL;
 21.1440 -        HMODULE hVerify = NULL;
 21.1441 -
 21.1442 -        while (1) {
 21.1443 -            // awt.dll depends on jvm.dll & java.dll;
 21.1444 -            // jvm.dll is already loaded, so we need only java.dll;
 21.1445 -            // java.dll depends on MSVCRT lib & verify.dll.
 21.1446 -            if (!GetJREPath(libraryPath, MAXPATHLEN)) {
 21.1447 -                break;
 21.1448 -            }
 21.1449 -
 21.1450 -            // save path length
 21.1451 -            jrePathLen = strlen(libraryPath);
 21.1452 -
 21.1453 -            // load msvcrt 1st
 21.1454 -            LoadMSVCRT();
 21.1455 -
 21.1456 -            // load verify.dll
 21.1457 -            strcat(libraryPath, "\\bin\\verify.dll");
 21.1458 -            hVerify = LoadLibrary(libraryPath);
 21.1459 -            if (hVerify == NULL) {
 21.1460 -                break;
 21.1461 -            }
 21.1462 -
 21.1463 -            // restore jrePath
 21.1464 -            libraryPath[jrePathLen] = 0;
 21.1465 -            // load java.dll
 21.1466 -            strcat(libraryPath, "\\bin\\" JAVA_DLL);
 21.1467 -            hJava = LoadLibrary(libraryPath);
 21.1468 -            if (hJava == NULL) {
 21.1469 -                break;
 21.1470 -            }
 21.1471 -
 21.1472 -            // restore jrePath
 21.1473 -            libraryPath[jrePathLen] = 0;
 21.1474 -            // load awt.dll
 21.1475 -            strcat(libraryPath, "\\bin\\awt.dll");
 21.1476 -            hPreloadAwt = LoadLibrary(libraryPath);
 21.1477 -            if (hPreloadAwt == NULL) {
 21.1478 -                break;
 21.1479 -            }
 21.1480 -
 21.1481 -            // get "preloadStop" func ptr
 21.1482 -            fnPreloadStop = (FnPreloadStop *)GetProcAddress(hPreloadAwt, "preloadStop");
 21.1483 -
 21.1484 -            break;
 21.1485 -        }
 21.1486 -    }
 21.1487 -
 21.1488 -    if (hPreloadAwt != NULL) {
 21.1489 -        FnPreloadStart *fnInit = (FnPreloadStart *)GetProcAddress(hPreloadAwt, funcName);
 21.1490 -        if (fnInit != NULL) {
 21.1491 -            // don't forget to stop preloading
 21.1492 -            awtPreloaded = 1;
 21.1493 -
 21.1494 -            result = fnInit();
 21.1495 -        }
 21.1496 -    }
 21.1497 -
 21.1498 -    return result;
 21.1499 -}
 21.1500 -
 21.1501 -/*
 21.1502 - * Terminates AWT preloading
 21.1503 - */
 21.1504 -void AWTPreloadStop() {
 21.1505 -    if (fnPreloadStop != NULL) {
 21.1506 -        fnPreloadStop();
 21.1507 -    }
 21.1508 -}
 21.1509 -
 21.1510 -#endif /* ENABLE_AWT_PRELOAD */
    22.1 --- a/src/os/windows/launcher/java_md.h	Mon May 06 13:53:13 2013 -0700
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,83 +0,0 @@
    22.4 -/*
    22.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    22.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 - *
    22.8 - * This code is free software; you can redistribute it and/or modify it
    22.9 - * under the terms of the GNU General Public License version 2 only, as
   22.10 - * published by the Free Software Foundation.
   22.11 - *
   22.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 - * version 2 for more details (a copy is included in the LICENSE file that
   22.16 - * accompanied this code).
   22.17 - *
   22.18 - * You should have received a copy of the GNU General Public License version
   22.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 - *
   22.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 - * or visit www.oracle.com if you need additional information or have any
   22.24 - * questions.
   22.25 - *
   22.26 - */
   22.27 -
   22.28 -#ifndef JAVA_MD_H
   22.29 -#define JAVA_MD_H
   22.30 -
   22.31 -#include <jni.h>
   22.32 -#include <windows.h>
   22.33 -#include <io.h>
   22.34 -#ifndef GAMMA
   22.35 -#include "manifest_info.h"
   22.36 -#endif
   22.37 -#include "jli_util.h"
   22.38 -
   22.39 -#ifdef GAMMA
   22.40 -#define stricmp _stricmp
   22.41 -#define strnicmp _strnicmp
   22.42 -#define snprintf _snprintf
   22.43 -#define strdup _strdup
   22.44 -#endif
   22.45 -
   22.46 -#define PATH_SEPARATOR  ';'
   22.47 -#define FILESEP         "\\"
   22.48 -#define FILE_SEPARATOR  '\\'
   22.49 -#define IS_FILE_SEPARATOR(c) ((c) == '\\' || (c) == '/')
   22.50 -#define MAXPATHLEN      MAX_PATH
   22.51 -#define MAXNAMELEN      MAX_PATH
   22.52 -
   22.53 -#ifdef JAVA_ARGS
   22.54 -/*
   22.55 - * ApplicationHome is prepended to each of these entries; the resulting
   22.56 - * strings are concatenated (separated by PATH_SEPARATOR) and used as the
   22.57 - * value of -cp option to the launcher.
   22.58 - */
   22.59 -#ifndef APP_CLASSPATH
   22.60 -#define APP_CLASSPATH        { "\\lib\\tools.jar", "\\classes" }
   22.61 -#endif
   22.62 -#endif
   22.63 -
   22.64 -/*
   22.65 - * Support for doing cheap, accurate interval timing.
   22.66 - */
   22.67 -extern jlong CounterGet(void);
   22.68 -extern jlong Counter2Micros(jlong counts);
   22.69 -
   22.70 -#ifdef JAVAW
   22.71 -#define main _main
   22.72 -extern int _main(int argc, char **argv);
   22.73 -#endif
   22.74 -
   22.75 -#define JLONG_FORMAT "%I64d"
   22.76 -
   22.77 -/*
   22.78 - * Function prototypes.
   22.79 - */
   22.80 -#ifndef GAMMA
   22.81 -char *LocateJRE(manifest_info *info);
   22.82 -void ExecJRE(char *jre, char **argv);
   22.83 -#endif
   22.84 -int UnsetEnv(char *name);
   22.85 -
   22.86 -#endif
    23.1 --- a/src/share/tools/ProjectCreator/BuildConfig.java	Mon May 06 13:53:13 2013 -0700
    23.2 +++ b/src/share/tools/ProjectCreator/BuildConfig.java	Mon May 06 19:49:23 2013 -0700
    23.3 @@ -65,6 +65,7 @@
    23.4          String sourceBase = getFieldString(null, "SourceBase");
    23.5          String buildSpace = getFieldString(null, "BuildSpace");
    23.6          String outDir = buildBase;
    23.7 +        String jdkTargetRoot = getFieldString(null, "JdkTargetRoot");
    23.8  
    23.9          put("Id", flavourBuild);
   23.10          put("OutputDir", outDir);
   23.11 @@ -72,6 +73,7 @@
   23.12          put("BuildBase", buildBase);
   23.13          put("BuildSpace", buildSpace);
   23.14          put("OutputDll", outDir + Util.sep + outDll);
   23.15 +        put("JdkTargetRoot", jdkTargetRoot);
   23.16  
   23.17          context = new String [] {flavourBuild, flavour, build, null};
   23.18      }
    24.1 --- a/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java	Mon May 06 13:53:13 2013 -0700
    24.2 +++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java	Mon May 06 19:49:23 2013 -0700
    24.3 @@ -98,11 +98,6 @@
    24.4              tagV(cfg.getV("LinkerFlags"));
    24.5              endTag();
    24.6  
    24.7 -            startTag("PostBuildEvent");
    24.8 -            tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription"));
    24.9 -            tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n")));
   24.10 -            endTag();
   24.11 -
   24.12              startTag("PreLinkEvent");
   24.13              tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription"));
   24.14              tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n")));
   24.15 @@ -141,7 +136,9 @@
   24.16  
   24.17          for (BuildConfig cfg : allConfigs) {
   24.18              startTag(cfg, "PropertyGroup");
   24.19 -            tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe");
   24.20 +            tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe");
   24.21 +            tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) -Dsun.java.launcher=gamma");
   24.22 +            tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot"));
   24.23              endTag();
   24.24          }
   24.25  
    25.1 --- a/src/share/tools/launcher/java.c	Mon May 06 13:53:13 2013 -0700
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,2080 +0,0 @@
    25.4 -/*
    25.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    25.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 - *
    25.8 - * This code is free software; you can redistribute it and/or modify it
    25.9 - * under the terms of the GNU General Public License version 2 only, as
   25.10 - * published by the Free Software Foundation.
   25.11 - *
   25.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 - * version 2 for more details (a copy is included in the LICENSE file that
   25.16 - * accompanied this code).
   25.17 - *
   25.18 - * You should have received a copy of the GNU General Public License version
   25.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 - *
   25.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 - * or visit www.oracle.com if you need additional information or have any
   25.24 - * questions.
   25.25 - *
   25.26 - */
   25.27 -
   25.28 -/*
   25.29 - * Gamma (Hotspot internal engineering test) launcher based on 6.0u22 JDK,
   25.30 - * search "GAMMA" for gamma specific changes.
   25.31 - *
   25.32 - * GAMMA: gamma launcher is much simpler than regular java launcher in that
   25.33 - *        JVM is either statically linked in or it is installed in the
   25.34 - *        same directory where the launcher exists, so we don't have to
   25.35 - *        worry about choosing the right JVM based on command line flag, jar
   25.36 - *        file and/or ergonomics. Intead of removing unused logic from source
   25.37 - *        they are commented out with #ifndef GAMMA, hopefully it'll be easier
   25.38 - *        to maintain this file in sync with regular JDK launcher.
   25.39 - */
   25.40 -
   25.41 -/*
   25.42 - * Shared source for 'java' command line tool.
   25.43 - *
   25.44 - * If JAVA_ARGS is defined, then acts as a launcher for applications. For
   25.45 - * instance, the JDK command line tools such as javac and javadoc (see
   25.46 - * makefiles for more details) are built with this program.  Any arguments
   25.47 - * prefixed with '-J' will be passed directly to the 'java' command.
   25.48 - */
   25.49 -
   25.50 -#ifdef GAMMA
   25.51 -#  ifdef JAVA_ARGS
   25.52 -#    error Do NOT define JAVA_ARGS when building gamma launcher
   25.53 -#  endif
   25.54 -#  if !defined(LINK_INTO_AOUT) && !defined(LINK_INTO_LIBJVM)
   25.55 -#    error Either LINK_INTO_AOUT or LINK_INTO_LIBJVM must be defined
   25.56 -#  endif
   25.57 -#endif
   25.58 -
   25.59 -/*
   25.60 - * One job of the launcher is to remove command line options which the
   25.61 - * vm does not understand and will not process.  These options include
   25.62 - * options which select which style of vm is run (e.g. -client and
   25.63 - * -server) as well as options which select the data model to use.
   25.64 - * Additionally, for tools which invoke an underlying vm "-J-foo"
   25.65 - * options are turned into "-foo" options to the vm.  This option
   25.66 - * filtering is handled in a number of places in the launcher, some of
   25.67 - * it in machine-dependent code.  In this file, the function
   25.68 - * CheckJVMType removes vm style options and TranslateApplicationArgs
   25.69 - * removes "-J" prefixes.  On unix platforms, the
   25.70 - * CreateExecutionEnvironment function from the unix java_md.c file
   25.71 - * processes and removes -d<n> options.  However, in case
   25.72 - * CreateExecutionEnvironment does not need to exec because
   25.73 - * LD_LIBRARY_PATH is set acceptably and the data model does not need
   25.74 - * to be changed, ParseArguments will screen out the redundant -d<n>
   25.75 - * options and prevent them from being passed to the vm; this is done
   25.76 - * by using the machine-dependent call
   25.77 - * RemovableMachineDependentOption.
   25.78 - */
   25.79 -
   25.80 -#include <stdio.h>
   25.81 -#include <stdlib.h>
   25.82 -#include <string.h>
   25.83 -
   25.84 -#include <jni.h>
   25.85 -#include <jvm.h>
   25.86 -#include "java.h"
   25.87 -#ifndef GAMMA
   25.88 -#include "manifest_info.h"
   25.89 -#include "version_comp.h"
   25.90 -#include "splashscreen.h"
   25.91 -#endif
   25.92 -#include "wildcard.h"
   25.93 -
   25.94 -#ifndef FULL_VERSION
   25.95 -#define FULL_VERSION JDK_MAJOR_VERSION "." JDK_MINOR_VERSION
   25.96 -#endif
   25.97 -
   25.98 -/*
   25.99 - * The following environment variable is used to influence the behavior
  25.100 - * of the jre exec'd through the SelectVersion routine.  The command line
  25.101 - * options which specify the version are not passed to the exec'd version,
  25.102 - * because that jre may be an older version which wouldn't recognize them.
  25.103 - * This environment variable is known to this (and later) version and serves
  25.104 - * to suppress the version selection code.  This is not only for efficiency,
  25.105 - * but also for correctness, since any command line options have been
  25.106 - * removed which would cause any value found in the manifest to be used.
  25.107 - * This would be incorrect because the command line options are defined
  25.108 - * to take precedence.
  25.109 - *
  25.110 - * The value associated with this environment variable is the MainClass
  25.111 - * name from within the executable jar file (if any). This is strictly a
  25.112 - * performance enhancement to avoid re-reading the jar file manifest.
  25.113 - *
  25.114 - * A NOTE TO DEVELOPERS: For performance reasons it is important that
  25.115 - * the program image remain relatively small until after SelectVersion
  25.116 - * CreateExecutionEnvironment have finished their possibly recursive
  25.117 - * processing. Watch everything, but resist all temptations to use Java
  25.118 - * interfaces.
  25.119 - */
  25.120 -#define ENV_ENTRY "_JAVA_VERSION_SET"
  25.121 -
  25.122 -#ifndef GAMMA
  25.123 -#define SPLASH_FILE_ENV_ENTRY "_JAVA_SPLASH_FILE"
  25.124 -#define SPLASH_JAR_ENV_ENTRY "_JAVA_SPLASH_JAR"
  25.125 -#endif
  25.126 -
  25.127 -static jboolean printVersion = JNI_FALSE; /* print and exit */
  25.128 -static jboolean showVersion = JNI_FALSE;  /* print but continue */
  25.129 -static char *progname;
  25.130 -jboolean _launcher_debug = JNI_FALSE;
  25.131 -
  25.132 -#ifndef GAMMA
  25.133 -/*
  25.134 - * Entries for splash screen environment variables.
  25.135 - * putenv is performed in SelectVersion. We need
  25.136 - * them in memory until UnsetEnv, so they are made static
  25.137 - * global instead of auto local.
  25.138 - */
  25.139 -static char* splash_file_entry = NULL;
  25.140 -static char* splash_jar_entry = NULL;
  25.141 -#endif
  25.142 -
  25.143 -/*
  25.144 - * List of VM options to be specified when the VM is created.
  25.145 - */
  25.146 -static JavaVMOption *options;
  25.147 -static int numOptions, maxOptions;
  25.148 -
  25.149 -/*
  25.150 - * Prototypes for functions internal to launcher.
  25.151 - */
  25.152 -static void SetClassPath(const char *s);
  25.153 -static void SelectVersion(int argc, char **argv, char **main_class);
  25.154 -static jboolean ParseArguments(int *pargc, char ***pargv, char **pjarfile,
  25.155 -                               char **pclassname, int *pret, const char *jvmpath);
  25.156 -static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
  25.157 -                              InvocationFunctions *ifn);
  25.158 -static jstring NewPlatformString(JNIEnv *env, char *s);
  25.159 -static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
  25.160 -static jclass LoadClass(JNIEnv *env, char *name);
  25.161 -static jstring GetMainClassName(JNIEnv *env, char *jarname);
  25.162 -static void SetJavaCommandLineProp(char* classname, char* jarfile, int argc, char** argv);
  25.163 -static void SetJavaLauncherProp(void);
  25.164 -
  25.165 -#ifdef JAVA_ARGS
  25.166 -static void TranslateApplicationArgs(int *pargc, char ***pargv);
  25.167 -static jboolean AddApplicationOptions(void);
  25.168 -#endif
  25.169 -
  25.170 -static void PrintJavaVersion(JNIEnv *env);
  25.171 -static void PrintUsage(void);
  25.172 -static jint PrintXUsage(const char *jvmpath);
  25.173 -
  25.174 -static void SetPaths(int argc, char **argv);
  25.175 -
  25.176 -#ifndef GAMMA
  25.177 -
  25.178 -/* Maximum supported entries from jvm.cfg. */
  25.179 -#define INIT_MAX_KNOWN_VMS      10
  25.180 -/* Values for vmdesc.flag */
  25.181 -#define VM_UNKNOWN              -1
  25.182 -#define VM_KNOWN                 0
  25.183 -#define VM_ALIASED_TO            1
  25.184 -#define VM_WARN                  2
  25.185 -#define VM_ERROR                 3
  25.186 -#define VM_IF_SERVER_CLASS       4
  25.187 -#define VM_IGNORE                5
  25.188 -struct vmdesc {
  25.189 -    char *name;
  25.190 -    int flag;
  25.191 -    char *alias;
  25.192 -    char *server_class;
  25.193 -};
  25.194 -static struct vmdesc *knownVMs = NULL;
  25.195 -static int knownVMsCount = 0;
  25.196 -static int knownVMsLimit = 0;
  25.197 -
  25.198 -static void GrowKnownVMs();
  25.199 -static int  KnownVMIndex(const char* name);
  25.200 -static void FreeKnownVMs();
  25.201 -static void ShowSplashScreen();
  25.202 -
  25.203 -#endif /* ifndef GAMMA */
  25.204 -
  25.205 -jboolean ServerClassMachine();
  25.206 -
  25.207 -/* flag which if set suppresses error messages from the launcher */
  25.208 -static int noExitErrorMessage = 0;
  25.209 -
  25.210 -/*
  25.211 - * Running Java code in primordial thread caused many problems. We will
  25.212 - * create a new thread to invoke JVM. See 6316197 for more information.
  25.213 - */
  25.214 -static jlong threadStackSize = 0;  /* stack size of the new thread */
  25.215 -
  25.216 -int JNICALL JavaMain(void * args); /* entry point                  */
  25.217 -
  25.218 -struct JavaMainArgs {
  25.219 -  int     argc;
  25.220 -  char ** argv;
  25.221 -  char *  jarfile;
  25.222 -  char *  classname;
  25.223 -  InvocationFunctions ifn;
  25.224 -};
  25.225 -
  25.226 -/*
  25.227 - * Entry point.
  25.228 - */
  25.229 -int
  25.230 -main(int argc, char ** argv)
  25.231 -{
  25.232 -    char *jarfile = 0;
  25.233 -    char *classname = 0;
  25.234 -    char *s = 0;
  25.235 -    char *main_class = NULL;
  25.236 -    int ret;
  25.237 -    InvocationFunctions ifn;
  25.238 -    jlong start, end;
  25.239 -    char jrepath[MAXPATHLEN], jvmpath[MAXPATHLEN];
  25.240 -    char ** original_argv = argv;
  25.241 -
  25.242 -    if (getenv("_JAVA_LAUNCHER_DEBUG") != 0) {
  25.243 -        _launcher_debug = JNI_TRUE;
  25.244 -        printf("----_JAVA_LAUNCHER_DEBUG----\n");
  25.245 -    }
  25.246 -
  25.247 -#ifndef GAMMA
  25.248 -    /*
  25.249 -     * Make sure the specified version of the JRE is running.
  25.250 -     *
  25.251 -     * There are three things to note about the SelectVersion() routine:
  25.252 -     *  1) If the version running isn't correct, this routine doesn't
  25.253 -     *     return (either the correct version has been exec'd or an error
  25.254 -     *     was issued).
  25.255 -     *  2) Argc and Argv in this scope are *not* altered by this routine.
  25.256 -     *     It is the responsibility of subsequent code to ignore the
  25.257 -     *     arguments handled by this routine.
  25.258 -     *  3) As a side-effect, the variable "main_class" is guaranteed to
  25.259 -     *     be set (if it should ever be set).  This isn't exactly the
  25.260 -     *     poster child for structured programming, but it is a small
  25.261 -     *     price to pay for not processing a jar file operand twice.
  25.262 -     *     (Note: This side effect has been disabled.  See comment on
  25.263 -     *     bugid 5030265 below.)
  25.264 -     */
  25.265 -    SelectVersion(argc, argv, &main_class);
  25.266 -#endif /* ifndef GAMMA */
  25.267 -
  25.268 -    /* copy original argv */
  25.269 -    {
  25.270 -      int i;
  25.271 -      original_argv = (char**)JLI_MemAlloc(sizeof(char*)*(argc+1));
  25.272 -      for(i = 0; i < argc+1; i++)
  25.273 -        original_argv[i] = argv[i];
  25.274 -    }
  25.275 -
  25.276 -    CreateExecutionEnvironment(&argc, &argv,
  25.277 -                               jrepath, sizeof(jrepath),
  25.278 -                               jvmpath, sizeof(jvmpath),
  25.279 -                               original_argv);
  25.280 -
  25.281 -    printf("Using java runtime at: %s\n", jrepath);
  25.282 -
  25.283 -    ifn.CreateJavaVM = 0;
  25.284 -    ifn.GetDefaultJavaVMInitArgs = 0;
  25.285 -
  25.286 -    if (_launcher_debug)
  25.287 -      start = CounterGet();
  25.288 -    if (!LoadJavaVM(jvmpath, &ifn)) {
  25.289 -      exit(6);
  25.290 -    }
  25.291 -    if (_launcher_debug) {
  25.292 -      end   = CounterGet();
  25.293 -      printf("%ld micro seconds to LoadJavaVM\n",
  25.294 -             (long)(jint)Counter2Micros(end-start));
  25.295 -    }
  25.296 -
  25.297 -#ifdef JAVA_ARGS  /* javac, jar and friends. */
  25.298 -    progname = "java";
  25.299 -#else             /* java, oldjava, javaw and friends */
  25.300 -#ifdef PROGNAME
  25.301 -    progname = PROGNAME;
  25.302 -#else
  25.303 -    progname = *argv;
  25.304 -    if ((s = strrchr(progname, FILE_SEPARATOR)) != 0) {
  25.305 -        progname = s + 1;
  25.306 -    }
  25.307 -#endif /* PROGNAME */
  25.308 -#endif /* JAVA_ARGS */
  25.309 -    ++argv;
  25.310 -    --argc;
  25.311 -
  25.312 -#ifdef JAVA_ARGS
  25.313 -    /* Preprocess wrapper arguments */
  25.314 -    TranslateApplicationArgs(&argc, &argv);
  25.315 -    if (!AddApplicationOptions()) {
  25.316 -        exit(1);
  25.317 -    }
  25.318 -#endif
  25.319 -
  25.320 -    /* Set default CLASSPATH */
  25.321 -    if ((s = getenv("CLASSPATH")) == 0) {
  25.322 -        s = ".";
  25.323 -    }
  25.324 -#ifndef JAVA_ARGS
  25.325 -    SetClassPath(s);
  25.326 -#endif
  25.327 -
  25.328 -    /*
  25.329 -     *  Parse command line options; if the return value of
  25.330 -     *  ParseArguments is false, the program should exit.
  25.331 -     */
  25.332 -    if (!ParseArguments(&argc, &argv, &jarfile, &classname, &ret, jvmpath)) {
  25.333 -      exit(ret);
  25.334 -    }
  25.335 -
  25.336 -    /* Override class path if -jar flag was specified */
  25.337 -    if (jarfile != 0) {
  25.338 -        SetClassPath(jarfile);
  25.339 -    }
  25.340 -
  25.341 -    /* set the -Dsun.java.command pseudo property */
  25.342 -    SetJavaCommandLineProp(classname, jarfile, argc, argv);
  25.343 -
  25.344 -    /* Set the -Dsun.java.launcher pseudo property */
  25.345 -    SetJavaLauncherProp();
  25.346 -
  25.347 -    /* set the -Dsun.java.launcher.* platform properties */
  25.348 -    SetJavaLauncherPlatformProps();
  25.349 -
  25.350 -#ifndef GAMMA
  25.351 -    /* Show the splash screen if needed */
  25.352 -    ShowSplashScreen();
  25.353 -#endif
  25.354 -
  25.355 -    /*
  25.356 -     * Done with all command line processing and potential re-execs so
  25.357 -     * clean up the environment.
  25.358 -     */
  25.359 -    (void)UnsetEnv(ENV_ENTRY);
  25.360 -#ifndef GAMMA
  25.361 -    (void)UnsetEnv(SPLASH_FILE_ENV_ENTRY);
  25.362 -    (void)UnsetEnv(SPLASH_JAR_ENV_ENTRY);
  25.363 -
  25.364 -    JLI_MemFree(splash_jar_entry);
  25.365 -    JLI_MemFree(splash_file_entry);
  25.366 -#endif
  25.367 -
  25.368 -    /*
  25.369 -     * If user doesn't specify stack size, check if VM has a preference.
  25.370 -     * Note that HotSpot no longer supports JNI_VERSION_1_1 but it will
  25.371 -     * return its default stack size through the init args structure.
  25.372 -     */
  25.373 -    if (threadStackSize == 0) {
  25.374 -      struct JDK1_1InitArgs args1_1;
  25.375 -      memset((void*)&args1_1, 0, sizeof(args1_1));
  25.376 -      args1_1.version = JNI_VERSION_1_1;
  25.377 -      ifn.GetDefaultJavaVMInitArgs(&args1_1);  /* ignore return value */
  25.378 -      if (args1_1.javaStackSize > 0) {
  25.379 -         threadStackSize = args1_1.javaStackSize;
  25.380 -      }
  25.381 -    }
  25.382 -
  25.383 -    { /* Create a new thread to create JVM and invoke main method */
  25.384 -      struct JavaMainArgs args;
  25.385 -
  25.386 -      args.argc = argc;
  25.387 -      args.argv = argv;
  25.388 -      args.jarfile = jarfile;
  25.389 -      args.classname = classname;
  25.390 -      args.ifn = ifn;
  25.391 -
  25.392 -      return ContinueInNewThread(JavaMain, threadStackSize, (void*)&args);
  25.393 -    }
  25.394 -}
  25.395 -
  25.396 -int JNICALL
  25.397 -JavaMain(void * _args)
  25.398 -{
  25.399 -    struct JavaMainArgs *args = (struct JavaMainArgs *)_args;
  25.400 -    int argc = args->argc;
  25.401 -    char **argv = args->argv;
  25.402 -    char *jarfile = args->jarfile;
  25.403 -    char *classname = args->classname;
  25.404 -    InvocationFunctions ifn = args->ifn;
  25.405 -
  25.406 -    JavaVM *vm = 0;
  25.407 -    JNIEnv *env = 0;
  25.408 -    jstring mainClassName;
  25.409 -    jclass mainClass;
  25.410 -    jmethodID mainID;
  25.411 -    jobjectArray mainArgs;
  25.412 -    int ret = 0;
  25.413 -    jlong start, end;
  25.414 -
  25.415 -    /*
  25.416 -     * Error message to print or display; by default the message will
  25.417 -     * only be displayed in a window.
  25.418 -     */
  25.419 -    char * message = "Fatal exception occurred.  Program will exit.";
  25.420 -    jboolean messageDest = JNI_FALSE;
  25.421 -
  25.422 -    /* Initialize the virtual machine */
  25.423 -
  25.424 -    if (_launcher_debug)
  25.425 -        start = CounterGet();
  25.426 -    if (!InitializeJVM(&vm, &env, &ifn)) {
  25.427 -        ReportErrorMessage("Could not create the Java virtual machine.",
  25.428 -                           JNI_TRUE);
  25.429 -        exit(1);
  25.430 -    }
  25.431 -
  25.432 -    if (printVersion || showVersion) {
  25.433 -        PrintJavaVersion(env);
  25.434 -        if ((*env)->ExceptionOccurred(env)) {
  25.435 -            ReportExceptionDescription(env);
  25.436 -            goto leave;
  25.437 -        }
  25.438 -        if (printVersion) {
  25.439 -            ret = 0;
  25.440 -            message = NULL;
  25.441 -            goto leave;
  25.442 -        }
  25.443 -        if (showVersion) {
  25.444 -            fprintf(stderr, "\n");
  25.445 -        }
  25.446 -    }
  25.447 -
  25.448 -    /* If the user specified neither a class name nor a JAR file */
  25.449 -    if (jarfile == 0 && classname == 0) {
  25.450 -        PrintUsage();
  25.451 -        message = NULL;
  25.452 -        goto leave;
  25.453 -    }
  25.454 -
  25.455 -#ifndef GAMMA
  25.456 -    FreeKnownVMs();  /* after last possible PrintUsage() */
  25.457 -#endif
  25.458 -
  25.459 -    if (_launcher_debug) {
  25.460 -        end   = CounterGet();
  25.461 -        printf("%ld micro seconds to InitializeJVM\n",
  25.462 -               (long)(jint)Counter2Micros(end-start));
  25.463 -    }
  25.464 -
  25.465 -    /* At this stage, argc/argv have the applications' arguments */
  25.466 -    if (_launcher_debug) {
  25.467 -        int i = 0;
  25.468 -        printf("Main-Class is '%s'\n", classname ? classname : "");
  25.469 -        printf("Apps' argc is %d\n", argc);
  25.470 -        for (; i < argc; i++) {
  25.471 -            printf("    argv[%2d] = '%s'\n", i, argv[i]);
  25.472 -        }
  25.473 -    }
  25.474 -
  25.475 -    ret = 1;
  25.476 -
  25.477 -    /*
  25.478 -     * Get the application's main class.
  25.479 -     *
  25.480 -     * See bugid 5030265.  The Main-Class name has already been parsed
  25.481 -     * from the manifest, but not parsed properly for UTF-8 support.
  25.482 -     * Hence the code here ignores the value previously extracted and
  25.483 -     * uses the pre-existing code to reextract the value.  This is
  25.484 -     * possibly an end of release cycle expedient.  However, it has
  25.485 -     * also been discovered that passing some character sets through
  25.486 -     * the environment has "strange" behavior on some variants of
  25.487 -     * Windows.  Hence, maybe the manifest parsing code local to the
  25.488 -     * launcher should never be enhanced.
  25.489 -     *
  25.490 -     * Hence, future work should either:
  25.491 -     *     1)   Correct the local parsing code and verify that the
  25.492 -     *          Main-Class attribute gets properly passed through
  25.493 -     *          all environments,
  25.494 -     *     2)   Remove the vestages of maintaining main_class through
  25.495 -     *          the environment (and remove these comments).
  25.496 -     */
  25.497 -    if (jarfile != 0) {
  25.498 -        mainClassName = GetMainClassName(env, jarfile);
  25.499 -        if ((*env)->ExceptionOccurred(env)) {
  25.500 -            ReportExceptionDescription(env);
  25.501 -            goto leave;
  25.502 -        }
  25.503 -        if (mainClassName == NULL) {
  25.504 -          const char * format = "Failed to load Main-Class manifest "
  25.505 -                                "attribute from\n%s";
  25.506 -          message = (char*)JLI_MemAlloc((strlen(format) + strlen(jarfile)) *
  25.507 -                                    sizeof(char));
  25.508 -          sprintf(message, format, jarfile);
  25.509 -          messageDest = JNI_TRUE;
  25.510 -          goto leave;
  25.511 -        }
  25.512 -        classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
  25.513 -        if (classname == NULL) {
  25.514 -            ReportExceptionDescription(env);
  25.515 -            goto leave;
  25.516 -        }
  25.517 -        mainClass = LoadClass(env, classname);
  25.518 -        if(mainClass == NULL) { /* exception occured */
  25.519 -            const char * format = "Could not find the main class: %s. Program will exit.";
  25.520 -            ReportExceptionDescription(env);
  25.521 -            message = (char *)JLI_MemAlloc((strlen(format) +
  25.522 -                                            strlen(classname)) * sizeof(char) );
  25.523 -            messageDest = JNI_TRUE;
  25.524 -            sprintf(message, format, classname);
  25.525 -            goto leave;
  25.526 -        }
  25.527 -        (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
  25.528 -    } else {
  25.529 -      mainClassName = NewPlatformString(env, classname);
  25.530 -      if (mainClassName == NULL) {
  25.531 -        const char * format = "Failed to load Main Class: %s";
  25.532 -        message = (char *)JLI_MemAlloc((strlen(format) + strlen(classname)) *
  25.533 -                                   sizeof(char) );
  25.534 -        sprintf(message, format, classname);
  25.535 -        messageDest = JNI_TRUE;
  25.536 -        goto leave;
  25.537 -      }
  25.538 -      classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
  25.539 -      if (classname == NULL) {
  25.540 -        ReportExceptionDescription(env);
  25.541 -        goto leave;
  25.542 -      }
  25.543 -      mainClass = LoadClass(env, classname);
  25.544 -      if(mainClass == NULL) { /* exception occured */
  25.545 -        const char * format = "Could not find the main class: %s.  Program will exit.";
  25.546 -        ReportExceptionDescription(env);
  25.547 -        message = (char *)JLI_MemAlloc((strlen(format) +
  25.548 -                                        strlen(classname)) * sizeof(char) );
  25.549 -        messageDest = JNI_TRUE;
  25.550 -        sprintf(message, format, classname);
  25.551 -        goto leave;
  25.552 -      }
  25.553 -      (*env)->ReleaseStringUTFChars(env, mainClassName, classname);
  25.554 -    }
  25.555 -
  25.556 -    /* Get the application's main method */
  25.557 -    mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
  25.558 -                                       "([Ljava/lang/String;)V");
  25.559 -    if (mainID == NULL) {
  25.560 -        if ((*env)->ExceptionOccurred(env)) {
  25.561 -            ReportExceptionDescription(env);
  25.562 -        } else {
  25.563 -          message = "No main method found in specified class.";
  25.564 -          messageDest = JNI_TRUE;
  25.565 -        }
  25.566 -        goto leave;
  25.567 -    }
  25.568 -
  25.569 -    {    /* Make sure the main method is public */
  25.570 -        jint mods;
  25.571 -        jmethodID mid;
  25.572 -        jobject obj = (*env)->ToReflectedMethod(env, mainClass,
  25.573 -                                                mainID, JNI_TRUE);
  25.574 -
  25.575 -        if( obj == NULL) { /* exception occurred */
  25.576 -            ReportExceptionDescription(env);
  25.577 -            goto leave;
  25.578 -        }
  25.579 -
  25.580 -        mid =
  25.581 -          (*env)->GetMethodID(env,
  25.582 -                              (*env)->GetObjectClass(env, obj),
  25.583 -                              "getModifiers", "()I");
  25.584 -        if ((*env)->ExceptionOccurred(env)) {
  25.585 -            ReportExceptionDescription(env);
  25.586 -            goto leave;
  25.587 -        }
  25.588 -
  25.589 -        mods = (*env)->CallIntMethod(env, obj, mid);
  25.590 -        if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
  25.591 -            message = "Main method not public.";
  25.592 -            messageDest = JNI_TRUE;
  25.593 -            goto leave;
  25.594 -        }
  25.595 -    }
  25.596 -
  25.597 -    /* Build argument array */
  25.598 -    mainArgs = NewPlatformStringArray(env, argv, argc);
  25.599 -    if (mainArgs == NULL) {
  25.600 -        ReportExceptionDescription(env);
  25.601 -        goto leave;
  25.602 -    }
  25.603 -
  25.604 -    /* Invoke main method. */
  25.605 -    (*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
  25.606 -
  25.607 -    /*
  25.608 -     * The launcher's exit code (in the absence of calls to
  25.609 -     * System.exit) will be non-zero if main threw an exception.
  25.610 -     */
  25.611 -    ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
  25.612 -
  25.613 -    /*
  25.614 -     * Detach the main thread so that it appears to have ended when
  25.615 -     * the application's main method exits.  This will invoke the
  25.616 -     * uncaught exception handler machinery if main threw an
  25.617 -     * exception.  An uncaught exception handler cannot change the
  25.618 -     * launcher's return code except by calling System.exit.
  25.619 -     */
  25.620 -    if ((*vm)->DetachCurrentThread(vm) != 0) {
  25.621 -        message = "Could not detach main thread.";
  25.622 -        messageDest = JNI_TRUE;
  25.623 -        ret = 1;
  25.624 -        goto leave;
  25.625 -    }
  25.626 -
  25.627 -    message = NULL;
  25.628 -
  25.629 - leave:
  25.630 -    /*
  25.631 -     * Wait for all non-daemon threads to end, then destroy the VM.
  25.632 -     * This will actually create a trivial new Java waiter thread
  25.633 -     * named "DestroyJavaVM", but this will be seen as a different
  25.634 -     * thread from the one that executed main, even though they are
  25.635 -     * the same C thread.  This allows mainThread.join() and
  25.636 -     * mainThread.isAlive() to work as expected.
  25.637 -     */
  25.638 -    (*vm)->DestroyJavaVM(vm);
  25.639 -
  25.640 -    if(message != NULL && !noExitErrorMessage)
  25.641 -      ReportErrorMessage(message, messageDest);
  25.642 -    return ret;
  25.643 -}
  25.644 -
  25.645 -#ifndef GAMMA
  25.646 -/*
  25.647 - * Checks the command line options to find which JVM type was
  25.648 - * specified.  If no command line option was given for the JVM type,
  25.649 - * the default type is used.  The environment variable
  25.650 - * JDK_ALTERNATE_VM and the command line option -XXaltjvm= are also
  25.651 - * checked as ways of specifying which JVM type to invoke.
  25.652 - */
  25.653 -char *
  25.654 -CheckJvmType(int *pargc, char ***argv, jboolean speculative) {
  25.655 -    int i, argi;
  25.656 -    int argc;
  25.657 -    char **newArgv;
  25.658 -    int newArgvIdx = 0;
  25.659 -    int isVMType;
  25.660 -    int jvmidx = -1;
  25.661 -    char *jvmtype = getenv("JDK_ALTERNATE_VM");
  25.662 -
  25.663 -    argc = *pargc;
  25.664 -
  25.665 -    /* To make things simpler we always copy the argv array */
  25.666 -    newArgv = JLI_MemAlloc((argc + 1) * sizeof(char *));
  25.667 -
  25.668 -    /* The program name is always present */
  25.669 -    newArgv[newArgvIdx++] = (*argv)[0];
  25.670 -
  25.671 -    for (argi = 1; argi < argc; argi++) {
  25.672 -        char *arg = (*argv)[argi];
  25.673 -        isVMType = 0;
  25.674 -
  25.675 -#ifdef JAVA_ARGS
  25.676 -        if (arg[0] != '-') {
  25.677 -            newArgv[newArgvIdx++] = arg;
  25.678 -            continue;
  25.679 -        }
  25.680 -#else
  25.681 -        if (strcmp(arg, "-classpath") == 0 ||
  25.682 -            strcmp(arg, "-cp") == 0) {
  25.683 -            newArgv[newArgvIdx++] = arg;
  25.684 -            argi++;
  25.685 -            if (argi < argc) {
  25.686 -                newArgv[newArgvIdx++] = (*argv)[argi];
  25.687 -            }
  25.688 -            continue;
  25.689 -        }
  25.690 -        if (arg[0] != '-') break;
  25.691 -#endif
  25.692 -
  25.693 -        /* Did the user pass an explicit VM type? */
  25.694 -        i = KnownVMIndex(arg);
  25.695 -        if (i >= 0) {
  25.696 -            jvmtype = knownVMs[jvmidx = i].name + 1; /* skip the - */
  25.697 -            isVMType = 1;
  25.698 -            *pargc = *pargc - 1;
  25.699 -        }
  25.700 -
  25.701 -        /* Did the user specify an "alternate" VM? */
  25.702 -        else if (strncmp(arg, "-XXaltjvm=", 10) == 0 || strncmp(arg, "-J-XXaltjvm=", 12) == 0) {
  25.703 -            isVMType = 1;
  25.704 -            jvmtype = arg+((arg[1]=='X')? 10 : 12);
  25.705 -            jvmidx = -1;
  25.706 -        }
  25.707 -
  25.708 -        if (!isVMType) {
  25.709 -            newArgv[newArgvIdx++] = arg;
  25.710 -        }
  25.711 -    }
  25.712 -
  25.713 -    /*
  25.714 -     * Finish copying the arguments if we aborted the above loop.
  25.715 -     * NOTE that if we aborted via "break" then we did NOT copy the
  25.716 -     * last argument above, and in addition argi will be less than
  25.717 -     * argc.
  25.718 -     */
  25.719 -    while (argi < argc) {
  25.720 -        newArgv[newArgvIdx++] = (*argv)[argi];
  25.721 -        argi++;
  25.722 -    }
  25.723 -
  25.724 -    /* argv is null-terminated */
  25.725 -    newArgv[newArgvIdx] = 0;
  25.726 -
  25.727 -    /* Copy back argv */
  25.728 -    *argv = newArgv;
  25.729 -    *pargc = newArgvIdx;
  25.730 -
  25.731 -    /* use the default VM type if not specified (no alias processing) */
  25.732 -    if (jvmtype == NULL) {
  25.733 -      char* result = knownVMs[0].name+1;
  25.734 -      /* Use a different VM type if we are on a server class machine? */
  25.735 -      if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) &&
  25.736 -          (ServerClassMachine() == JNI_TRUE)) {
  25.737 -        result = knownVMs[0].server_class+1;
  25.738 -      }
  25.739 -      if (_launcher_debug) {
  25.740 -        printf("Default VM: %s\n", result);
  25.741 -      }
  25.742 -      return result;
  25.743 -    }
  25.744 -
  25.745 -    /* if using an alternate VM, no alias processing */
  25.746 -    if (jvmidx < 0)
  25.747 -      return jvmtype;
  25.748 -
  25.749 -    /* Resolve aliases first */
  25.750 -    {
  25.751 -      int loopCount = 0;
  25.752 -      while (knownVMs[jvmidx].flag == VM_ALIASED_TO) {
  25.753 -        int nextIdx = KnownVMIndex(knownVMs[jvmidx].alias);
  25.754 -
  25.755 -        if (loopCount > knownVMsCount) {
  25.756 -          if (!speculative) {
  25.757 -            ReportErrorMessage("Error: Corrupt jvm.cfg file; cycle in alias list.",
  25.758 -                               JNI_TRUE);
  25.759 -            exit(1);
  25.760 -          } else {
  25.761 -            return "ERROR";
  25.762 -            /* break; */
  25.763 -          }
  25.764 -        }
  25.765 -
  25.766 -        if (nextIdx < 0) {
  25.767 -          if (!speculative) {
  25.768 -            ReportErrorMessage2("Error: Unable to resolve VM alias %s",
  25.769 -                                knownVMs[jvmidx].alias, JNI_TRUE);
  25.770 -            exit(1);
  25.771 -          } else {
  25.772 -            return "ERROR";
  25.773 -          }
  25.774 -        }
  25.775 -        jvmidx = nextIdx;
  25.776 -        jvmtype = knownVMs[jvmidx].name+1;
  25.777 -        loopCount++;
  25.778 -      }
  25.779 -    }
  25.780 -
  25.781 -    switch (knownVMs[jvmidx].flag) {
  25.782 -    case VM_WARN:
  25.783 -        if (!speculative) {
  25.784 -            fprintf(stderr, "Warning: %s VM not supported; %s VM will be used\n",
  25.785 -                    jvmtype, knownVMs[0].name + 1);
  25.786 -        }
  25.787 -        /* fall through */
  25.788 -    case VM_IGNORE:
  25.789 -        jvmtype = knownVMs[jvmidx=0].name + 1;
  25.790 -        /* fall through */
  25.791 -    case VM_KNOWN:
  25.792 -        break;
  25.793 -    case VM_ERROR:
  25.794 -        if (!speculative) {
  25.795 -            ReportErrorMessage2("Error: %s VM not supported", jvmtype, JNI_TRUE);
  25.796 -            exit(1);
  25.797 -        } else {
  25.798 -            return "ERROR";
  25.799 -        }
  25.800 -    }
  25.801 -
  25.802 -    return jvmtype;
  25.803 -}
  25.804 -#endif /* ifndef GAMMA */
  25.805 -
  25.806 -# define KB (1024UL)
  25.807 -# define MB (1024UL * KB)
  25.808 -# define GB (1024UL * MB)
  25.809 -
  25.810 -/* copied from HotSpot function "atomll()" */
  25.811 -static int
  25.812 -parse_stack_size(const char *s, jlong *result) {
  25.813 -  jlong n = 0;
  25.814 -  int args_read = sscanf(s, JLONG_FORMAT, &n);
  25.815 -  if (args_read != 1) {
  25.816 -    return 0;
  25.817 -  }
  25.818 -  while (*s != '\0' && *s >= '0' && *s <= '9') {
  25.819 -    s++;
  25.820 -  }
  25.821 -  // 4705540: illegal if more characters are found after the first non-digit
  25.822 -  if (strlen(s) > 1) {
  25.823 -    return 0;
  25.824 -  }
  25.825 -  switch (*s) {
  25.826 -    case 'T': case 't':
  25.827 -      *result = n * GB * KB;
  25.828 -      return 1;
  25.829 -    case 'G': case 'g':
  25.830 -      *result = n * GB;
  25.831 -      return 1;
  25.832 -    case 'M': case 'm':
  25.833 -      *result = n * MB;
  25.834 -      return 1;
  25.835 -    case 'K': case 'k':
  25.836 -      *result = n * KB;
  25.837 -      return 1;
  25.838 -    case '\0':
  25.839 -      *result = n;
  25.840 -      return 1;
  25.841 -    default:
  25.842 -      /* Create JVM with default stack and let VM handle malformed -Xss string*/
  25.843 -      return 0;
  25.844 -  }
  25.845 -}
  25.846 -
  25.847 -/*
  25.848 - * Adds a new VM option with the given given name and value.
  25.849 - */
  25.850 -void
  25.851 -AddOption(char *str, void *info)
  25.852 -{
  25.853 -    /*
  25.854 -     * Expand options array if needed to accommodate at least one more
  25.855 -     * VM option.
  25.856 -     */
  25.857 -    if (numOptions >= maxOptions) {
  25.858 -        if (options == 0) {
  25.859 -            maxOptions = 4;
  25.860 -            options = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
  25.861 -        } else {
  25.862 -            JavaVMOption *tmp;
  25.863 -            maxOptions *= 2;
  25.864 -            tmp = JLI_MemAlloc(maxOptions * sizeof(JavaVMOption));
  25.865 -            memcpy(tmp, options, numOptions * sizeof(JavaVMOption));
  25.866 -            JLI_MemFree(options);
  25.867 -            options = tmp;
  25.868 -        }
  25.869 -    }
  25.870 -    options[numOptions].optionString = str;
  25.871 -    options[numOptions++].extraInfo = info;
  25.872 -
  25.873 -    if (strncmp(str, "-Xss", 4) == 0) {
  25.874 -      jlong tmp;
  25.875 -      if (parse_stack_size(str + 4, &tmp)) {
  25.876 -        threadStackSize = tmp;
  25.877 -      }
  25.878 -    }
  25.879 -}
  25.880 -
  25.881 -static void
  25.882 -SetClassPath(const char *s)
  25.883 -{
  25.884 -    char *def;
  25.885 -    s = JLI_WildcardExpandClasspath(s);
  25.886 -    def = JLI_MemAlloc(strlen(s) + 40);
  25.887 -    sprintf(def, "-Djava.class.path=%s", s);
  25.888 -    AddOption(def, NULL);
  25.889 -}
  25.890 -
  25.891 -#ifndef GAMMA
  25.892 -/*
  25.893 - * The SelectVersion() routine ensures that an appropriate version of
  25.894 - * the JRE is running.  The specification for the appropriate version
  25.895 - * is obtained from either the manifest of a jar file (preferred) or
  25.896 - * from command line options.
  25.897 - * The routine also parses splash screen command line options and
  25.898 - * passes on their values in private environment variables.
  25.899 - */
  25.900 -static void
  25.901 -SelectVersion(int argc, char **argv, char **main_class)
  25.902 -{
  25.903 -    char    *arg;
  25.904 -    char    **new_argv;
  25.905 -    char    **new_argp;
  25.906 -    char    *operand;
  25.907 -    char    *version = NULL;
  25.908 -    char    *jre = NULL;
  25.909 -    int     jarflag = 0;
  25.910 -    int     headlessflag = 0;
  25.911 -    int     restrict_search = -1;               /* -1 implies not known */
  25.912 -    manifest_info info;
  25.913 -    char    env_entry[MAXNAMELEN + 24] = ENV_ENTRY "=";
  25.914 -    char    *splash_file_name = NULL;
  25.915 -    char    *splash_jar_name = NULL;
  25.916 -    char    *env_in;
  25.917 -    int     res;
  25.918 -
  25.919 -    /*
  25.920 -     * If the version has already been selected, set *main_class
  25.921 -     * with the value passed through the environment (if any) and
  25.922 -     * simply return.
  25.923 -     */
  25.924 -    if ((env_in = getenv(ENV_ENTRY)) != NULL) {
  25.925 -        if (*env_in != '\0')
  25.926 -            *main_class = JLI_StringDup(env_in);
  25.927 -        return;
  25.928 -    }
  25.929 -
  25.930 -    /*
  25.931 -     * Scan through the arguments for options relevant to multiple JRE
  25.932 -     * support.  For reference, the command line syntax is defined as:
  25.933 -     *
  25.934 -     * SYNOPSIS
  25.935 -     *      java [options] class [argument...]
  25.936 -     *
  25.937 -     *      java [options] -jar file.jar [argument...]
  25.938 -     *
  25.939 -     * As the scan is performed, make a copy of the argument list with
  25.940 -     * the version specification options (new to 1.5) removed, so that
  25.941 -     * a version less than 1.5 can be exec'd.
  25.942 -     *
  25.943 -     * Note that due to the syntax of the native Windows interface
  25.944 -     * CreateProcess(), processing similar to the following exists in
  25.945 -     * the Windows platform specific routine ExecJRE (in java_md.c).
  25.946 -     * Changes here should be reproduced there.
  25.947 -     */
  25.948 -    new_argv = JLI_MemAlloc((argc + 1) * sizeof(char*));
  25.949 -    new_argv[0] = argv[0];
  25.950 -    new_argp = &new_argv[1];
  25.951 -    argc--;
  25.952 -    argv++;
  25.953 -    while ((arg = *argv) != 0 && *arg == '-') {
  25.954 -        if (strncmp(arg, "-version:", 9) == 0) {
  25.955 -            version = arg + 9;
  25.956 -        } else if (strcmp(arg, "-jre-restrict-search") == 0) {
  25.957 -            restrict_search = 1;
  25.958 -        } else if (strcmp(arg, "-no-jre-restrict-search") == 0) {
  25.959 -            restrict_search = 0;
  25.960 -        } else {
  25.961 -            if (strcmp(arg, "-jar") == 0)
  25.962 -                jarflag = 1;
  25.963 -            /* deal with "unfortunate" classpath syntax */
  25.964 -            if ((strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) &&
  25.965 -              (argc >= 2)) {
  25.966 -                *new_argp++ = arg;
  25.967 -                argc--;
  25.968 -                argv++;
  25.969 -                arg = *argv;
  25.970 -            }
  25.971 -
  25.972 -            /*
  25.973 -             * Checking for headless toolkit option in the some way as AWT does:
  25.974 -             * "true" means true and any other value means false
  25.975 -             */
  25.976 -            if (strcmp(arg, "-Djava.awt.headless=true") == 0) {
  25.977 -                headlessflag = 1;
  25.978 -            } else if (strncmp(arg, "-Djava.awt.headless=", 20) == 0) {
  25.979 -                headlessflag = 0;
  25.980 -            } else if (strncmp(arg, "-splash:", 8) == 0) {
  25.981 -                splash_file_name = arg+8;
  25.982 -            }
  25.983 -            *new_argp++ = arg;
  25.984 -        }
  25.985 -        argc--;
  25.986 -        argv++;
  25.987 -    }
  25.988 -    if (argc <= 0) {    /* No operand? Possibly legit with -[full]version */
  25.989 -        operand = NULL;
  25.990 -    } else {
  25.991 -        argc--;
  25.992 -        *new_argp++ = operand = *argv++;
  25.993 -    }
  25.994 -    while (argc-- > 0)  /* Copy over [argument...] */
  25.995 -        *new_argp++ = *argv++;
  25.996 -    *new_argp = NULL;
  25.997 -
  25.998 -    /*
  25.999 -     * If there is a jar file, read the manifest. If the jarfile can't be
 25.1000 -     * read, the manifest can't be read from the jar file, or the manifest
 25.1001 -     * is corrupt, issue the appropriate error messages and exit.
 25.1002 -     *
 25.1003 -     * Even if there isn't a jar file, construct a manifest_info structure
 25.1004 -     * containing the command line information.  It's a convenient way to carry
 25.1005 -     * this data around.
 25.1006 -     */
 25.1007 -    if (jarflag && operand) {
 25.1008 -        if ((res = JLI_ParseManifest(operand, &info)) != 0) {
 25.1009 -            if (res == -1)
 25.1010 -                ReportErrorMessage2("Unable to access jarfile %s",
 25.1011 -                  operand, JNI_TRUE);
 25.1012 -            else
 25.1013 -                ReportErrorMessage2("Invalid or corrupt jarfile %s",
 25.1014 -                  operand, JNI_TRUE);
 25.1015 -            exit(1);
 25.1016 -        }
 25.1017 -
 25.1018 -        /*
 25.1019 -         * Command line splash screen option should have precedence
 25.1020 -         * over the manifest, so the manifest data is used only if
 25.1021 -         * splash_file_name has not been initialized above during command
 25.1022 -         * line parsing
 25.1023 -         */
 25.1024 -        if (!headlessflag && !splash_file_name && info.splashscreen_image_file_name) {
 25.1025 -            splash_file_name = info.splashscreen_image_file_name;
 25.1026 -            splash_jar_name = operand;
 25.1027 -        }
 25.1028 -    } else {
 25.1029 -        info.manifest_version = NULL;
 25.1030 -        info.main_class = NULL;
 25.1031 -        info.jre_version = NULL;
 25.1032 -        info.jre_restrict_search = 0;
 25.1033 -    }
 25.1034 -
 25.1035 -    /*
 25.1036 -     * Passing on splash screen info in environment variables
 25.1037 -     */
 25.1038 -    if (splash_file_name && !headlessflag) {
 25.1039 -        char* splash_file_entry = JLI_MemAlloc(strlen(SPLASH_FILE_ENV_ENTRY "=")+strlen(splash_file_name)+1);
 25.1040 -        strcpy(splash_file_entry, SPLASH_FILE_ENV_ENTRY "=");
 25.1041 -        strcat(splash_file_entry, splash_file_name);
 25.1042 -        putenv(splash_file_entry);
 25.1043 -    }
 25.1044 -    if (splash_jar_name && !headlessflag) {
 25.1045 -        char* splash_jar_entry = JLI_MemAlloc(strlen(SPLASH_JAR_ENV_ENTRY "=")+strlen(splash_jar_name)+1);
 25.1046 -        strcpy(splash_jar_entry, SPLASH_JAR_ENV_ENTRY "=");
 25.1047 -        strcat(splash_jar_entry, splash_jar_name);
 25.1048 -        putenv(splash_jar_entry);
 25.1049 -    }
 25.1050 -
 25.1051 -    /*
 25.1052 -     * The JRE-Version and JRE-Restrict-Search values (if any) from the
 25.1053 -     * manifest are overwritten by any specified on the command line.
 25.1054 -     */
 25.1055 -    if (version != NULL)
 25.1056 -        info.jre_version = version;
 25.1057 -    if (restrict_search != -1)
 25.1058 -        info.jre_restrict_search = restrict_search;
 25.1059 -
 25.1060 -    /*
 25.1061 -     * "Valid" returns (other than unrecoverable errors) follow.  Set
 25.1062 -     * main_class as a side-effect of this routine.
 25.1063 -     */
 25.1064 -    if (info.main_class != NULL)
 25.1065 -        *main_class = JLI_StringDup(info.main_class);
 25.1066 -
 25.1067 -    /*
 25.1068 -     * If no version selection information is found either on the command
 25.1069 -     * line or in the manifest, simply return.
 25.1070 -     */
 25.1071 -    if (info.jre_version == NULL) {
 25.1072 -        JLI_FreeManifest();
 25.1073 -        JLI_MemFree(new_argv);
 25.1074 -        return;
 25.1075 -    }
 25.1076 -
 25.1077 -    /*
 25.1078 -     * Check for correct syntax of the version specification (JSR 56).
 25.1079 -     */
 25.1080 -    if (!JLI_ValidVersionString(info.jre_version)) {
 25.1081 -        ReportErrorMessage2("Syntax error in version specification \"%s\"",
 25.1082 -          info.jre_version, JNI_TRUE);
 25.1083 -        exit(1);
 25.1084 -    }
 25.1085 -
 25.1086 -    /*
 25.1087 -     * Find the appropriate JVM on the system. Just to be as forgiving as
 25.1088 -     * possible, if the standard algorithms don't locate an appropriate
 25.1089 -     * jre, check to see if the one running will satisfy the requirements.
 25.1090 -     * This can happen on systems which haven't been set-up for multiple
 25.1091 -     * JRE support.
 25.1092 -     */
 25.1093 -    jre = LocateJRE(&info);
 25.1094 -    if (_launcher_debug)
 25.1095 -        printf("JRE-Version = %s, JRE-Restrict-Search = %s Selected = %s\n",
 25.1096 -          (info.jre_version?info.jre_version:"null"),
 25.1097 -          (info.jre_restrict_search?"true":"false"), (jre?jre:"null"));
 25.1098 -    if (jre == NULL) {
 25.1099 -        if (JLI_AcceptableRelease(FULL_VERSION, info.jre_version)) {
 25.1100 -            JLI_FreeManifest();
 25.1101 -            JLI_MemFree(new_argv);
 25.1102 -            return;
 25.1103 -        } else {
 25.1104 -            ReportErrorMessage2(
 25.1105 -              "Unable to locate JRE meeting specification \"%s\"",
 25.1106 -              info.jre_version, JNI_TRUE);
 25.1107 -            exit(1);
 25.1108 -        }
 25.1109 -    }
 25.1110 -
 25.1111 -    /*
 25.1112 -     * If I'm not the chosen one, exec the chosen one.  Returning from
 25.1113 -     * ExecJRE indicates that I am indeed the chosen one.
 25.1114 -     *
 25.1115 -     * The private environment variable _JAVA_VERSION_SET is used to
 25.1116 -     * prevent the chosen one from re-reading the manifest file and
 25.1117 -     * using the values found within to override the (potential) command
 25.1118 -     * line flags stripped from argv (because the target may not
 25.1119 -     * understand them).  Passing the MainClass value is an optimization
 25.1120 -     * to avoid locating, expanding and parsing the manifest extra
 25.1121 -     * times.
 25.1122 -     */
 25.1123 -    if (info.main_class != NULL) {
 25.1124 -        if (strlen(info.main_class) <= MAXNAMELEN) {
 25.1125 -            (void)strcat(env_entry, info.main_class);
 25.1126 -        } else {
 25.1127 -            ReportErrorMessage("Error: main-class: attribute exceeds system limits\n", JNI_TRUE);
 25.1128 -            exit(1);
 25.1129 -        }
 25.1130 -    }
 25.1131 -    (void)putenv(env_entry);
 25.1132 -    ExecJRE(jre, new_argv);
 25.1133 -    JLI_FreeManifest();
 25.1134 -    JLI_MemFree(new_argv);
 25.1135 -    return;
 25.1136 -}
 25.1137 -#endif /* ifndef GAMMA */
 25.1138 -
 25.1139 -/*
 25.1140 - * Parses command line arguments.  Returns JNI_FALSE if launcher
 25.1141 - * should exit without starting vm (e.g. certain version and usage
 25.1142 - * options); returns JNI_TRUE if vm needs to be started to process
 25.1143 - * given options.  *pret (the launcher process return value) is set to
 25.1144 - * 0 for a normal exit.
 25.1145 - */
 25.1146 -static jboolean
 25.1147 -ParseArguments(int *pargc, char ***pargv, char **pjarfile,
 25.1148 -                       char **pclassname, int *pret, const char *jvmpath)
 25.1149 -{
 25.1150 -    int argc = *pargc;
 25.1151 -    char **argv = *pargv;
 25.1152 -    jboolean jarflag = JNI_FALSE;
 25.1153 -    char *arg;
 25.1154 -
 25.1155 -    *pret = 1;
 25.1156 -    while ((arg = *argv) != 0 && *arg == '-') {
 25.1157 -        argv++; --argc;
 25.1158 -        if (strcmp(arg, "-classpath") == 0 || strcmp(arg, "-cp") == 0) {
 25.1159 -            if (argc < 1) {
 25.1160 -                ReportErrorMessage2("%s requires class path specification",
 25.1161 -                                    arg, JNI_TRUE);
 25.1162 -                PrintUsage();
 25.1163 -                return JNI_FALSE;
 25.1164 -            }
 25.1165 -            SetClassPath(*argv);
 25.1166 -            argv++; --argc;
 25.1167 -        } else if (strcmp(arg, "-jar") == 0) {
 25.1168 -            jarflag = JNI_TRUE;
 25.1169 -        } else if (strcmp(arg, "-help") == 0 ||
 25.1170 -                   strcmp(arg, "-h") == 0 ||
 25.1171 -                   strcmp(arg, "-?") == 0) {
 25.1172 -            PrintUsage();
 25.1173 -            *pret = 0;
 25.1174 -            return JNI_FALSE;
 25.1175 -        } else if (strcmp(arg, "-version") == 0) {
 25.1176 -            printVersion = JNI_TRUE;
 25.1177 -            return JNI_TRUE;
 25.1178 -        } else if (strcmp(arg, "-showversion") == 0) {
 25.1179 -            showVersion = JNI_TRUE;
 25.1180 -        } else if (strcmp(arg, "-X") == 0) {
 25.1181 -            *pret = PrintXUsage(jvmpath);
 25.1182 -            return JNI_FALSE;
 25.1183 -/*
 25.1184 - * The following case provide backward compatibility with old-style
 25.1185 - * command line options.
 25.1186 - */
 25.1187 -        } else if (strcmp(arg, "-fullversion") == 0) {
 25.1188 -            fprintf(stderr, "%s full version \"%s\"\n", progname,
 25.1189 -                    FULL_VERSION);
 25.1190 -            *pret = 0;
 25.1191 -            return JNI_FALSE;
 25.1192 -        } else if (strcmp(arg, "-verbosegc") == 0) {
 25.1193 -            AddOption("-verbose:gc", NULL);
 25.1194 -        } else if (strcmp(arg, "-t") == 0) {
 25.1195 -            AddOption("-Xt", NULL);
 25.1196 -        } else if (strcmp(arg, "-tm") == 0) {
 25.1197 -            AddOption("-Xtm", NULL);
 25.1198 -        } else if (strcmp(arg, "-debug") == 0) {
 25.1199 -            AddOption("-Xdebug", NULL);
 25.1200 -        } else if (strcmp(arg, "-noclassgc") == 0) {
 25.1201 -            AddOption("-Xnoclassgc", NULL);
 25.1202 -        } else if (strcmp(arg, "-Xfuture") == 0) {
 25.1203 -            AddOption("-Xverify:all", NULL);
 25.1204 -        } else if (strcmp(arg, "-verify") == 0) {
 25.1205 -            AddOption("-Xverify:all", NULL);
 25.1206 -        } else if (strcmp(arg, "-verifyremote") == 0) {
 25.1207 -            AddOption("-Xverify:remote", NULL);
 25.1208 -        } else if (strcmp(arg, "-noverify") == 0) {
 25.1209 -            AddOption("-Xverify:none", NULL);
 25.1210 -        } else if (strcmp(arg, "-XXsuppressExitMessage") == 0) {
 25.1211 -            noExitErrorMessage = 1;
 25.1212 -        } else if (strncmp(arg, "-prof", 5) == 0) {
 25.1213 -            char *p = arg + 5;
 25.1214 -            char *tmp = JLI_MemAlloc(strlen(arg) + 50);
 25.1215 -            if (*p) {
 25.1216 -                sprintf(tmp, "-Xrunhprof:cpu=old,file=%s", p + 1);
 25.1217 -            } else {
 25.1218 -                sprintf(tmp, "-Xrunhprof:cpu=old,file=java.prof");
 25.1219 -            }
 25.1220 -            AddOption(tmp, NULL);
 25.1221 -        } else if (strncmp(arg, "-ss", 3) == 0 ||
 25.1222 -                   strncmp(arg, "-oss", 4) == 0 ||
 25.1223 -                   strncmp(arg, "-ms", 3) == 0 ||
 25.1224 -                   strncmp(arg, "-mx", 3) == 0) {
 25.1225 -            char *tmp = JLI_MemAlloc(strlen(arg) + 6);
 25.1226 -            sprintf(tmp, "-X%s", arg + 1); /* skip '-' */
 25.1227 -            AddOption(tmp, NULL);
 25.1228 -        } else if (strcmp(arg, "-checksource") == 0 ||
 25.1229 -                   strcmp(arg, "-cs") == 0 ||
 25.1230 -                   strcmp(arg, "-noasyncgc") == 0) {
 25.1231 -            /* No longer supported */
 25.1232 -            fprintf(stderr,
 25.1233 -                    "Warning: %s option is no longer supported.\n",
 25.1234 -                    arg);
 25.1235 -        } else if (strncmp(arg, "-version:", 9) == 0 ||
 25.1236 -                   strcmp(arg, "-no-jre-restrict-search") == 0 ||
 25.1237 -                   strcmp(arg, "-jre-restrict-search") == 0 ||
 25.1238 -                   strncmp(arg, "-splash:", 8) == 0) {
 25.1239 -            ; /* Ignore machine independent options already handled */
 25.1240 -        } else if (RemovableMachineDependentOption(arg) ) {
 25.1241 -            ; /* Do not pass option to vm. */
 25.1242 -        }
 25.1243 -        else {
 25.1244 -            AddOption(arg, NULL);
 25.1245 -        }
 25.1246 -    }
 25.1247 -
 25.1248 -    if (--argc >= 0) {
 25.1249 -        if (jarflag) {
 25.1250 -            *pjarfile = *argv++;
 25.1251 -            *pclassname = 0;
 25.1252 -        } else {
 25.1253 -            *pjarfile = 0;
 25.1254 -            *pclassname = *argv++;
 25.1255 -        }
 25.1256 -        *pargc = argc;
 25.1257 -        *pargv = argv;
 25.1258 -    }
 25.1259 -
 25.1260 -    return JNI_TRUE;
 25.1261 -}
 25.1262 -
 25.1263 -/*
 25.1264 - * Initializes the Java Virtual Machine. Also frees options array when
 25.1265 - * finished.
 25.1266 - */
 25.1267 -static jboolean
 25.1268 -InitializeJVM(JavaVM **pvm, JNIEnv **penv, InvocationFunctions *ifn)
 25.1269 -{
 25.1270 -    JavaVMInitArgs args;
 25.1271 -    jint r;
 25.1272 -
 25.1273 -    memset(&args, 0, sizeof(args));
 25.1274 -    args.version  = JNI_VERSION_1_2;
 25.1275 -    args.nOptions = numOptions;
 25.1276 -    args.options  = options;
 25.1277 -    args.ignoreUnrecognized = JNI_FALSE;
 25.1278 -
 25.1279 -    if (_launcher_debug) {
 25.1280 -        int i = 0;
 25.1281 -        printf("JavaVM args:\n    ");
 25.1282 -        printf("version 0x%08lx, ", (long)args.version);
 25.1283 -        printf("ignoreUnrecognized is %s, ",
 25.1284 -               args.ignoreUnrecognized ? "JNI_TRUE" : "JNI_FALSE");
 25.1285 -        printf("nOptions is %ld\n", (long)args.nOptions);
 25.1286 -        for (i = 0; i < numOptions; i++)
 25.1287 -            printf("    option[%2d] = '%s'\n",
 25.1288 -                   i, args.options[i].optionString);
 25.1289 -    }
 25.1290 -
 25.1291 -    r = ifn->CreateJavaVM(pvm, (void **)penv, &args);
 25.1292 -    JLI_MemFree(options);
 25.1293 -    return r == JNI_OK;
 25.1294 -}
 25.1295 -
 25.1296 -
 25.1297 -#define NULL_CHECK0(e) if ((e) == 0) return 0
 25.1298 -#define NULL_CHECK(e) if ((e) == 0) return
 25.1299 -
 25.1300 -static jstring platformEncoding = NULL;
 25.1301 -static jstring getPlatformEncoding(JNIEnv *env) {
 25.1302 -    if (platformEncoding == NULL) {
 25.1303 -        jstring propname = (*env)->NewStringUTF(env, "sun.jnu.encoding");
 25.1304 -        if (propname) {
 25.1305 -            jclass cls;
 25.1306 -            jmethodID mid;
 25.1307 -            NULL_CHECK0 (cls = (*env)->FindClass(env, "java/lang/System"));
 25.1308 -            NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
 25.1309 -                                   env, cls,
 25.1310 -                                   "getProperty",
 25.1311 -                                   "(Ljava/lang/String;)Ljava/lang/String;"));
 25.1312 -            platformEncoding = (*env)->CallStaticObjectMethod (
 25.1313 -                                    env, cls, mid, propname);
 25.1314 -        }
 25.1315 -    }
 25.1316 -    return platformEncoding;
 25.1317 -}
 25.1318 -
 25.1319 -static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
 25.1320 -    jclass cls;
 25.1321 -    jmethodID mid;
 25.1322 -    NULL_CHECK0 (cls = (*env)->FindClass(env, "java/nio/charset/Charset"));
 25.1323 -    NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
 25.1324 -                           env, cls,
 25.1325 -                           "isSupported",
 25.1326 -                           "(Ljava/lang/String;)Z"));
 25.1327 -    return (*env)->CallStaticBooleanMethod(env, cls, mid, enc);
 25.1328 -}
 25.1329 -
 25.1330 -/*
 25.1331 - * Returns a new Java string object for the specified platform string.
 25.1332 - */
 25.1333 -static jstring
 25.1334 -NewPlatformString(JNIEnv *env, char *s)
 25.1335 -{
 25.1336 -    int len = (int)strlen(s);
 25.1337 -    jclass cls;
 25.1338 -    jmethodID mid;
 25.1339 -    jbyteArray ary;
 25.1340 -    jstring enc;
 25.1341 -
 25.1342 -    if (s == NULL)
 25.1343 -        return 0;
 25.1344 -    enc = getPlatformEncoding(env);
 25.1345 -
 25.1346 -    ary = (*env)->NewByteArray(env, len);
 25.1347 -    if (ary != 0) {
 25.1348 -        jstring str = 0;
 25.1349 -        (*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
 25.1350 -        if (!(*env)->ExceptionOccurred(env)) {
 25.1351 -            if (isEncodingSupported(env, enc) == JNI_TRUE) {
 25.1352 -                NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
 25.1353 -                NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
 25.1354 -                                          "([BLjava/lang/String;)V"));
 25.1355 -                str = (*env)->NewObject(env, cls, mid, ary, enc);
 25.1356 -            } else {
 25.1357 -                /*If the encoding specified in sun.jnu.encoding is not
 25.1358 -                  endorsed by "Charset.isSupported" we have to fall back
 25.1359 -                  to use String(byte[]) explicitly here without specifying
 25.1360 -                  the encoding name, in which the StringCoding class will
 25.1361 -                  pickup the iso-8859-1 as the fallback converter for us.
 25.1362 -                */
 25.1363 -                NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
 25.1364 -                NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
 25.1365 -                                          "([B)V"));
 25.1366 -                str = (*env)->NewObject(env, cls, mid, ary);
 25.1367 -            }
 25.1368 -            (*env)->DeleteLocalRef(env, ary);
 25.1369 -            return str;
 25.1370 -        }
 25.1371 -    }
 25.1372 -    return 0;
 25.1373 -}
 25.1374 -
 25.1375 -/*
 25.1376 - * Returns a new array of Java string objects for the specified
 25.1377 - * array of platform strings.
 25.1378 - */
 25.1379 -static jobjectArray
 25.1380 -NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
 25.1381 -{
 25.1382 -    jarray cls;
 25.1383 -    jarray ary;
 25.1384 -    int i;
 25.1385 -
 25.1386 -    NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
 25.1387 -    NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));
 25.1388 -    for (i = 0; i < strc; i++) {
 25.1389 -        jstring str = NewPlatformString(env, *strv++);
 25.1390 -        NULL_CHECK0(str);
 25.1391 -        (*env)->SetObjectArrayElement(env, ary, i, str);
 25.1392 -        (*env)->DeleteLocalRef(env, str);
 25.1393 -    }
 25.1394 -    return ary;
 25.1395 -}
 25.1396 -
 25.1397 -/*
 25.1398 - * Loads a class, convert the '.' to '/'.
 25.1399 - */
 25.1400 -static jclass
 25.1401 -LoadClass(JNIEnv *env, char *name)
 25.1402 -{
 25.1403 -    char *buf = JLI_MemAlloc(strlen(name) + 1);
 25.1404 -    char *s = buf, *t = name, c;
 25.1405 -    jclass cls;
 25.1406 -    jlong start, end;
 25.1407 -
 25.1408 -    if (_launcher_debug)
 25.1409 -        start = CounterGet();
 25.1410 -
 25.1411 -    do {
 25.1412 -        c = *t++;
 25.1413 -        *s++ = (c == '.') ? '/' : c;
 25.1414 -    } while (c != '\0');
 25.1415 -    cls = (*env)->FindClass(env, buf);
 25.1416 -    JLI_MemFree(buf);
 25.1417 -
 25.1418 -    if (_launcher_debug) {
 25.1419 -        end   = CounterGet();
 25.1420 -        printf("%ld micro seconds to load main class\n",
 25.1421 -               (long)(jint)Counter2Micros(end-start));
 25.1422 -        printf("----_JAVA_LAUNCHER_DEBUG----\n");
 25.1423 -    }
 25.1424 -
 25.1425 -    return cls;
 25.1426 -}
 25.1427 -
 25.1428 -
 25.1429 -/*
 25.1430 - * Returns the main class name for the specified jar file.
 25.1431 - */
 25.1432 -static jstring
 25.1433 -GetMainClassName(JNIEnv *env, char *jarname)
 25.1434 -{
 25.1435 -#define MAIN_CLASS "Main-Class"
 25.1436 -    jclass cls;
 25.1437 -    jmethodID mid;
 25.1438 -    jobject jar, man, attr;
 25.1439 -    jstring str, result = 0;
 25.1440 -
 25.1441 -    NULL_CHECK0(cls = (*env)->FindClass(env, "java/util/jar/JarFile"));
 25.1442 -    NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
 25.1443 -                                          "(Ljava/lang/String;)V"));
 25.1444 -    NULL_CHECK0(str = NewPlatformString(env, jarname));
 25.1445 -    NULL_CHECK0(jar = (*env)->NewObject(env, cls, mid, str));
 25.1446 -    NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "getManifest",
 25.1447 -                                          "()Ljava/util/jar/Manifest;"));
 25.1448 -    man = (*env)->CallObjectMethod(env, jar, mid);
 25.1449 -    if (man != 0) {
 25.1450 -        NULL_CHECK0(mid = (*env)->GetMethodID(env,
 25.1451 -                                    (*env)->GetObjectClass(env, man),
 25.1452 -                                    "getMainAttributes",
 25.1453 -                                    "()Ljava/util/jar/Attributes;"));
 25.1454 -        attr = (*env)->CallObjectMethod(env, man, mid);
 25.1455 -        if (attr != 0) {
 25.1456 -            NULL_CHECK0(mid = (*env)->GetMethodID(env,
 25.1457 -                                    (*env)->GetObjectClass(env, attr),
 25.1458 -                                    "getValue",
 25.1459 -                                    "(Ljava/lang/String;)Ljava/lang/String;"));
 25.1460 -            NULL_CHECK0(str = NewPlatformString(env, MAIN_CLASS));
 25.1461 -            result = (*env)->CallObjectMethod(env, attr, mid, str);
 25.1462 -        }
 25.1463 -    }
 25.1464 -    return result;
 25.1465 -}
 25.1466 -
 25.1467 -#ifdef JAVA_ARGS
 25.1468 -static char *java_args[] = JAVA_ARGS;
 25.1469 -static char *app_classpath[] = APP_CLASSPATH;
 25.1470 -
 25.1471 -/*
 25.1472 - * For tools, convert command line args thus:
 25.1473 - *   javac -cp foo:foo/"*" -J-ms32m ...
 25.1474 - *   java -ms32m -cp JLI_WildcardExpandClasspath(foo:foo/"*") ...
 25.1475 - */
 25.1476 -static void
 25.1477 -TranslateApplicationArgs(int *pargc, char ***pargv)
 25.1478 -{
 25.1479 -    const int NUM_ARGS = (sizeof(java_args) / sizeof(char *));
 25.1480 -    int argc = *pargc;
 25.1481 -    char **argv = *pargv;
 25.1482 -    int nargc = argc + NUM_ARGS;
 25.1483 -    char **nargv = JLI_MemAlloc((nargc + 1) * sizeof(char *));
 25.1484 -    int i;
 25.1485 -
 25.1486 -    *pargc = nargc;
 25.1487 -    *pargv = nargv;
 25.1488 -
 25.1489 -    /* Copy the VM arguments (i.e. prefixed with -J) */
 25.1490 -    for (i = 0; i < NUM_ARGS; i++) {
 25.1491 -        char *arg = java_args[i];
 25.1492 -        if (arg[0] == '-' && arg[1] == 'J') {
 25.1493 -            *nargv++ = arg + 2;
 25.1494 -        }
 25.1495 -    }
 25.1496 -
 25.1497 -    for (i = 0; i < argc; i++) {
 25.1498 -        char *arg = argv[i];
 25.1499 -        if (arg[0] == '-' && arg[1] == 'J') {
 25.1500 -            if (arg[2] == '\0') {
 25.1501 -                ReportErrorMessage("Error: the -J option should not be "
 25.1502 -                                   "followed by a space.", JNI_TRUE);
 25.1503 -                exit(1);
 25.1504 -            }
 25.1505 -            *nargv++ = arg + 2;
 25.1506 -        }
 25.1507 -    }
 25.1508 -
 25.1509 -    /* Copy the rest of the arguments */
 25.1510 -    for (i = 0; i < NUM_ARGS; i++) {
 25.1511 -        char *arg = java_args[i];
 25.1512 -        if (arg[0] != '-' || arg[1] != 'J') {
 25.1513 -            *nargv++ = arg;
 25.1514 -        }
 25.1515 -    }
 25.1516 -    for (i = 0; i < argc; i++) {
 25.1517 -        char *arg = argv[i];
 25.1518 -        if (arg[0] == '-') {
 25.1519 -            if (arg[1] == 'J')
 25.1520 -                continue;
 25.1521 -#ifdef EXPAND_CLASSPATH_WILDCARDS
 25.1522 -            if (arg[1] == 'c'
 25.1523 -                && (strcmp(arg, "-cp") == 0 ||
 25.1524 -                    strcmp(arg, "-classpath") == 0)
 25.1525 -                && i < argc - 1) {
 25.1526 -                *nargv++ = arg;
 25.1527 -                *nargv++ = (char *) JLI_WildcardExpandClasspath(argv[i+1]);
 25.1528 -                i++;
 25.1529 -                continue;
 25.1530 -            }
 25.1531 -#endif
 25.1532 -        }
 25.1533 -        *nargv++ = arg;
 25.1534 -    }
 25.1535 -    *nargv = 0;
 25.1536 -}
 25.1537 -
 25.1538 -/*
 25.1539 - * For our tools, we try to add 3 VM options:
 25.1540 - *      -Denv.class.path=<envcp>
 25.1541 - *      -Dapplication.home=<apphome>
 25.1542 - *      -Djava.class.path=<appcp>
 25.1543 - * <envcp>   is the user's setting of CLASSPATH -- for instance the user
 25.1544 - *           tells javac where to find binary classes through this environment
 25.1545 - *           variable.  Notice that users will be able to compile against our
 25.1546 - *           tools classes (sun.tools.javac.Main) only if they explicitly add
 25.1547 - *           tools.jar to CLASSPATH.
 25.1548 - * <apphome> is the directory where the application is installed.
 25.1549 - * <appcp>   is the classpath to where our apps' classfiles are.
 25.1550 - */
 25.1551 -static jboolean
 25.1552 -AddApplicationOptions()
 25.1553 -{
 25.1554 -    const int NUM_APP_CLASSPATH = (sizeof(app_classpath) / sizeof(char *));
 25.1555 -    char *envcp, *appcp, *apphome;
 25.1556 -    char home[MAXPATHLEN]; /* application home */
 25.1557 -    char separator[] = { PATH_SEPARATOR, '\0' };
 25.1558 -    int size, i;
 25.1559 -    int strlenHome;
 25.1560 -
 25.1561 -    {
 25.1562 -        const char *s = getenv("CLASSPATH");
 25.1563 -        if (s) {
 25.1564 -            s = (char *) JLI_WildcardExpandClasspath(s);
 25.1565 -            /* 40 for -Denv.class.path= */
 25.1566 -            envcp = (char *)JLI_MemAlloc(strlen(s) + 40);
 25.1567 -            sprintf(envcp, "-Denv.class.path=%s", s);
 25.1568 -            AddOption(envcp, NULL);
 25.1569 -        }
 25.1570 -    }
 25.1571 -
 25.1572 -    if (!GetApplicationHome(home, sizeof(home))) {
 25.1573 -        ReportErrorMessage("Can't determine application home", JNI_TRUE);
 25.1574 -        return JNI_FALSE;
 25.1575 -    }
 25.1576 -
 25.1577 -    /* 40 for '-Dapplication.home=' */
 25.1578 -    apphome = (char *)JLI_MemAlloc(strlen(home) + 40);
 25.1579 -    sprintf(apphome, "-Dapplication.home=%s", home);
 25.1580 -    AddOption(apphome, NULL);
 25.1581 -
 25.1582 -    /* How big is the application's classpath? */
 25.1583 -    size = 40;                                 /* 40: "-Djava.class.path=" */
 25.1584 -    strlenHome = (int)strlen(home);
 25.1585 -    for (i = 0; i < NUM_APP_CLASSPATH; i++) {
 25.1586 -        size += strlenHome + (int)strlen(app_classpath[i]) + 1; /* 1: separator */
 25.1587 -    }
 25.1588 -    appcp = (char *)JLI_MemAlloc(size + 1);
 25.1589 -    strcpy(appcp, "-Djava.class.path=");
 25.1590 -    for (i = 0; i < NUM_APP_CLASSPATH; i++) {
 25.1591 -        strcat(appcp, home);                    /* c:\program files\myapp */
 25.1592 -        strcat(appcp, app_classpath[i]);        /* \lib\myapp.jar         */
 25.1593 -        strcat(appcp, separator);               /* ;                      */
 25.1594 -    }
 25.1595 -    appcp[strlen(appcp)-1] = '\0';  /* remove trailing path separator */
 25.1596 -    AddOption(appcp, NULL);
 25.1597 -    return JNI_TRUE;
 25.1598 -}
 25.1599 -#endif /* JAVA_ARGS */
 25.1600 -
 25.1601 -/*
 25.1602 - * inject the -Dsun.java.command pseudo property into the args structure
 25.1603 - * this pseudo property is used in the HotSpot VM to expose the
 25.1604 - * Java class name and arguments to the main method to the VM. The
 25.1605 - * HotSpot VM uses this pseudo property to store the Java class name
 25.1606 - * (or jar file name) and the arguments to the class's main method
 25.1607 - * to the instrumentation memory region. The sun.java.command pseudo
 25.1608 - * property is not exported by HotSpot to the Java layer.
 25.1609 - */
 25.1610 -void
 25.1611 -SetJavaCommandLineProp(char *classname, char *jarfile,
 25.1612 -                       int argc, char **argv)
 25.1613 -{
 25.1614 -
 25.1615 -    int i = 0;
 25.1616 -    size_t len = 0;
 25.1617 -    char* javaCommand = NULL;
 25.1618 -    char* dashDstr = "-Dsun.java.command=";
 25.1619 -
 25.1620 -    if (classname == NULL && jarfile == NULL) {
 25.1621 -        /* unexpected, one of these should be set. just return without
 25.1622 -         * setting the property
 25.1623 -         */
 25.1624 -        return;
 25.1625 -    }
 25.1626 -
 25.1627 -    /* if the class name is not set, then use the jarfile name */
 25.1628 -    if (classname == NULL) {
 25.1629 -        classname = jarfile;
 25.1630 -    }
 25.1631 -
 25.1632 -    /* determine the amount of memory to allocate assuming
 25.1633 -     * the individual components will be space separated
 25.1634 -     */
 25.1635 -    len = strlen(classname);
 25.1636 -    for (i = 0; i < argc; i++) {
 25.1637 -        len += strlen(argv[i]) + 1;
 25.1638 -    }
 25.1639 -
 25.1640 -    /* allocate the memory */
 25.1641 -    javaCommand = (char*) JLI_MemAlloc(len + strlen(dashDstr) + 1);
 25.1642 -
 25.1643 -    /* build the -D string */
 25.1644 -    *javaCommand = '\0';
 25.1645 -    strcat(javaCommand, dashDstr);
 25.1646 -    strcat(javaCommand, classname);
 25.1647 -
 25.1648 -    for (i = 0; i < argc; i++) {
 25.1649 -        /* the components of the string are space separated. In
 25.1650 -         * the case of embedded white space, the relationship of
 25.1651 -         * the white space separated components to their true
 25.1652 -         * positional arguments will be ambiguous. This issue may
 25.1653 -         * be addressed in a future release.
 25.1654 -         */
 25.1655 -        strcat(javaCommand, " ");
 25.1656 -        strcat(javaCommand, argv[i]);
 25.1657 -    }
 25.1658 -
 25.1659 -    AddOption(javaCommand, NULL);
 25.1660 -}
 25.1661 -
 25.1662 -/*
 25.1663 - * JVM would like to know if it's created by a standard Sun launcher, or by
 25.1664 - * user native application, the following property indicates the former.
 25.1665 - */
 25.1666 -void SetJavaLauncherProp() {
 25.1667 -  AddOption("-Dsun.java.launcher=" LAUNCHER_TYPE, NULL);
 25.1668 -}
 25.1669 -
 25.1670 -/*
 25.1671 - * Prints the version information from the java.version and other properties.
 25.1672 - */
 25.1673 -static void
 25.1674 -PrintJavaVersion(JNIEnv *env)
 25.1675 -{
 25.1676 -    jclass ver;
 25.1677 -    jmethodID print;
 25.1678 -
 25.1679 -    NULL_CHECK(ver = (*env)->FindClass(env, "sun/misc/Version"));
 25.1680 -    NULL_CHECK(print = (*env)->GetStaticMethodID(env, ver, "print", "()V"));
 25.1681 -
 25.1682 -    (*env)->CallStaticVoidMethod(env, ver, print);
 25.1683 -}
 25.1684 -
 25.1685 -/*
 25.1686 - * Prints default usage message.
 25.1687 - */
 25.1688 -static void
 25.1689 -PrintUsage(void)
 25.1690 -{
 25.1691 -#ifndef GAMMA
 25.1692 -    int i;
 25.1693 -#endif
 25.1694 -
 25.1695 -    fprintf(stdout,
 25.1696 -        "Usage: %s [-options] class [args...]\n"
 25.1697 -        "           (to execute a class)\n"
 25.1698 -        "   or  %s [-options] -jar jarfile [args...]\n"
 25.1699 -        "           (to execute a jar file)\n"
 25.1700 -        "\n"
 25.1701 -        "where options include:\n",
 25.1702 -        progname,
 25.1703 -        progname);
 25.1704 -
 25.1705 -#ifndef GAMMA
 25.1706 -    PrintMachineDependentOptions();
 25.1707 -
 25.1708 -    if ((knownVMs[0].flag == VM_KNOWN) ||
 25.1709 -        (knownVMs[0].flag == VM_IF_SERVER_CLASS)) {
 25.1710 -      fprintf(stdout, "    %s\t  to select the \"%s\" VM\n",
 25.1711 -              knownVMs[0].name, knownVMs[0].name+1);
 25.1712 -    }
 25.1713 -    for (i=1; i<knownVMsCount; i++) {
 25.1714 -        if (knownVMs[i].flag == VM_KNOWN)
 25.1715 -            fprintf(stdout, "    %s\t  to select the \"%s\" VM\n",
 25.1716 -                    knownVMs[i].name, knownVMs[i].name+1);
 25.1717 -    }
 25.1718 -    for (i=1; i<knownVMsCount; i++) {
 25.1719 -        if (knownVMs[i].flag == VM_ALIASED_TO)
 25.1720 -            fprintf(stdout, "    %s\t  is a synonym for "
 25.1721 -                    "the \"%s\" VM  [deprecated]\n",
 25.1722 -                    knownVMs[i].name, knownVMs[i].alias+1);
 25.1723 -    }
 25.1724 -    /* The first known VM is the default */
 25.1725 -    {
 25.1726 -      const char* defaultVM   = knownVMs[0].name+1;
 25.1727 -      const char* punctuation = ".";
 25.1728 -      const char* reason      = "";
 25.1729 -      if ((knownVMs[0].flag == VM_IF_SERVER_CLASS) &&
 25.1730 -          (ServerClassMachine() == JNI_TRUE)) {
 25.1731 -        defaultVM = knownVMs[0].server_class+1;
 25.1732 -        punctuation = ", ";
 25.1733 -        reason = "because you are running on a server-class machine.\n";
 25.1734 -      }
 25.1735 -      fprintf(stdout, "                  The default VM is %s%s\n",
 25.1736 -              defaultVM, punctuation);
 25.1737 -      fprintf(stdout, "                  %s\n",
 25.1738 -              reason);
 25.1739 -    }
 25.1740 -#endif /* ifndef GAMMA */
 25.1741 -
 25.1742 -    fprintf(stdout,
 25.1743 -"    -cp <class search path of directories and zip/jar files>\n"
 25.1744 -"    -classpath <class search path of directories and zip/jar files>\n"
 25.1745 -"                  A %c separated list of directories, JAR archives,\n"
 25.1746 -"                  and ZIP archives to search for class files.\n"
 25.1747 -"    -D<name>=<value>\n"
 25.1748 -"                  set a system property\n"
 25.1749 -"    -verbose[:class|gc|jni]\n"
 25.1750 -"                  enable verbose output\n"
 25.1751 -"    -version      print product version and exit\n"
 25.1752 -"    -version:<value>\n"
 25.1753 -"                  require the specified version to run\n"
 25.1754 -"    -showversion  print product version and continue\n"
 25.1755 -"    -jre-restrict-search | -jre-no-restrict-search\n"
 25.1756 -"                  include/exclude user private JREs in the version search\n"
 25.1757 -"    -? -help      print this help message\n"
 25.1758 -"    -X            print help on non-standard options\n"
 25.1759 -"    -ea[:<packagename>...|:<classname>]\n"
 25.1760 -"    -enableassertions[:<packagename>...|:<classname>]\n"
 25.1761 -"                  enable assertions\n"
 25.1762 -"    -da[:<packagename>...|:<classname>]\n"
 25.1763 -"    -disableassertions[:<packagename>...|:<classname>]\n"
 25.1764 -"                  disable assertions\n"
 25.1765 -"    -esa | -enablesystemassertions\n"
 25.1766 -"                  enable system assertions\n"
 25.1767 -"    -dsa | -disablesystemassertions\n"
 25.1768 -"                  disable system assertions\n"
 25.1769 -"    -agentlib:<libname>[=<options>]\n"
 25.1770 -"                  load native agent library <libname>, e.g. -agentlib:hprof\n"
 25.1771 -"                    see also, -agentlib:jdwp=help and -agentlib:hprof=help\n"
 25.1772 -"    -agentpath:<pathname>[=<options>]\n"
 25.1773 -"                  load native agent library by full pathname\n"
 25.1774 -"    -javaagent:<jarpath>[=<options>]\n"
 25.1775 -"                  load Java programming language agent, see java.lang.instrument\n"
 25.1776 -"    -splash:<imagepath>\n"
 25.1777 -"                  show splash screen with specified image\n"
 25.1778 -
 25.1779 -            ,PATH_SEPARATOR);
 25.1780 -}
 25.1781 -
 25.1782 -/*
 25.1783 - * Print usage message for -X options.
 25.1784 - */
 25.1785 -static jint
 25.1786 -PrintXUsage(const char *jvmpath)
 25.1787 -{
 25.1788 -    /*
 25.1789 -       A 32 bit cushion to prevent buffer overrun, noting that
 25.1790 -       fopen(3C) may fail if the buffer exceeds MAXPATHLEN.
 25.1791 -    */
 25.1792 -    char path[MAXPATHLEN+32];
 25.1793 -    char buf[128];
 25.1794 -    size_t n;
 25.1795 -    FILE *fp;
 25.1796 -    static const char Xusage_txt[] = "/Xusage.txt";
 25.1797 -
 25.1798 -    strcpy(path, jvmpath);
 25.1799 -    /* Note the FILE_SEPARATOR is platform dependent */
 25.1800 -    strcpy(strrchr(path, FILE_SEPARATOR), Xusage_txt);
 25.1801 -    fp = fopen(path, "r");
 25.1802 -    if (fp == 0) {
 25.1803 -        fprintf(stderr, "Can't open %s\n", path);
 25.1804 -        return 1;
 25.1805 -    }
 25.1806 -    while ((n = fread(buf, 1, sizeof(buf), fp)) != 0) {
 25.1807 -        fwrite(buf, 1, n, stdout);
 25.1808 -    }
 25.1809 -    fclose(fp);
 25.1810 -    return 0;
 25.1811 -}
 25.1812 -
 25.1813 -#ifndef GAMMA
 25.1814 -/*
 25.1815 - * Read the jvm.cfg file and fill the knownJVMs[] array.
 25.1816 - *
 25.1817 - * The functionality of the jvm.cfg file is subject to change without
 25.1818 - * notice and the mechanism will be removed in the future.
 25.1819 - *
 25.1820 - * The lexical structure of the jvm.cfg file is as follows:
 25.1821 - *
 25.1822 - *     jvmcfg         :=  { vmLine }
 25.1823 - *     vmLine         :=  knownLine
 25.1824 - *                    |   aliasLine
 25.1825 - *                    |   warnLine
 25.1826 - *                    |   ignoreLine
 25.1827 - *                    |   errorLine
 25.1828 - *                    |   predicateLine
 25.1829 - *                    |   commentLine
 25.1830 - *     knownLine      :=  flag  "KNOWN"                  EOL
 25.1831 - *     warnLine       :=  flag  "WARN"                   EOL
 25.1832 - *     ignoreLine     :=  flag  "IGNORE"                 EOL
 25.1833 - *     errorLine      :=  flag  "ERROR"                  EOL
 25.1834 - *     aliasLine      :=  flag  "ALIASED_TO"       flag  EOL
 25.1835 - *     predicateLine  :=  flag  "IF_SERVER_CLASS"  flag  EOL
 25.1836 - *     commentLine    :=  "#" text                       EOL
 25.1837 - *     flag           :=  "-" identifier
 25.1838 - *
 25.1839 - * The semantics are that when someone specifies a flag on the command line:
 25.1840 - * - if the flag appears on a knownLine, then the identifier is used as
 25.1841 - *   the name of the directory holding the JVM library (the name of the JVM).
 25.1842 - * - if the flag appears as the first flag on an aliasLine, the identifier
 25.1843 - *   of the second flag is used as the name of the JVM.
 25.1844 - * - if the flag appears on a warnLine, the identifier is used as the
 25.1845 - *   name of the JVM, but a warning is generated.
 25.1846 - * - if the flag appears on an ignoreLine, the identifier is recognized as the
 25.1847 - *   name of a JVM, but the identifier is ignored and the default vm used
 25.1848 - * - if the flag appears on an errorLine, an error is generated.
 25.1849 - * - if the flag appears as the first flag on a predicateLine, and
 25.1850 - *   the machine on which you are running passes the predicate indicated,
 25.1851 - *   then the identifier of the second flag is used as the name of the JVM,
 25.1852 - *   otherwise the identifier of the first flag is used as the name of the JVM.
 25.1853 - * If no flag is given on the command line, the first vmLine of the jvm.cfg
 25.1854 - * file determines the name of the JVM.
 25.1855 - * PredicateLines are only interpreted on first vmLine of a jvm.cfg file,
 25.1856 - * since they only make sense if someone hasn't specified the name of the
 25.1857 - * JVM on the command line.
 25.1858 - *
 25.1859 - * The intent of the jvm.cfg file is to allow several JVM libraries to
 25.1860 - * be installed in different subdirectories of a single JRE installation,
 25.1861 - * for space-savings and convenience in testing.
 25.1862 - * The intent is explicitly not to provide a full aliasing or predicate
 25.1863 - * mechanism.
 25.1864 - */
 25.1865 -jint
 25.1866 -ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative)
 25.1867 -{
 25.1868 -    FILE *jvmCfg;
 25.1869 -    char jvmCfgName[MAXPATHLEN+20];
 25.1870 -    char line[MAXPATHLEN+20];
 25.1871 -    int cnt = 0;
 25.1872 -    int lineno = 0;
 25.1873 -    jlong start, end;
 25.1874 -    int vmType;
 25.1875 -    char *tmpPtr;
 25.1876 -    char *altVMName = NULL;
 25.1877 -    char *serverClassVMName = NULL;
 25.1878 -    static char *whiteSpace = " \t";
 25.1879 -    if (_launcher_debug) {
 25.1880 -        start = CounterGet();
 25.1881 -    }
 25.1882 -
 25.1883 -    strcpy(jvmCfgName, jrepath);
 25.1884 -    strcat(jvmCfgName, FILESEP "lib" FILESEP);
 25.1885 -    strcat(jvmCfgName, arch);
 25.1886 -    strcat(jvmCfgName, FILESEP "jvm.cfg");
 25.1887 -
 25.1888 -    jvmCfg = fopen(jvmCfgName, "r");
 25.1889 -    if (jvmCfg == NULL) {
 25.1890 -      if (!speculative) {
 25.1891 -        ReportErrorMessage2("Error: could not open `%s'", jvmCfgName,
 25.1892 -                            JNI_TRUE);
 25.1893 -        exit(1);
 25.1894 -      } else {
 25.1895 -        return -1;
 25.1896 -      }
 25.1897 -    }
 25.1898 -    while (fgets(line, sizeof(line), jvmCfg) != NULL) {
 25.1899 -        vmType = VM_UNKNOWN;
 25.1900 -        lineno++;
 25.1901 -        if (line[0] == '#')
 25.1902 -            continue;
 25.1903 -        if (line[0] != '-') {
 25.1904 -            fprintf(stderr, "Warning: no leading - on line %d of `%s'\n",
 25.1905 -                    lineno, jvmCfgName);
 25.1906 -        }
 25.1907 -        if (cnt >= knownVMsLimit) {
 25.1908 -            GrowKnownVMs(cnt);
 25.1909 -        }
 25.1910 -        line[strlen(line)-1] = '\0'; /* remove trailing newline */
 25.1911 -        tmpPtr = line + strcspn(line, whiteSpace);
 25.1912 -        if (*tmpPtr == 0) {
 25.1913 -            fprintf(stderr, "Warning: missing VM type on line %d of `%s'\n",
 25.1914 -                    lineno, jvmCfgName);
 25.1915 -        } else {
 25.1916 -            /* Null-terminate this string for JLI_StringDup below */
 25.1917 -            *tmpPtr++ = 0;
 25.1918 -            tmpPtr += strspn(tmpPtr, whiteSpace);
 25.1919 -            if (*tmpPtr == 0) {
 25.1920 -                fprintf(stderr, "Warning: missing VM type on line %d of `%s'\n",
 25.1921 -                        lineno, jvmCfgName);
 25.1922 -            } else {
 25.1923 -                if (!strncmp(tmpPtr, "KNOWN", strlen("KNOWN"))) {
 25.1924 -                    vmType = VM_KNOWN;
 25.1925 -                } else if (!strncmp(tmpPtr, "ALIASED_TO", strlen("ALIASED_TO"))) {
 25.1926 -                    tmpPtr += strcspn(tmpPtr, whiteSpace);
 25.1927 -                    if (*tmpPtr != 0) {
 25.1928 -                        tmpPtr += strspn(tmpPtr, whiteSpace);
 25.1929 -                    }
 25.1930 -                    if (*tmpPtr == 0) {
 25.1931 -                        fprintf(stderr, "Warning: missing VM alias on line %d of `%s'\n",
 25.1932 -                                lineno, jvmCfgName);
 25.1933 -                    } else {
 25.1934 -                        /* Null terminate altVMName */
 25.1935 -                        altVMName = tmpPtr;
 25.1936 -                        tmpPtr += strcspn(tmpPtr, whiteSpace);
 25.1937 -                        *tmpPtr = 0;
 25.1938 -                        vmType = VM_ALIASED_TO;
 25.1939 -                    }
 25.1940 -                } else if (!strncmp(tmpPtr, "WARN", strlen("WARN"))) {
 25.1941 -                    vmType = VM_WARN;
 25.1942 -                } else if (!strncmp(tmpPtr, "IGNORE", strlen("IGNORE"))) {
 25.1943 -                    vmType = VM_IGNORE;
 25.1944 -                } else if (!strncmp(tmpPtr, "ERROR", strlen("ERROR"))) {
 25.1945 -                    vmType = VM_ERROR;
 25.1946 -                } else if (!strncmp(tmpPtr,
 25.1947 -                                    "IF_SERVER_CLASS",
 25.1948 -                                    strlen("IF_SERVER_CLASS"))) {
 25.1949 -                    tmpPtr += strcspn(tmpPtr, whiteSpace);
 25.1950 -                    if (*tmpPtr != 0) {
 25.1951 -                        tmpPtr += strspn(tmpPtr, whiteSpace);
 25.1952 -                    }
 25.1953 -                    if (*tmpPtr == 0) {
 25.1954 -                        fprintf(stderr, "Warning: missing server class VM on line %d of `%s'\n",
 25.1955 -                                lineno, jvmCfgName);
 25.1956 -                    } else {
 25.1957 -                        /* Null terminate server class VM name */
 25.1958 -                        serverClassVMName = tmpPtr;
 25.1959 -                        tmpPtr += strcspn(tmpPtr, whiteSpace);
 25.1960 -                        *tmpPtr = 0;
 25.1961 -                        vmType = VM_IF_SERVER_CLASS;
 25.1962 -                    }
 25.1963 -                } else {
 25.1964 -                    fprintf(stderr, "Warning: unknown VM type on line %d of `%s'\n",
 25.1965 -                            lineno, &jvmCfgName[0]);
 25.1966 -                    vmType = VM_KNOWN;
 25.1967 -                }
 25.1968 -            }
 25.1969 -        }
 25.1970 -
 25.1971 -        if (_launcher_debug)
 25.1972 -            printf("jvm.cfg[%d] = ->%s<-\n", cnt, line);
 25.1973 -        if (vmType != VM_UNKNOWN) {
 25.1974 -            knownVMs[cnt].name = JLI_StringDup(line);
 25.1975 -            knownVMs[cnt].flag = vmType;
 25.1976 -            switch (vmType) {
 25.1977 -            default:
 25.1978 -                break;
 25.1979 -            case VM_ALIASED_TO:
 25.1980 -                knownVMs[cnt].alias = JLI_StringDup(altVMName);
 25.1981 -                if (_launcher_debug) {
 25.1982 -                    printf("    name: %s  vmType: %s  alias: %s\n",
 25.1983 -                           knownVMs[cnt].name, "VM_ALIASED_TO", knownVMs[cnt].alias);
 25.1984 -                }
 25.1985 -                break;
 25.1986 -            case VM_IF_SERVER_CLASS:
 25.1987 -                knownVMs[cnt].server_class = JLI_StringDup(serverClassVMName);
 25.1988 -                if (_launcher_debug) {
 25.1989 -                    printf("    name: %s  vmType: %s  server_class: %s\n",
 25.1990 -                           knownVMs[cnt].name, "VM_IF_SERVER_CLASS", knownVMs[cnt].server_class);
 25.1991 -                }
 25.1992 -                break;
 25.1993 -            }
 25.1994 -            cnt++;
 25.1995 -        }
 25.1996 -    }
 25.1997 -    fclose(jvmCfg);
 25.1998 -    knownVMsCount = cnt;
 25.1999 -
 25.2000 -    if (_launcher_debug) {
 25.2001 -        end   = CounterGet();
 25.2002 -        printf("%ld micro seconds to parse jvm.cfg\n",
 25.2003 -               (long)(jint)Counter2Micros(end-start));
 25.2004 -    }
 25.2005 -
 25.2006 -    return cnt;
 25.2007 -}
 25.2008 -
 25.2009 -
 25.2010 -static void
 25.2011 -GrowKnownVMs(int minimum)
 25.2012 -{
 25.2013 -    struct vmdesc* newKnownVMs;
 25.2014 -    int newMax;
 25.2015 -
 25.2016 -    newMax = (knownVMsLimit == 0 ? INIT_MAX_KNOWN_VMS : (2 * knownVMsLimit));
 25.2017 -    if (newMax <= minimum) {
 25.2018 -        newMax = minimum;
 25.2019 -    }
 25.2020 -    newKnownVMs = (struct vmdesc*) JLI_MemAlloc(newMax * sizeof(struct vmdesc));
 25.2021 -    if (knownVMs != NULL) {
 25.2022 -        memcpy(newKnownVMs, knownVMs, knownVMsLimit * sizeof(struct vmdesc));
 25.2023 -    }
 25.2024 -    JLI_MemFree(knownVMs);
 25.2025 -    knownVMs = newKnownVMs;
 25.2026 -    knownVMsLimit = newMax;
 25.2027 -}
 25.2028 -
 25.2029 -
 25.2030 -/* Returns index of VM or -1 if not found */
 25.2031 -static int
 25.2032 -KnownVMIndex(const char* name)
 25.2033 -{
 25.2034 -    int i;
 25.2035 -    if (strncmp(name, "-J", 2) == 0) name += 2;
 25.2036 -    for (i = 0; i < knownVMsCount; i++) {
 25.2037 -        if (!strcmp(name, knownVMs[i].name)) {
 25.2038 -            return i;
 25.2039 -        }
 25.2040 -    }
 25.2041 -    return -1;
 25.2042 -}
 25.2043 -
 25.2044 -static void
 25.2045 -FreeKnownVMs()
 25.2046 -{
 25.2047 -    int i;
 25.2048 -    for (i = 0; i < knownVMsCount; i++) {
 25.2049 -        JLI_MemFree(knownVMs[i].name);
 25.2050 -        knownVMs[i].name = NULL;
 25.2051 -    }
 25.2052 -    JLI_MemFree(knownVMs);
 25.2053 -}
 25.2054 -
 25.2055 -
 25.2056 -/*
 25.2057 - * Displays the splash screen according to the jar file name
 25.2058 - * and image file names stored in environment variables
 25.2059 - */
 25.2060 -static void
 25.2061 -ShowSplashScreen()
 25.2062 -{
 25.2063 -    const char *jar_name = getenv(SPLASH_JAR_ENV_ENTRY);
 25.2064 -    const char *file_name = getenv(SPLASH_FILE_ENV_ENTRY);
 25.2065 -    int data_size;
 25.2066 -    void *image_data;
 25.2067 -    if (jar_name) {
 25.2068 -        image_data = JLI_JarUnpackFile(jar_name, file_name, &data_size);
 25.2069 -        if (image_data) {
 25.2070 -            DoSplashInit();
 25.2071 -            DoSplashLoadMemory(image_data, data_size);
 25.2072 -            JLI_MemFree(image_data);
 25.2073 -        }
 25.2074 -    } else if (file_name) {
 25.2075 -        DoSplashInit();
 25.2076 -        DoSplashLoadFile(file_name);
 25.2077 -    } else {
 25.2078 -        return;
 25.2079 -    }
 25.2080 -    DoSplashSetFileJarName(file_name, jar_name);
 25.2081 -}
 25.2082 -
 25.2083 -#endif /* ifndef GAMMA */
    26.1 --- a/src/share/tools/launcher/java.h	Mon May 06 13:53:13 2013 -0700
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,110 +0,0 @@
    26.4 -/*
    26.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
    26.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 - *
    26.8 - * This code is free software; you can redistribute it and/or modify it
    26.9 - * under the terms of the GNU General Public License version 2 only, as
   26.10 - * published by the Free Software Foundation.
   26.11 - *
   26.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 - * version 2 for more details (a copy is included in the LICENSE file that
   26.16 - * accompanied this code).
   26.17 - *
   26.18 - * You should have received a copy of the GNU General Public License version
   26.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 - *
   26.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 - * or visit www.oracle.com if you need additional information or have any
   26.24 - * questions.
   26.25 - *
   26.26 - */
   26.27 -
   26.28 -
   26.29 -#ifndef _JAVA_H_
   26.30 -#define _JAVA_H_
   26.31 -
   26.32 -/*
   26.33 - * Get system specific defines.
   26.34 - */
   26.35 -#include "jni.h"
   26.36 -#include "java_md.h"
   26.37 -#include "jli_util.h"
   26.38 -
   26.39 -/*
   26.40 - * Pointers to the needed JNI invocation API, initialized by LoadJavaVM.
   26.41 - */
   26.42 -typedef jint (JNICALL *CreateJavaVM_t)(JavaVM **pvm, void **env, void *args);
   26.43 -typedef jint (JNICALL *GetDefaultJavaVMInitArgs_t)(void *args);
   26.44 -
   26.45 -typedef struct {
   26.46 -    CreateJavaVM_t CreateJavaVM;
   26.47 -    GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs;
   26.48 -} InvocationFunctions;
   26.49 -
   26.50 -/*
   26.51 - * Prototypes for launcher functions in the system specific java_md.c.
   26.52 - */
   26.53 -
   26.54 -jboolean
   26.55 -LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn);
   26.56 -
   26.57 -void
   26.58 -GetXUsagePath(char *buf, jint bufsize);
   26.59 -
   26.60 -jboolean
   26.61 -GetApplicationHome(char *buf, jint bufsize);
   26.62 -
   26.63 -const char *
   26.64 -GetArch();
   26.65 -
   26.66 -void CreateExecutionEnvironment(int *_argc,
   26.67 -                                       char ***_argv,
   26.68 -                                       char jrepath[],
   26.69 -                                       jint so_jrepath,
   26.70 -                                       char jvmpath[],
   26.71 -                                       jint so_jvmpath,
   26.72 -                                       char **original_argv);
   26.73 -
   26.74 -/*
   26.75 - * Report an error message to stderr or a window as appropriate.  The
   26.76 - * flag always is set to JNI_TRUE if message is to be reported to both
   26.77 - * strerr and windows and set to JNI_FALSE if the message should only
   26.78 - * be sent to a window.
   26.79 - */
   26.80 -void ReportErrorMessage(char * message, jboolean always);
   26.81 -void ReportErrorMessage2(char * format, char * string, jboolean always);
   26.82 -
   26.83 -/*
   26.84 - * Report an exception which terminates the vm to stderr or a window
   26.85 - * as appropriate.
   26.86 - */
   26.87 -void ReportExceptionDescription(JNIEnv * env);
   26.88 -
   26.89 -jboolean RemovableMachineDependentOption(char * option);
   26.90 -void PrintMachineDependentOptions();
   26.91 -
   26.92 -/*
   26.93 - * Block current thread and continue execution in new thread
   26.94 - */
   26.95 -int ContinueInNewThread(int (JNICALL *continuation)(void *),
   26.96 -                        jlong stack_size, void * args);
   26.97 -
   26.98 -/* sun.java.launcher.* platform properties. */
   26.99 -void SetJavaLauncherPlatformProps(void);
  26.100 -
  26.101 -/*
  26.102 - * Functions defined in java.c and used in java_md.c.
  26.103 - */
  26.104 -jint ReadKnownVMs(const char *jrepath, char * arch, jboolean speculative);
  26.105 -char *CheckJvmType(int *argc, char ***argv, jboolean speculative);
  26.106 -void AddOption(char *str, void *info);
  26.107 -
  26.108 -/*
  26.109 - * Make launcher spit debug output.
  26.110 - */
  26.111 -extern jboolean _launcher_debug;
  26.112 -
  26.113 -#endif /* _JAVA_H_ */
    27.1 --- a/src/share/tools/launcher/jli_util.c	Mon May 06 13:53:13 2013 -0700
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,89 +0,0 @@
    27.4 -
    27.5 -/*
    27.6 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    27.7 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.8 - *
    27.9 - * This code is free software; you can redistribute it and/or modify it
   27.10 - * under the terms of the GNU General Public License version 2 only, as
   27.11 - * published by the Free Software Foundation.
   27.12 - *
   27.13 - * This code is distributed in the hope that it will be useful, but WITHOUT
   27.14 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   27.15 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   27.16 - * version 2 for more details (a copy is included in the LICENSE file that
   27.17 - * accompanied this code).
   27.18 - *
   27.19 - * You should have received a copy of the GNU General Public License version
   27.20 - * 2 along with this work; if not, write to the Free Software Foundation,
   27.21 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   27.22 - *
   27.23 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   27.24 - * or visit www.oracle.com if you need additional information or have any
   27.25 - * questions.
   27.26 - *
   27.27 - */
   27.28 -
   27.29 -#include <stdio.h>
   27.30 -#include <string.h>
   27.31 -#include "jli_util.h"
   27.32 -
   27.33 -#ifdef GAMMA
   27.34 -#ifdef TARGET_OS_FAMILY_windows
   27.35 -#define strdup _strdup
   27.36 -#endif
   27.37 -#endif
   27.38 -
   27.39 -/*
   27.40 - * Returns a pointer to a block of at least 'size' bytes of memory.
   27.41 - * Prints error message and exits if the memory could not be allocated.
   27.42 - */
   27.43 -void *
   27.44 -JLI_MemAlloc(size_t size)
   27.45 -{
   27.46 -    void *p = malloc(size);
   27.47 -    if (p == 0) {
   27.48 -        perror("malloc");
   27.49 -        exit(1);
   27.50 -    }
   27.51 -    return p;
   27.52 -}
   27.53 -
   27.54 -/*
   27.55 - * Equivalent to realloc(size).
   27.56 - * Prints error message and exits if the memory could not be reallocated.
   27.57 - */
   27.58 -void *
   27.59 -JLI_MemRealloc(void *ptr, size_t size)
   27.60 -{
   27.61 -    void *p = realloc(ptr, size);
   27.62 -    if (p == 0) {
   27.63 -        perror("realloc");
   27.64 -        exit(1);
   27.65 -    }
   27.66 -    return p;
   27.67 -}
   27.68 -
   27.69 -/*
   27.70 - * Wrapper over strdup(3C) which prints an error message and exits if memory
   27.71 - * could not be allocated.
   27.72 - */
   27.73 -char *
   27.74 -JLI_StringDup(const char *s1)
   27.75 -{
   27.76 -    char *s = strdup(s1);
   27.77 -    if (s == NULL) {
   27.78 -        perror("strdup");
   27.79 -        exit(1);
   27.80 -    }
   27.81 -    return s;
   27.82 -}
   27.83 -
   27.84 -/*
   27.85 - * Very equivalent to free(ptr).
   27.86 - * Here to maintain pairing with the above routines.
   27.87 - */
   27.88 -void
   27.89 -JLI_MemFree(void *ptr)
   27.90 -{
   27.91 -    free(ptr);
   27.92 -}
    28.1 --- a/src/share/tools/launcher/jli_util.h	Mon May 06 13:53:13 2013 -0700
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,35 +0,0 @@
    28.4 -/*
    28.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    28.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.7 - *
    28.8 - * This code is free software; you can redistribute it and/or modify it
    28.9 - * under the terms of the GNU General Public License version 2 only, as
   28.10 - * published by the Free Software Foundation.
   28.11 - *
   28.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   28.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.15 - * version 2 for more details (a copy is included in the LICENSE file that
   28.16 - * accompanied this code).
   28.17 - *
   28.18 - * You should have received a copy of the GNU General Public License version
   28.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   28.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.21 - *
   28.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.23 - * or visit www.oracle.com if you need additional information or have any
   28.24 - * questions.
   28.25 - *
   28.26 - */
   28.27 -
   28.28 -#ifndef _JLI_UTIL_H
   28.29 -#define _JLI_UTIL_H
   28.30 -
   28.31 -#include <stdlib.h>
   28.32 -
   28.33 -void *JLI_MemAlloc(size_t size);
   28.34 -void *JLI_MemRealloc(void *ptr, size_t size);
   28.35 -char *JLI_StringDup(const char *s1);
   28.36 -void  JLI_MemFree(void *ptr);
   28.37 -
   28.38 -#endif  /* _JLI_UTIL_H */
    29.1 --- a/src/share/tools/launcher/wildcard.c	Mon May 06 13:53:13 2013 -0700
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,496 +0,0 @@
    29.4 -/*
    29.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    29.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 - *
    29.8 - * This code is free software; you can redistribute it and/or modify it
    29.9 - * under the terms of the GNU General Public License version 2 only, as
   29.10 - * published by the Free Software Foundation.
   29.11 - *
   29.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 - * version 2 for more details (a copy is included in the LICENSE file that
   29.16 - * accompanied this code).
   29.17 - *
   29.18 - * You should have received a copy of the GNU General Public License version
   29.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 - *
   29.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.23 - * or visit www.oracle.com if you need additional information or have any
   29.24 - * questions.
   29.25 - *
   29.26 - */
   29.27 -
   29.28 -/*
   29.29 - * Class-Path Wildcards
   29.30 - *
   29.31 - * The syntax for wildcards is a single asterisk. The class path
   29.32 - * foo/"*", e.g., loads all jar files in the directory named foo.
   29.33 - * (This requires careful quotation when used in shell scripts.)
   29.34 - *
   29.35 - * Only files whose names end in .jar or .JAR are matched.
   29.36 - * Files whose names end in .zip, or which have a particular
   29.37 - * magic number, regardless of filename extension, are not
   29.38 - * matched.
   29.39 - *
   29.40 - * Files are considered regardless of whether or not they are
   29.41 - * "hidden" in the UNIX sense, i.e., have names beginning with '.'.
   29.42 - *
   29.43 - * A wildcard only matches jar files, not class files in the same
   29.44 - * directory.  If you want to load both class files and jar files from
   29.45 - * a single directory foo then you can say foo:foo/"*", or foo/"*":foo
   29.46 - * if you want the jar files to take precedence.
   29.47 - *
   29.48 - * Subdirectories are not searched recursively, i.e., foo/"*" only
   29.49 - * looks for jar files in foo, not in foo/bar, foo/baz, etc.
   29.50 - *
   29.51 - * Expansion of wildcards is done early, prior to the invocation of a
   29.52 - * program's main method, rather than late, during the class-loading
   29.53 - * process itself.  Each element of the input class path containing a
   29.54 - * wildcard is replaced by the (possibly empty) sequence of elements
   29.55 - * generated by enumerating the jar files in the named directory.  If
   29.56 - * the directory foo contains a.jar, b.jar, and c.jar,
   29.57 - * e.g., then the class path foo/"*" is expanded into
   29.58 - * foo/a.jar:foo/b.jar:foo/c.jar, and that string would be the value
   29.59 - * of the system property java.class.path.
   29.60 - *
   29.61 - * The order in which the jar files in a directory are enumerated in
   29.62 - * the expanded class path is not specified and may vary from platform
   29.63 - * to platform and even from moment to moment on the same machine.  A
   29.64 - * well-constructed application should not depend upon any particular
   29.65 - * order.  If a specific order is required then the jar files can be
   29.66 - * enumerated explicitly in the class path.
   29.67 - *
   29.68 - * The CLASSPATH environment variable is not treated any differently
   29.69 - * from the -classpath (equiv. -cp) command-line option,
   29.70 - * i.e. wildcards are honored in all these cases.
   29.71 - *
   29.72 - * Class-path wildcards are not honored in the Class-Path jar-manifest
   29.73 - * header.
   29.74 - *
   29.75 - * Class-path wildcards are honored not only by the Java launcher but
   29.76 - * also by most other command-line tools that accept class paths, and
   29.77 - * in particular by javac and javadoc.
   29.78 - *
   29.79 - * Class-path wildcards are not honored in any other kind of path, and
   29.80 - * especially not in the bootstrap class path, which is a mere
   29.81 - * artifact of our implementation and not something that developers
   29.82 - * should use.
   29.83 - *
   29.84 - * Classpath wildcards are only expanded in the Java launcher code,
   29.85 - * supporting the use of wildcards on the command line and in the
   29.86 - * CLASSPATH environment variable.  We do not support the use of
   29.87 - * wildcards by applications that embed the JVM.
   29.88 - */
   29.89 -
   29.90 -#include <stddef.h>
   29.91 -#include <stdio.h>
   29.92 -#include <stdlib.h>
   29.93 -#include <string.h>
   29.94 -#include <sys/types.h>
   29.95 -#include "java.h"       /* Strictly for PATH_SEPARATOR/FILE_SEPARATOR */
   29.96 -#include "jli_util.h"
   29.97 -
   29.98 -#ifdef _WIN32
   29.99 -#include <windows.h>
  29.100 -#else /* Unix */
  29.101 -#include <unistd.h>
  29.102 -#include <dirent.h>
  29.103 -#endif /* Unix */
  29.104 -
  29.105 -static int
  29.106 -exists(const char* filename)
  29.107 -{
  29.108 -#ifdef _WIN32
  29.109 -    return _access(filename, 0) == 0;
  29.110 -#else
  29.111 -    return access(filename, F_OK) == 0;
  29.112 -#endif
  29.113 -}
  29.114 -
  29.115 -#define NEW_(TYPE) ((TYPE) JLI_MemAlloc(sizeof(struct TYPE##_)))
  29.116 -
  29.117 -/*
  29.118 - * Wildcard directory iteration.
  29.119 - * WildcardIterator_for(wildcard) returns an iterator.
  29.120 - * Each call to that iterator's next() method returns the basename
  29.121 - * of an entry in the wildcard's directory.  The basename's memory
  29.122 - * belongs to the iterator.  The caller is responsible for prepending
  29.123 - * the directory name and file separator, if necessary.
  29.124 - * When done with the iterator, call the close method to clean up.
  29.125 - */
  29.126 -typedef struct WildcardIterator_* WildcardIterator;
  29.127 -
  29.128 -#ifdef _WIN32
  29.129 -struct WildcardIterator_
  29.130 -{
  29.131 -    HANDLE handle;
  29.132 -    char *firstFile; /* Stupid FindFirstFile...FindNextFile */
  29.133 -};
  29.134 -
  29.135 -static WildcardIterator
  29.136 -WildcardIterator_for(const char *wildcard)
  29.137 -{
  29.138 -    WIN32_FIND_DATA find_data;
  29.139 -    WildcardIterator it = NEW_(WildcardIterator);
  29.140 -    HANDLE handle = FindFirstFile(wildcard, &find_data);
  29.141 -    if (handle == INVALID_HANDLE_VALUE)
  29.142 -        return NULL;
  29.143 -    it->handle = handle;
  29.144 -    it->firstFile = find_data.cFileName;
  29.145 -    return it;
  29.146 -}
  29.147 -
  29.148 -static char *
  29.149 -WildcardIterator_next(WildcardIterator it)
  29.150 -{
  29.151 -    WIN32_FIND_DATA find_data;
  29.152 -    if (it->firstFile != NULL) {
  29.153 -        char *firstFile = it->firstFile;
  29.154 -        it->firstFile = NULL;
  29.155 -        return firstFile;
  29.156 -    }
  29.157 -    return FindNextFile(it->handle, &find_data)
  29.158 -        ? find_data.cFileName : NULL;
  29.159 -}
  29.160 -
  29.161 -static void
  29.162 -WildcardIterator_close(WildcardIterator it)
  29.163 -{
  29.164 -    if (it) {
  29.165 -        FindClose(it->handle);
  29.166 -        JLI_MemFree(it->firstFile);
  29.167 -        JLI_MemFree(it);
  29.168 -    }
  29.169 -}
  29.170 -
  29.171 -#else /* Unix */
  29.172 -struct WildcardIterator_
  29.173 -{
  29.174 -    DIR *dir;
  29.175 -};
  29.176 -
  29.177 -static WildcardIterator
  29.178 -WildcardIterator_for(const char *wildcard)
  29.179 -{
  29.180 -    DIR *dir;
  29.181 -    int wildlen = strlen(wildcard);
  29.182 -    if (wildlen < 2) {
  29.183 -        dir = opendir(".");
  29.184 -    } else {
  29.185 -        char *dirname = JLI_StringDup(wildcard);
  29.186 -        dirname[wildlen - 1] = '\0';
  29.187 -        dir = opendir(dirname);
  29.188 -        JLI_MemFree(dirname);
  29.189 -    }
  29.190 -    if (dir == NULL)
  29.191 -        return NULL;
  29.192 -    else {
  29.193 -        WildcardIterator it = NEW_(WildcardIterator);
  29.194 -        it->dir = dir;
  29.195 -        return it;
  29.196 -    }
  29.197 -}
  29.198 -
  29.199 -static char *
  29.200 -WildcardIterator_next(WildcardIterator it)
  29.201 -{
  29.202 -    struct dirent* dirp = readdir(it->dir);
  29.203 -    return dirp ? dirp->d_name : NULL;
  29.204 -}
  29.205 -
  29.206 -static void
  29.207 -WildcardIterator_close(WildcardIterator it)
  29.208 -{
  29.209 -    if (it) {
  29.210 -        closedir(it->dir);
  29.211 -        JLI_MemFree(it);
  29.212 -    }
  29.213 -}
  29.214 -#endif /* Unix */
  29.215 -
  29.216 -static int
  29.217 -equal(const char *s1, const char *s2)
  29.218 -{
  29.219 -    return strcmp(s1, s2) == 0;
  29.220 -}
  29.221 -
  29.222 -/*
  29.223 - * FileList ADT - a dynamic list of C filenames
  29.224 - */
  29.225 -struct FileList_
  29.226 -{
  29.227 -    char **files;
  29.228 -    int size;
  29.229 -    int capacity;
  29.230 -};
  29.231 -typedef struct FileList_ *FileList;
  29.232 -
  29.233 -static FileList
  29.234 -FileList_new(int capacity)
  29.235 -{
  29.236 -    FileList fl = NEW_(FileList);
  29.237 -    fl->capacity = capacity;
  29.238 -    fl->files = (char **) JLI_MemAlloc(capacity * sizeof(fl->files[0]));
  29.239 -    fl->size = 0;
  29.240 -    return fl;
  29.241 -}
  29.242 -
  29.243 -#ifdef DEBUG_WILDCARD
  29.244 -static void
  29.245 -FileList_print(FileList fl)
  29.246 -{
  29.247 -    int i;
  29.248 -    putchar('[');
  29.249 -    for (i = 0; i < fl->size; i++) {
  29.250 -        if (i > 0) printf(", ");
  29.251 -        printf("\"%s\"",fl->files[i]);
  29.252 -    }
  29.253 -    putchar(']');
  29.254 -}
  29.255 -#endif
  29.256 -
  29.257 -static void
  29.258 -FileList_free(FileList fl)
  29.259 -{
  29.260 -    if (fl) {
  29.261 -        if (fl->files) {
  29.262 -            int i;
  29.263 -            for (i = 0; i < fl->size; i++)
  29.264 -                JLI_MemFree(fl->files[i]);
  29.265 -            JLI_MemFree(fl->files);
  29.266 -        }
  29.267 -        JLI_MemFree(fl);
  29.268 -    }
  29.269 -}
  29.270 -
  29.271 -static void
  29.272 -FileList_ensureCapacity(FileList fl, int capacity)
  29.273 -{
  29.274 -    if (fl->capacity < capacity) {
  29.275 -        while (fl->capacity < capacity)
  29.276 -            fl->capacity *= 2;
  29.277 -        fl->files = JLI_MemRealloc(fl->files,
  29.278 -                               fl->capacity * sizeof(fl->files[0]));
  29.279 -    }
  29.280 -}
  29.281 -
  29.282 -static void
  29.283 -FileList_add(FileList fl, char *file)
  29.284 -{
  29.285 -    FileList_ensureCapacity(fl, fl->size+1);
  29.286 -    fl->files[fl->size++] = file;
  29.287 -}
  29.288 -
  29.289 -static void
  29.290 -FileList_addSubstring(FileList fl, const char *beg, int len)
  29.291 -{
  29.292 -    char *filename = (char *) JLI_MemAlloc(len+1);
  29.293 -    memcpy(filename, beg, len);
  29.294 -    filename[len] = '\0';
  29.295 -    FileList_ensureCapacity(fl, fl->size+1);
  29.296 -    fl->files[fl->size++] = filename;
  29.297 -}
  29.298 -
  29.299 -static char *
  29.300 -FileList_join(FileList fl, char sep)
  29.301 -{
  29.302 -    int i;
  29.303 -    int size;
  29.304 -    char *path;
  29.305 -    char *p;
  29.306 -    for (i = 0, size = 1; i < fl->size; i++)
  29.307 -        size += strlen(fl->files[i]) + 1;
  29.308 -
  29.309 -    path = JLI_MemAlloc(size);
  29.310 -
  29.311 -    for (i = 0, p = path; i < fl->size; i++) {
  29.312 -        int len = strlen(fl->files[i]);
  29.313 -        if (i > 0) *p++ = sep;
  29.314 -        memcpy(p, fl->files[i], len);
  29.315 -        p += len;
  29.316 -    }
  29.317 -    *p = '\0';
  29.318 -
  29.319 -    return path;
  29.320 -}
  29.321 -
  29.322 -static FileList
  29.323 -FileList_split(const char *path, char sep)
  29.324 -{
  29.325 -    const char *p, *q;
  29.326 -    int len = strlen(path);
  29.327 -    int count;
  29.328 -    FileList fl;
  29.329 -    for (count = 1, p = path; p < path + len; p++)
  29.330 -        count += (*p == sep);
  29.331 -    fl = FileList_new(count);
  29.332 -    for (p = path;;) {
  29.333 -        for (q = p; q <= path + len; q++) {
  29.334 -            if (*q == sep || *q == '\0') {
  29.335 -                FileList_addSubstring(fl, p, q - p);
  29.336 -                if (*q == '\0')
  29.337 -                    return fl;
  29.338 -                p = q + 1;
  29.339 -            }
  29.340 -        }
  29.341 -    }
  29.342 -}
  29.343 -
  29.344 -static int
  29.345 -isJarFileName(const char *filename)
  29.346 -{
  29.347 -    int len = strlen(filename);
  29.348 -    return (len >= 4) &&
  29.349 -        (filename[len - 4] == '.') &&
  29.350 -        (equal(filename + len - 3, "jar") ||
  29.351 -         equal(filename + len - 3, "JAR")) &&
  29.352 -        /* Paranoia: Maybe filename is "DIR:foo.jar" */
  29.353 -        (strchr(filename, PATH_SEPARATOR) == NULL);
  29.354 -}
  29.355 -
  29.356 -static char *
  29.357 -wildcardConcat(const char *wildcard, const char *basename)
  29.358 -{
  29.359 -    int wildlen = strlen(wildcard);
  29.360 -    int baselen = strlen(basename);
  29.361 -    char *filename = (char *) JLI_MemAlloc(wildlen + baselen);
  29.362 -    /* Replace the trailing '*' with basename */
  29.363 -    memcpy(filename, wildcard, wildlen-1);
  29.364 -    memcpy(filename+wildlen-1, basename, baselen+1);
  29.365 -    return filename;
  29.366 -}
  29.367 -
  29.368 -static FileList
  29.369 -wildcardFileList(const char *wildcard)
  29.370 -{
  29.371 -    const char *basename;
  29.372 -    FileList fl = FileList_new(16);
  29.373 -    WildcardIterator it = WildcardIterator_for(wildcard);
  29.374 -    if (it == NULL) {
  29.375 -        FileList_free(fl);
  29.376 -        return NULL;
  29.377 -    }
  29.378 -    while ((basename = WildcardIterator_next(it)) != NULL)
  29.379 -        if (isJarFileName(basename))
  29.380 -            FileList_add(fl, wildcardConcat(wildcard, basename));
  29.381 -    WildcardIterator_close(it);
  29.382 -    return fl;
  29.383 -}
  29.384 -
  29.385 -static int
  29.386 -isWildcard(const char *filename)
  29.387 -{
  29.388 -    int len = strlen(filename);
  29.389 -    return (len > 0) &&
  29.390 -        (filename[len - 1] == '*') &&
  29.391 -        (len == 1 || IS_FILE_SEPARATOR(filename[len - 2])) &&
  29.392 -        (! exists(filename));
  29.393 -}
  29.394 -
  29.395 -static void
  29.396 -FileList_expandWildcards(FileList fl)
  29.397 -{
  29.398 -    int i, j;
  29.399 -    for (i = 0; i < fl->size; i++) {
  29.400 -        if (isWildcard(fl->files[i])) {
  29.401 -            FileList expanded = wildcardFileList(fl->files[i]);
  29.402 -            if (expanded != NULL && expanded->size > 0) {
  29.403 -                JLI_MemFree(fl->files[i]);
  29.404 -                FileList_ensureCapacity(fl, fl->size + expanded->size);
  29.405 -                for (j = fl->size - 1; j >= i+1; j--)
  29.406 -                    fl->files[j+expanded->size-1] = fl->files[j];
  29.407 -                for (j = 0; j < expanded->size; j++)
  29.408 -                    fl->files[i+j] = expanded->files[j];
  29.409 -                i += expanded->size - 1;
  29.410 -                fl->size += expanded->size - 1;
  29.411 -                /* fl expropriates expanded's elements. */
  29.412 -                expanded->size = 0;
  29.413 -            }
  29.414 -            FileList_free(expanded);
  29.415 -        }
  29.416 -    }
  29.417 -}
  29.418 -
  29.419 -const char *
  29.420 -JLI_WildcardExpandClasspath(const char *classpath)
  29.421 -{
  29.422 -    char *expanded;
  29.423 -    FileList fl;
  29.424 -
  29.425 -    if (strchr(classpath, '*') == NULL)
  29.426 -        return classpath;
  29.427 -    fl = FileList_split(classpath, PATH_SEPARATOR);
  29.428 -    FileList_expandWildcards(fl);
  29.429 -    expanded = FileList_join(fl, PATH_SEPARATOR);
  29.430 -    FileList_free(fl);
  29.431 -    if (getenv("_JAVA_LAUNCHER_DEBUG") != 0)
  29.432 -        printf("Expanded wildcards:\n"
  29.433 -               "    before: \"%s\"\n"
  29.434 -               "    after : \"%s\"\n",
  29.435 -               classpath, expanded);
  29.436 -    return expanded;
  29.437 -}
  29.438 -
  29.439 -#ifdef DEBUG_WILDCARD
  29.440 -static void
  29.441 -wildcardExpandArgv(const char ***argv)
  29.442 -{
  29.443 -    int i;
  29.444 -    for (i = 0; (*argv)[i]; i++) {
  29.445 -        if (equal((*argv)[i], "-cp") ||
  29.446 -            equal((*argv)[i], "-classpath")) {
  29.447 -            i++;
  29.448 -            (*argv)[i] = wildcardExpandClasspath((*argv)[i]);
  29.449 -        }
  29.450 -    }
  29.451 -}
  29.452 -
  29.453 -static void
  29.454 -debugPrintArgv(char *argv[])
  29.455 -{
  29.456 -    int i;
  29.457 -    putchar('[');
  29.458 -    for (i = 0; argv[i]; i++) {
  29.459 -        if (i > 0) printf(", ");
  29.460 -        printf("\"%s\"", argv[i]);
  29.461 -    }
  29.462 -    printf("]\n");
  29.463 -}
  29.464 -
  29.465 -int
  29.466 -main(int argc, char *argv[])
  29.467 -{
  29.468 -    argv[0] = "java";
  29.469 -    wildcardExpandArgv((const char***)&argv);
  29.470 -    debugPrintArgv(argv);
  29.471 -    /* execvp("java", argv); */
  29.472 -    return 0;
  29.473 -}
  29.474 -#endif /* DEBUG_WILDCARD */
  29.475 -
  29.476 -/* Cute little perl prototype implementation....
  29.477 -
  29.478 -my $sep = ($^O =~ /^(Windows|cygwin)/) ? ";" : ":";
  29.479 -
  29.480 -sub expand($) {
  29.481 -  opendir DIR, $_[0] or return $_[0];
  29.482 -  join $sep, map {"$_[0]/$_"} grep {/\.(jar|JAR)$/} readdir DIR;
  29.483 -}
  29.484 -
  29.485 -sub munge($) {
  29.486 -  join $sep,
  29.487 -    map {(! -r $_ and s/[\/\\]+\*$//) ? expand $_ : $_} split $sep, $_[0];
  29.488 -}
  29.489 -
  29.490 -for (my $i = 0; $i < @ARGV - 1; $i++) {
  29.491 -  $ARGV[$i+1] = munge $ARGV[$i+1] if $ARGV[$i] =~ /^-c(p|lasspath)$/;
  29.492 -}
  29.493 -
  29.494 -$ENV{CLASSPATH} = munge $ENV{CLASSPATH} if exists $ENV{CLASSPATH};
  29.495 -@ARGV = ("java", @ARGV);
  29.496 -print "@ARGV\n";
  29.497 -exec @ARGV;
  29.498 -
  29.499 -*/
    30.1 --- a/src/share/tools/launcher/wildcard.h	Mon May 06 13:53:13 2013 -0700
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,34 +0,0 @@
    30.4 -/*
    30.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
    30.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 - *
    30.8 - * This code is free software; you can redistribute it and/or modify it
    30.9 - * under the terms of the GNU General Public License version 2 only, as
   30.10 - * published by the Free Software Foundation.
   30.11 - *
   30.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 - * version 2 for more details (a copy is included in the LICENSE file that
   30.16 - * accompanied this code).
   30.17 - *
   30.18 - * You should have received a copy of the GNU General Public License version
   30.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 - *
   30.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 - * or visit www.oracle.com if you need additional information or have any
   30.24 - * questions.
   30.25 - *
   30.26 - */
   30.27 -
   30.28 -#ifndef WILDCARD_H_
   30.29 -#define WILDCARD_H_
   30.30 -
   30.31 -#ifdef EXPAND_CLASSPATH_WILDCARDS
   30.32 -const char *JLI_WildcardExpandClasspath(const char *classpath);
   30.33 -#else
   30.34 -#define JLI_WildcardExpandClasspath(s) (s)
   30.35 -#endif
   30.36 -
   30.37 -#endif /* include guard */

mercurial