2

I am trying to read from a file: test1.txt the file has only one line: abcdefghigk

java -jar jython-standalone-2.7.3.jar
Jython 2.7.3 (tags/v2.7.3:5f29801fe, Sep 10 2022, 18:52:49)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_351
Type "help", "copyright", "credits" or "license" for more information.

>>> from java.io import FileReader
from java.io import FileReader
>>> import jarray
import jarray
>>> reader = FileReader('./test1.txt')
reader = FileReader('./test1.txt')
>>> chars = jarray.zeros(2048, 'c')
chars = jarray.zeros(2048, 'c')
>>> num = reader.read(chars)
num = reader.read(chars)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: read(): 1st arg can't be coerced to java.nio.CharBuffer, char[]
>>> 

If I use the older jython , it works

[pzwu@pzwu-1 python]$ java -jar jython-standalone-2.7.2.jar 
Jython 2.7.2 (v2.7.2:925a3cc3b49d, Mar 21 2020, 10:03:58)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_351
Type "help", "copyright", "credits" or "license" for more information.

>>> from java.io import FileReader
from java.io import FileReader
>>> import jarray
import jarray
>>> reader = FileReader('./test1.txt')
reader = FileReader('./test1.txt')
>>> chars = jarray.zeros(2048, 'c')
chars = jarray.zeros(2048, 'c')
>>> num = reader.read(chars)
num = reader.read(chars)
>>> print num
print num
13

Not sure what's going from 2.7.2 to 2.7.3. Thanks

Tried with jdk11, same result.. I guess it is a 2.7.3 bug?

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64
Peter Wu
  • 21
  • 1

0 Answers0