Hi Alex!  Thanks for holding PilCon yesterday (and the reminder).  I
enjoyed it!  I like Pil21 very much (it reminds me of using FORTH
assemblers back in the day), but I still have a use case where only Java
execution is suitable.

The PilCon discussion motivated me to take a look at the Ersatz Java 11
compilation issue.  I am happy to report there was a simple fix, and after
rebuilding it without warnings, it passed all of the tests relevant to
Ersatz.  I modified the standard test files with *(unless (member *CPU
'("JVM"))* etc.  Details follow.

Thank you for all of your wonderful work that you have shared with us, I
appreciate it!

Regards,
rcs

+----------------------------------------------------------+
|  *Ersatz Fix for Warning-Free Compilation Under Java 11+*  |
|                  *  22-Aug-2020, rcs   *                   |
+----------------------------------------------------------+


*PROBLEM-------*
An attempt to rebuild Ersatz using mkJar.l under Java 11 or higher results
in the warnings:

Note: PicoLisp.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.


*DIAGNOSIS---------*
Modify the second when clause of mkJar.l to reveal the deprecated features
by adding the
"-deprecation" flag (a synonym for -Xlint:deprecation):

(when (call "javac" "-g:none" "-deprecation" "PicoLisp.java")
                              ^^^^^^^^^^^^^^
On a system with Java 11 installed on it (package openjdk-11-jdk and its
dependencies under Debian Linux),
execute mkJal.l (e.g. ./pil mkJar.l under Linux).

When executed, 9 warnings are displayed in the form:

 PicoLisp.java:3074: warning: [deprecation] Integer(int) in Integer has
been deprecated
               arg[i] = new Integer(num.Cnt);

Forgiving the editorial commentary, the Stack Overflow posting "The
constructors Integer(int),
Double(double), Long(long) and so on are deprecated" is enlightening
(
https://stackoverflow.com/questions/47095474/the-constructors-integerint-doubledouble-longlong-and-so-on-are-deprecat#47095501).
In short, it recommends replacing the form:

new <WrapperType>(<primitiveType>)

with

<WrapperType>.valueOf(<primitiveType>)


*CURE----*
Make the changes in fun.src as follows (this example uses version 19.10.21):

153c153
<          arg[i] = new Integer(num.Cnt);
---
>          arg[i] = Integer.valueOf(num.Cnt);
277c277
<    return new Symbol(new Byte(x instanceof Number? (byte)((Number)x).Cnt
: (byte)x.name().charAt(0)));
---
>    return new Symbol(Byte.valueOf(x instanceof Number?
(byte)((Number)x).Cnt : (byte)x.name().charAt(0)));
282c282
<    return new Symbol(new Character(x instanceof Number?
(char)((Number)x).Cnt : x.name().charAt(0)));
---
>    return new Symbol(Character.valueOf(x instanceof Number?
(char)((Number)x).Cnt : x.name().charAt(0)));
286c286
<    return new Symbol(new Integer(evInt(ex.Cdr)));
---
>    return new Symbol(Integer.valueOf(evInt(ex.Cdr)));
290c290
<    return new Symbol(new Long(evLong(ex.Cdr)));
---
>    return new Symbol(Long.valueOf(evLong(ex.Cdr)));
296,297c296,297
<       return new Symbol(new Float(((Number)x).toString(evInt(ex.Cdr),
'.', '\0')));
<    return new Symbol(new Float(x.name()));
---
>       return new Symbol(Float.valueOf(((Number)x).toString(evInt(ex.Cdr),
'.', '\0')));
>    return new Symbol(Float.valueOf(x.name()));
303,304c303,304
<       return new Symbol(new Double(((Number)x).toString(evInt(ex.Cdr),
'.', '\0')));
<    return new Symbol(new Double(x.name()));
---
>       return new
Symbol(Double.valueOf(((Number)x).toString(evInt(ex.Cdr), '.', '\0')));
>    return new Symbol(Double.valueOf(x.name()));

Execution of the tests in the ~/picoLisp/test directory relevant to Ersatz
confirms it is functional
after these changes.

-- 
*Níl aon tinteán mar do thinteán féin. *[Irish Gaelic]
(There is no fireside like your own fireside.)

Reply via email to