natural / java2python

Simple but effective library to translate Java source code to Python.
GNU Lesser General Public License v2.1
564 stars 243 forks source link

IndexError: list index out of range #62

Open AdvancedImagingUTSW opened 5 years ago

AdvancedImagingUTSW commented 5 years ago

Thanks in advance...

Running java2python in Anaconda on a Mac with following packages: ...$ conda list -n j2p

packages in environment at /Applications/Anaconda/anaconda3/envs/j2p:

#

Name Version Build Channel

antlr-python-runtime 3.1.3 pypi_0 pypi ca-certificates 2019.8.28 0
certifi 2019.9.11 py27_0
java2python 0.5.0 pypi_0 pypi libcxx 4.0.1 hcfea43d_1
libcxxabi 4.0.1 hcfea43d_1
libedit 3.1.20181209 hb402a30_0
libffi 3.2.1 h475c297_4
ncurses 6.1 h0a44026_1
pip 19.2.3 py27_0
python 2.7.16 h97142e2_7
readline 7.0 h1de35cc_5
setuptools 41.4.0 py27_0
sqlite 3.30.0 ha441bb4_0
tk 8.6.8 ha441bb4_0
wheel 0.33.6 py27_0
zlib 1.2.11 h1de35cc_3

Trying to convert this file to python... https://github.com/smithk/cidre/blob/master/0.1/imagej/src/Cidre_Plugin.java

Get the following error j2py Cidre_Plugin.java Cidre_Plugin.py Traceback (most recent call last): File "/Applications/Anaconda/anaconda3/envs/j2p/bin/j2py", line 258, in sys.exit(runMain(configScript(sys.argv[1:]))) File "/Applications/Anaconda/anaconda3/envs/j2p/bin/j2py", line 57, in runMain return runOneOrMany(options) File "/Applications/Anaconda/anaconda3/envs/j2p/bin/j2py", line 82, in runOneOrMany return runTransform(options) File "/Applications/Anaconda/anaconda3/envs/j2p/bin/j2py", line 134, in runTransform module.walk(tree) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 86, in walk visitor.walk(child, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 86, in walk visitor.walk(child, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 86, in walk visitor.walk(child, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 86, in walk visitor.walk(child, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 86, in walk visitor.walk(child, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 83, in walk visitor = self.accept(tree, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 43, in accept return call(node, memo) File "/Applications/Anaconda/anaconda3/envs/j2p/lib/python2.7/site-packages/java2python/compiler/visitor.py", line 474, in acceptIf nextNode = nextNode.children[2] IndexError: list index out of range

changeling commented 4 years ago

@AdvancedImagingUTSW Did you get past this error? Currenlty running into this problem and about to dig in.

AdvancedImagingUTSW commented 4 years ago

Hello @changeling,

I never did get past this error. It's been months since I tried though. Thanks in advance.

Best, Kevin

changeling commented 4 years ago

Thanks for the response, Kevin.

For anyone running into this, I manually implemented the patches in https://github.com/natural/java2python/pull/32 and it seems to have fixed this problem.

Cheers,

Chris