Problems with initialization of a byte array, INLINE Java IS NECESSARY...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problems with initialization of a byte array, INLINE Java IS NECESSARY...

Oleg A. Kulikov
I was ready to write a message given below with a proposition to support
inline Java codes to handle primitive data ( say to have a conveniet array
initialization or to have an
opportunity to use powerfull shift operation <<<, >>> with a byte data ),
when Antoon Verhoeven proposed the same.
----------

I've detected that hexPrint example program from the RedBook types
character "?" intead of bytes x'88' and x'98'. I've decided to check
where an error lies and I've wrote the most natural for me definition
of a byte array:

ascii = [ byte '╪', '?', '%', '-', '?', 'T' ] -- 87 88 89 97 98 99 ( DOS
coding is used here )
System.out.println( String( ascii ) )
Say Rexx String( ascii )
exit

The result of execution was:

java.lang.NumberFormatException: ╪
 at netrexx.lang.Rexx.toint(Rexx.nrx:616)
 at netrexx.lang.Rexx.tobyte(Rexx.nrx:596)
 at t.main(t.nrx:38)

OK, I've changed ascii definition to:

ascii = [ byte 135, 136, 137, 151, 152, 153 ] -- 87 88 89 97 98 99

and I've got a very strange compiler message:

NetRexx portable processor, version 1.113
Copyright (c) IBM Corporation, 1997.  All rights reserved.
Program t.nrx
 40 +++ ascii = [ byte 135, 136, 137, 151, 152, 153 ] -- 87 88 89 97 98 99
    +++                     ^^^
    +++ Error: Cannot convert value of type 'short' for assignment to array
element of type 'byte'
Compilation of 't.nrx' failed [one error]

It was natural for me to define type of elements of an array only once but
to exclude this error message it appeared necessary to write "byte" near
ALL elements of this array. Besides even schoolboy knows that byte values
lies in [0,255] region and thus would be surprized by the message above.

Skipping the other details it appeared that only ascii definition in a
rather unnatural form:

ascii = [ byte (-121), (-120), (-119), (-105), (-104), (-103) ]

has permitted to get a result:

╪?%-?T
╪?%-?T

which shows that an error I've detected lies in one of the Java 1.1.3
classes nor in the NetRexx classes.

Sorry for such a long message,
O'Kulikov.

P.S: my environment is NT 4.0 ( x86 ), JDK 1.1.3, NetRexx 1.113.

[hidden email]