obriencj/python-javatools

Error 'javatools.Unimplemented'.

pedromartins4 opened this issue · 9 comments

I have the following error:
javatools.Unimplemented: _next_argsig is '\x00' in �L�j�a�v�a�.�l�a�n�g�.�r�e�f�l�e�c�t�.�M�e�t�h�o�d�;�

running:
ci = unpack_classfile(full_filename)
print( ci.get_requires() )

where full_filename is the attached file (GitHub forced me to zip to upload):
SimplePropertyAccessor.class.zip

Seems to be a missing corner case somewhere. Please let me know if I can provide any additional information that helps on debugging.

Do you have the source code for this as well?

I would love to have the sources, so I can create a minimal reproducer, as well as information regarding which JDK was used. Then I can look at seeing where we are skipping an offset of some sort.

I got similar error:

❯ jardiff scala-library-2.12.8.jar scala-library-2.13.0.jar                                                                                                                                                                                   Traceback (most recent call last):                                                                                                                                                                                                              File "/Users/alvaro/.pyenv/versions/2.7/bin/jardiff", line 10, in <module>                                                                                                                                                                      
sys.exit(main(sys.argv))                                                                                                                                                                                                                    
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/jardiff.py", line 545, in main                                                                                                                                    
return cli(parser, *parser.parse_args(args))                                                                                                                                                                                                
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/jardiff.py", line 469, in cli                                                                                                                                     
return cli_jars_diff(parser, options, left, right)                                                                                                                                                                                          
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/jardiff.py", line 449, in cli_jars_diff                                                                                                                           
delta.check()                                                                                                                                                                                                                               
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 339, in check                                                                                                                                    
self.changed, self.description = self.check_impl()                                                                                                                                                                                          
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 443, in check_impl                                                                                                                               
change.check()                                                                                                                                                                                                                              
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 339, in check                                                                                                                                    
self.changed, self.description = self.check_impl()                                                                                                                                                                                          
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/jardiff.py", line 322, in check_impl                                                                                                                              
ret = SuperChange.check_impl(self)                                                                                                                                                                                                          
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 443, in check_impl                                                                                                                               
change.check()                                                                                                                                                                                                                              
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 339, in check                                                                                                                                    
self.changed, self.description = self.check_impl()                                                                                                                                                                                          
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 442, in check_impl                                                                                                                               
for change in self.collect():                                                                                                                                                                                                               
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/change.py", line 431, in collect                                                                                                                                  
self.changes = tuple(self.collect_impl())                                                                                                                                                                                                   
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/jardiff.py", line 147, in collect_impl                                                                                                                            
linfo = unpack_class(lfd.read())                                                                                                                                                                                                            
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/__init__.py", line 2201, in unpack_class                                                                                                                          
o.unpack(up, magic=magic)                                                                                                                                                                                                                   
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/__init__.py", line 415, in unpack                                                                                                                                 
self.cpool.unpack(unpacker)                                                                                                                                                                                                                 
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/__init__.py", line 172, in unpack                                                                                                                                 
item = _unpack_const_item(unpacker)                                                                                                                                                                                                         
File "/Users/alvaro/.pyenv/versions/2.7/lib/python2.7/site-packages/javatools/__init__.py", line 1943, in _unpack_const_item                                                                                                                    
raise Unimplemented("unknown constant type %r" % type)                                                                                                                                                                                    
javatools.Unimplemented: unknown constant type <type 'type'>

jar files can be downloaded from:
https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.0/scala-library-2.13.0.jar
https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.8/scala-library-2.12.8.jar

I know this is scala code, but ideally should generate valid java bytecode
Thanks!

Could you try this with the current master version of javatools from git?

I used these two jars as an example to do some python3 testing, which revealed a number of problems. I've published the fixes to master, however there's an unresolved/unrelated issue that we still don't fully support the InvokeDynamic constant type or the related bootstrap method table.

https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.10

Thank you. Tried with the repo version and got:

❯ jardiff scala-library-2.12.8.jar scala-library-2.13.0.jar
Traceback (most recent call last):
  File "/Users/alvaro/.pyenv/versions/3.7.0/bin/jardiff", line 11, in <module>
    load_entry_point('javatools==1.5.0', 'console_scripts', 'jardiff')()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/jardiff.py", line 628, in main
    return cli(parser.parse_args(args[1:]))
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/jardiff.py", line 551, in cli
    return cli_jars_diff(options, left, right)
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/jardiff.py", line 534, in cli_jars_diff
    delta.check()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 361, in check
    self.changed, self.description = self.check_impl()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 466, in check_impl
    change.check()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 361, in check
    self.changed, self.description = self.check_impl()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/jardiff.py", line 411, in check_impl
    ret = super(JarContentsChange, self).check_impl()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 466, in check_impl
    change.check()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 361, in check
    self.changed, self.description = self.check_impl()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 466, in check_impl
    change.check()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 361, in check
    self.changed, self.description = self.check_impl()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 466, in check_impl
    change.check()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 361, in check
    self.changed, self.description = self.check_impl()
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 465, in check_impl
    for change in self.collect():
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 453, in collect
    self.changes = tuple(self.collect_impl())
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 89, in iterate_by_type
    cache = collect_by_type(objs)
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/change.py", line 68, in collect_by_type
    for val in obj_sequence:
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/classdiff.py", line 308, in collect_impl
    li[member.get_identifier()] = member
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/__init__.py", line 1511, in get_identifier
    args = ",".join(self.get_arg_type_descriptors())
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/__init__.py", line 1387, in get_arg_type_descriptors
    tp = _typeseq(tp[0][1:-1])
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/__init__.py", line 2215, in _typeseq
    return tuple(_typeseq_iter(type_s))
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/__init__.py", line 2206, in _typeseq_iter
    t, s = _next_argsig(s)
  File "/Users/alvaro/.pyenv/versions/3.7.0/lib/python3.7/site-packages/javatools-1.5.0-py3.7.egg/javatools/__init__.py", line 2194, in _next_argsig
    raise Unimplemented("_next_argsig is %r in %r" % (c, s))
javatools.Unimplemented: _next_argsig is 's' in 'scala/collection/Seq;'

That doesn't seem to be the version from current master -- I backed that down to 1.4.0 (notice that the copy there is saying 1.5.0).

Oh sorry, had the previous installation interfering. Thanks! it works now.

Should I close this ticket or do you want to keep it open for the still unsupported features?

cool, thanks!