IcedTeaWeb: using java 9 run args ?

Laurent Bourgès bourges.laurent at gmail.com
Fri Oct 19 11:14:03 UTC 2018


Jiri,

One more question:
Why not parse java.version in java itself ?

Shell scripts need to parse 1.8 or 9+ to handle properly java command
arguments.

Laurent

Le jeu. 18 oct. 2018 à 23:05, Laurent Bourgès <bourges.laurent at gmail.com> a
écrit :

> Jiri,
> I took some time to illustrate my proposal about simplifying shell scripts
> to work on OpenJDK11 and 8:
>
> I need the install directory for ITW:
> +ITW_INS=/home/bourgesl/libs/icedtea-web-1.7-HEAD/install
>
> Then I removed all add-reads / add-exports (except patch-module) and added
> argument to use arg file:
>
>
> *+  # add JDK9 arg file:+  COMMAND[k]="@$ITW_INS/bin/itw-run.args"+
> k=$((k+1))*
>
> Arg File named itw-run.args in the same folder as shell scripts (sh/bat)  :
> --add-reads=java.base=ALL-UNNAMED,java.desktop
> --add-reads=java.desktop=ALL-UNNAMED,java.naming
> --add-reads=java.naming=ALL-UNNAMED,java.desktop
>
> --add-exports=java.desktop/sun.awt=ALL-UNNAMED,java.desktop
> --add-exports=java.desktop/javax.jnlp=ALL-UNNAMED,java.desktop
>
>
> --add-exports=java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.security.action=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.security.provider=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.security.util=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.security.validator=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.security.x509=ALL-UNNAMED,java.desktop
> --add-exports=java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop
> --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop
>
> --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop
> --add-exports=java.desktop/sun.applet=ALL-UNNAMED,java.desktop
> --add-exports=java.desktop/sun.applet=ALL-UNNAMED,jdk.jsobject
>
> --add-exports=java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop
>
> It is simpler to me to gather all add-reads/add-exports declaration in
> such arg file (less obfuscated) and it will be reused by windows script too.
>
> What do you think ?
> I will go on modifying the Makefile generating such shells from templates
> launchers.in (sed ...)
>
> Laurent
>
> PS: diff for my javaws / javaws11 installed scripts (generated):
> --- /home/icedtea/icedtea-web-1.7-HEAD/install/bin/javaws
> +++ /home/icedtea/icedtea-web-1.7-HEAD/install/bin/javaws11
> @@ -1,14 +1,16 @@
>  #!/bin/bash
>
> +ITW_INS=/home/bourgesl/libs/icedtea-web-1.7-HEAD/install
> +ITW_SHARE=$ITW_INS/share
> +
>  NASHORN=lib/ext/nashorn.jar
> -JAVA=/home/bourgesl/apps/ojdk8//jre/bin/java
>
> -LAUNCHER_BOOTCLASSPATH='-Xbootclasspath/a:/home/bourgesl/libs/icedtea-web-1.7-HEAD/install/share/icedtea-web/netx.jar'
> +JAVA_BASE=/home/bourgesl/apps/openjdk-11+28_linux-x64_bin
> +LAUNCHER_BOOTCLASSPATH="-Xbootclasspath/a:$ITW_SHARE/icedtea-web/netx.jar"
>  LAUNCHER_FLAGS=-Xms8m
>  CLASSNAME=net.sourceforge.jnlp.runtime.Boot
>
> -BINARY_LOCATION=/home/bourgesl/libs/icedtea-web-1.7-HEAD/install/bin/javaws
>
> -SPLASH_LOCATION=/home/bourgesl/libs/icedtea-web-1.7-HEAD/install/share/icedtea-web/javaws_splash.png
> +BINARY_LOCATION=$ITW_INS/bin/javaws11
> +SPLASH_LOCATION=$ITW_SHARE/icedtea-web/javaws_splash.png
>  PROGRAM_NAME=javaws
>
> -CP=/home/bourgesl/apps/ojdk8//jre/lib/rt.jar:/home/bourgesl/apps/ojdk8//jre/lib/jfxrt.jar
>
>  CONFIG_HOME=$XDG_CONFIG_HOME
>  if [ "x$CONFIG_HOME" = "x" ] ; then
> @@ -27,15 +29,14 @@
>  fi;
>  if [ "x$CUSTOM_JRE" != "x" ] ; then
>    if [ -e  "$CUSTOM_JRE" -a -e "$CUSTOM_JRE/bin/java" ] ; then
> -    JAVA=$CUSTOM_JRE/bin/java
> -    CP=$CUSTOM_JRE/lib/rt.jar:$CUSTOM_JRE/lib/jfxrt.jar
> -    LAUNCHER_BOOTCLASSPATH=$LAUNCHER_BOOTCLASSPATH:$CUSTOM_JRE/$NASHORN
> +    JAVA_BASE=$CUSTOM_JRE
>    else
> -    echo "Your custom JRE $CUSTOM_JRE read from deployment.properties
> under key $PROPERTY_NAME as $CUSTOM_JRE is not valid. Using default ($JAVA,
> $CP) in attempt to start. Please fix this."
> +    echo "Your custom JRE $CUSTOM_JRE read from deployment.properties
> under key $PROPERTY_NAME as $CUSTOM_JRE is not valid. Using default ($JAVA)
> in attempt to start. Please fix this."
>    fi
> -else
> -
> LAUNCHER_BOOTCLASSPATH="$LAUNCHER_BOOTCLASSPATH:/home/bourgesl/apps/ojdk8//jre/$NASHORN"
>  fi;
> +
> +JAVA=$JAVA_BASE/bin/java
> +echo "JAVA: $JAVA"
>
>  MODULAR_JDK="NO"
>  version=`${JAVA} -version 2>&1 | head -n 1 | cut -d'-' -f1 | cut -d'"'
> -f2 | cut -d'.' -f1`
> @@ -44,6 +45,9 @@
>  fi
>  if [ $version -ge "9" ]; then
>    MODULAR_JDK="YES"
> +else
> +  CP=$JAVA_BASE/lib/rt.jar:$JAVA_BASE/lib/jfxrt.jar
> +  LAUNCHER_BOOTCLASSPATH=$LAUNCHER_BOOTCLASSPATH:$JAVA_BASE/$NASHORN
>  fi
>
>  JAVA_ARGS=( )
> @@ -55,7 +59,7 @@
>
>  SPLASH="false"
>  if [ "x$ICEDTEA_WEB_SPLASH" = "x" ] ; then
> -SPLASH="true"
> +  SPLASH="true"
>  fi;
>  while [ "$#" -gt "0" ]; do
>    case "$1" in
> @@ -78,8 +82,8 @@
>  COMMAND[k]="${JAVA}"
>  k=$((k+1))
>  if [ "$SPLASH" = "true" ] ; then
> -COMMAND[k]="-splash:${SPLASH_LOCATION}"
> -k=$((k+1))
> +  COMMAND[k]="-splash:${SPLASH_LOCATION}"
> +  k=$((k+1))
>  fi;
>  COMMAND[k]="${LAUNCHER_BOOTCLASSPATH}"
>  k=$((k+1))
> @@ -87,96 +91,30 @@
>  k=$((k+1))
>
>  if [ "x$MODULAR_JDK" == "xYES" ] ; then
> -COMMAND[k]="--patch-module"
> -k=$((k+1))
>
> -COMMAND[k]="java.desktop=:/home/bourgesl/libs/icedtea-web-1.7-HEAD/install/share/icedtea-web/netx.jar"
> -k=$((k+1))
> -# jsobject must be pathched separately from plugin
> -# otherwise netscape pkg would be shared by two modules, which is forbiden
> -JSOBJECT_JAR=
> -# plugin jar may not be built
> -if [ ! "x$JSOBJECT_JAR" == "x" ] ; then
>    COMMAND[k]="--patch-module"
>    k=$((k+1))
> -  COMMAND[k]="jdk.jsobject=$JSOBJECT_JAR"
> +  COMMAND[k]="java.desktop=$ITW_SHARE/icedtea-web/netx.jar"
> +  k=$((k+1))
> +  # jsobject must be patched separately from plugin
> +  # otherwise netscape pkg would be shared by two modules, which is
> forbiden
> +  JSOBJECT_JAR=
> +  # plugin jar may not be built
> +  if [ ! "x$JSOBJECT_JAR" == "x" ] ; then
> +    COMMAND[k]="--patch-module"
> +    k=$((k+1))
> +    COMMAND[k]="jdk.jsobject=$JSOBJECT_JAR"
> +    k=$((k+1))
> +  fi
> +
>
>
> *+  # add JDK9 arg file:+  COMMAND[k]="@$ITW_INS/bin/itw-run.args"+
> k=$((k+1))*
> +else
> +  COMMAND[k]="-classpath"
> +  k=$((k+1))
> +  COMMAND[k]="${CP}"
>    k=$((k+1))
>  fi
> -
> -COMMAND[k]="--add-reads"
> -k=$((k+1))
> -COMMAND[k]="java.base=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-reads"
> -k=$((k+1))
> -COMMAND[k]="java.desktop=ALL-UNNAMED,java.naming"
> -k=$((k+1))
> -COMMAND[k]="--add-reads"
> -k=$((k+1))
> -COMMAND[k]="java.naming=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.desktop/sun.awt=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.desktop/javax.jnlp=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.security.provider=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.security.util=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.security.x509=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.security.validator=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
>
> -COMMAND[k]="java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.desktop/sun.applet=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.security.action=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop"
> -k=$((k+1))
> -COMMAND[k]="--add-exports"
> -k=$((k+1))
> -COMMAND[k]="java.desktop/sun.applet=ALL-UNNAMED,jdk.jsobject"
> -k=$((k+1))
> -fi
> -
>
>  i=0
>  while [ "$i" -lt "${#JAVA_ARGS[@]}" ]; do
> @@ -184,14 +122,20 @@
>    i=$((i+1))
>    k=$((k+1))
>  done
> -COMMAND[k]="-classpath"
> -k=$((k+1))
> -COMMAND[k]="${CP}"
> -k=$((k+1))
> +
>  COMMAND[k]="-Dicedtea-web.bin.name=${PROGRAM_NAME}"
>  k=$((k+1))
>  COMMAND[k]="-Dicedtea-web.bin.location=${BINARY_LOCATION}"
>  k=$((k+1))
> +
> +# icedtea-web.edt.debug
> +#COMMAND[k]="-Dicedtea-web.edt.debug=true"
> +#k=$((k+1))
>
>  COMMAND[k]="${CLASSNAME}"
>  k=$((k+1))
>  j=0
> @@ -201,6 +145,7 @@
>    k=$((k+1))
>  done
>
> +echo "CLI: '${COMMAND[@]}' "
>  exec -a "$PROGRAM_NAME" "${COMMAND[@]}"
>
>  exit $?
>
>
> Le mar. 9 oct. 2018 à 12:20, Jiri Vanek <jvanek at redhat.com> a écrit :
>
>> On 10/9/18 9:24 AM, Laurent Bourgès wrote:
>> > Jiri,
>> >
>> > I will prototype moving all java9 args from linux launchers into a
>> common arg file: itw.args.
>> >
>> > It will reduce the size and complexity and allow its reuse in windows
>> launchers.
>> > I suppose it will simplify rust launchers too.
>>
>> Major issue is I guess to find that file. The global x user
>> configurations are different. Also it
>> can use per-vm  configurations and in addition (linux x  window) x
>> (installed x selfbuild x
>> unpacked) locations are different.
>>
>> Maybe more friendly will be to include that in deployment properties?
>> Maybe path to this file can be
>> in deplyment properties?
>>
>>
>> This complication was the actual reason I had it hardcoded.  (especilly
>> with duplicated hardcoding
>> in plugin,  but htat issue is mos likely gone by plugin being deprecatyed
>> in 1.8 and removed in 1.9).
>>
>> Now, if this file will be used for -add-provides and friends, should it
>> serve also for other java
>> params? We already ahve this covered via -J and via one deployment
>> property (whih is I'm afraid
>> untested, unknow and never tempted out of the plugin).
>>
>> Thoughts?
>>    J.
>> >
>> >
>> >      > I wonder if you would agree giving java 9 add-reads, add-export
>> args as argument files ?
>> >      > See
>> >      >
>> >
>> https://blog.codefx.org/java/five-command-line-options-hack-java-module-system/#Thoughts-On-Command-Line-Options
>> >      >
>> >      > It would simplify a lot the linux / windows shell scripts and
>> possibly rust launchers (1.8) and
>> >      > allow using the same arg file for both win/unix launcher
>> (unified).
>> >      >
>> >
>> >     Hi!
>> >
>> >     Interesting idea...
>> >
>> >     Isnt it already achievable via -J ?
>> >     /me not tried
>> >
>> >
>> > This work is dedicated to improving existing shell scripts, not using
>> arg file for the jnlp
>> > application (out of scope).
>> >
>> > Cheers,
>> > Laurent
>>
>>
>> --
>> Jiri Vanek
>> Senior QE engineer, OpenJDK QE lead, Mgr.
>> Red Hat Czech
>> jvanek at redhat.com    M: +420775390109
>>
>
>
> --
> --
> Laurent Bourgès
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20181019/7e351534/attachment-0001.html>


More information about the distro-pkg-dev mailing list