I'm having issues passing a Byte into a Java library and I honestly can't find a single place on Google where anyone has done it or even talked about doing it. I'm not sure if this means I'm missing something very simple and obvious or just the first person to try :)
Here is the java method I'm trying to call:
The method signature is quite simple:
public static native void shiftOut(byte dPin, byte cPin, byte order, byte val);
Using the CommandBox 2.0.0 REPL (Running Lucee 4.5.1.008):
CFSCRIPT-REPL: shift = createObject( 'java', 'com.pi4j.wiringpi.Shift')
[Object java.lang.Class]
CFSCRIPT-REPL: shift.shiftIn( 27, 28, shift.MSBFIRST, '00000000' )
ERROR
No matching Method for shiftIn(numeric, numeric, numeric, string) found for com.pi4j.wiringpi.Shift
Ok, fair enough-- I didn't cast anything. Lucee saw a numeric, numeric, numeric and a string, but we need all four of the parameters to be bytes. Let's try casting the first parameter and see what happens.
CFSCRIPT-REPL: shift.shiftIn( javaCast( 'byte', 27 ), 28, shift.MSBFIRST, '00000000' )
ERROR
No matching Method for shiftIn(numeric, numeric, numeric, string) found for com.pi4j.wiringpi.Shift
Nope, the first param was still seem as a numeric even though I cast it. Let's try manually creating an instance of java.lang.Byte.
CFSCRIPT-REPL: byte = createObject( 'java', 'java.lang.Byte')
[Object java.lang.Class]
CFSCRIPT-REPL: shift.shiftIn( byte.init( 27 ), 28, shift.MSBFIRST, '00000000' )
ERROR
No matching Method for shiftIn(numeric, numeric, numeric, string) found for com.pi4j.wiringpi.Shift
No dice. Lucee is still convinced I'm trying to pass a "numeric" into my Java function.
I won't show the code, but even trying to javaCast() my Byte object results in Lucee seeing a "numeric". Also, I'm aware the "java.lang.Byte" is not the same as a native "byte" data type, but calling byte.init(27).byteValue() doesn't make any difference. It's still always a numeric.
Any ideas?
Thanks!
~Brad