ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken Wood <kw...@i2.com>
Subject Re: [suggestion] re: Bootstrapping Ant
Date Tue, 08 Aug 2000 17:48:05 GMT
I think this boils down to:

  1. java apps are platform independent

  2. invoking java apps is platform dependent

Just look at the installation of the JDK itself from,
say, IBM on AIX, Sun on Solaris, or HP on HPUX, and
you'll find that when you type "java -jar ant.jar"
you are invoking a shell script of some kind.

So, while it may be 'ugly' in some fashion, I
don't know of a way around it. I've looked
at commercial apps and they all address this
issue one way or another. Sometimes they
wrap their java apps in bat/shell scripts.
Sometimes they wrap them in python scripts
or perl scripts. At some point the OS
independent app has to be invoked in an OS
dependent way...

Example: on solaris 2.6 "java" is actually
this shell script, which has to deal with
issues like native threads vs green threads,
etc...

#!/bin/ksh -p
#
# @(#)java_wrapper.sh   1.52 99/01/13
#
# Copyright 1994-1998 by Sun Microsystems, Inc.,
# 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
# All rights reserved.
#
 
#===================================================================
# THIS SCRIPT AND JAVA WILL NOT RUN UNDER SUNOS4.X, AKA SOLARIS 1.X.  
#===================================================================
 
PRG=`whence $0` >/dev/null 2>&1
progname=`/usr/bin/basename $0`
proc=`/usr/bin/uname -p`
APPHOME=`/usr/bin/dirname "$PRG"`/..
 
# Resolve symlinks. See 4152645.
while [ -h "$PRG" ]; do
    ls=`/usr/bin/ls -ld "$PRG"`
    link=`/usr/bin/expr "$ls" : '^.*-> \(.*\)$'`
    if /usr/bin/expr "$link" : '^/' > /dev/null; then
        prg="$link"
    else
        prg="`/usr/bin/dirname $PRG`/$link"
    fi
    PRG=`whence "$prg"` > /dev/null 2>&1
    APPHOME=`/usr/bin/dirname "$PRG"`/..
done
 
JREHOME=$APPHOME/jre
 
# Where is JRE?
unset jre
if [ -f "${JREHOME}/lib/${proc}/libjava.so" ]; then
    jre="${JREHOME}"
fi
if [ -f "${APPHOME}/lib/${proc}/libjava.so" ]; then
    jre="${APPHOME}"
fi
if [ "x${jre}" = "x" ]; then
    echo "Error: can't find libjava.so."
    exit 1
fi
 
# Select vm type (if classic vm, also select thread type).
unset vmtype
unset ttype
DEFAULT_THREADS_FLAG=green

if [ "x$1" = "x-hotspot" ]; then
    vmtype=hotspot
    ttype=native_threads
    shift 1
else
    if [ "x$1" = "x-classic" ]; then
        vmtype=classic
        ttype=${DEFAULT_THREADS_FLAG}_threads
        shift 1
    else
        if [ "x$1" = "x-green" ]; then
            vmtype=classic
            ttype=green_threads
            shift 1
        else
            if [ "x$1" = "x-native" ]; then
                vmtype=classic
                ttype=native_threads
                shift 1
            else 
                if [ -d ${jre}/lib/${proc}/hotspot ]; then
                    vmtype=hotspot
                    ttype=native_threads
                else
                    vmtype=classic
                    if [[ ${THREADS_FLAG:-${DEFAULT_THREADS_FLAG}} =
native ]]
                    then 
                        ttype=native_threads
                    else
                        ttype=green_threads
                    fi
                fi
            fi
        fi
    fi
fi
 
# Special handling for classic VM.
if [ "${vmtype}" = "classic" ]; then
    # fix for bug 4032715
    if [[ ${ttype} = green_threads ]] ; then 
        LD_BIND_NOW=yes
        export LD_BIND_NOW
    fi
    # For internal use by classic VM.
    _JVM_THREADS_TYPE="${ttype}"
    export _JVM_THREADS_TYPE
fi
 
# Set LD_LIBRARY_PATH for hotspot VM.
LD_LIBRARY_PATH="${jre}/lib/${proc}/${ttype}:${jre}/lib/${proc}/${vmtype}:${jre}/lib/${proc}:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
 
# prepend XFILESEARCHPATH with awt Motif default locale resource files.
XFILESEARCHPATH="${jre}/lib/locale/%L/%T/%N%S:$XFILESEARCHPATH"
export XFILESEARCHPATH
 
prog="$APPHOME/bin/${proc}/${ttype}/${progname}"
 
# Run.
if [ -x "$prog" ]
then
    exec $DEBUG_PROG "$prog" "$@"
else
    echo >&2 "$progname was not found in ${prog}"
    exit 1
fi

Mime
View raw message