[jruby] Jruby 9.0.4.0 fails to compile code for MRI 2.1.6p336 (mingw).

Thomas E Enebo tom.enebo at gmail.com
Fri Jan 15 08:23:07 JST 2016


I can reduce the problem to:

class Foo
  def [](key)
  end
end

If you compile this with jrubyc but do not use --java it will work (on
master since we had a bug in 9.0.4.0), but I suspect it does not work with
--java because [] is not a valid identifier in java source code (but
totally ok in java class format).  Seems like we should make at least a
better error message that it is not possible to generate this...

-Tom

On Thu, Jan 14, 2016 at 1:35 PM, Hugh Sasse <hgs at dmu.ac.uk> wrote:

> Hello Tom,
>
> I have reduced the case to these 47 lines:
> <quote>
>
> # This needs to do a bit more than be a Hash.
> # We need to keep things case insensitive for this app,
> # and look things up that way and set them appropriately.
>
> class SymbolTable < Hash
>
>   def initialize(args=nil)
>     super
>   end
>
>
>   def [](key)
>     if key.respond_to? :upcase
>       super(key.upcase)
>     elsif key == ""
>       return nil
>     else
>       super
>     end
>   end
>
>   def []=(key, value)
>     if key.respond_to? :upcase
>       super(key.upcase, value)
>     elsif key.nil?  or  key == ""
>       if value == nil
>         super
>       else
>         raise " symbol empty string or nil must map to nil"
>       end
>     else
>       super
>     end
>   end
>
>   def has_key?(key)
>     if key.respond_to? :upcase
>       super(key.upcase)
>     else
>       super
>     end
>   end
>
> end
>
>
> </quote>
>
> I'd be the first to admit it is very crude, but it seems to work for
> what I'm doing.
>
> What appears to be happening, going by the messages I got when
>
> 1) commenting out all the methods, then
> 2) uncommenting them from the last one back to the first
>
> was that I got complaints about an unexpected question mark and
> and unepected Equals, so I'm inferring that the parser is objecting
> to my re-opening the class, because the unexpected LPAREN seems to
> come from the initialize method.  But this amounts to fairly wild
> speculation on my part :-) .
>
> I hope this is a small enough test case now.
>
> I'll probably need to look to metaprogramming to work around this and
> extend the individual object with a module, I expect.
>
> Thank you,
> Hugh
>
>
> On 14/01/2016 16:22, Hugh Sasse wrote:
>
>> Thank you, Tom.  That case you point at has a 5 line error case.
>> My code is currently 1025 lines.  I was hoping for some kind of output
>> that would help me narrow down where in my code it is failing.
>>
>> In the meantime, I will try to reduce this to something that would
>> handle a language nearer to /usr/games/fortune's SIMPL: Single
>> Instruction Mono-Purpose Language :-), which should make the
>> error case into a more sensible size.
>>
>> When I searched for the ParserSyntaxException string it seemed to be
>> only in the jar file, so it did not look like I could easily fix this
>> locally in order to get a line number out.
>>
>> I'll see what I can produce.
>>
>> Thank you.
>> Hugh
>>
>> On 14/01/2016 15:32, Thomas E Enebo wrote:
>>
>>> We do seem to have a second bug with --java + jrubyc open right now:
>>>
>>> https://github.com/jruby/jruby/issues/3599
>>>
>>> but if you can provide us with your error case then we can make it is
>>> also fixed.  As far as providing a better mechanism so you can fix it
>>> yourself I think we probably need some better error handling code
>>> there.   As it is whatever we are parsing is exploding in the parser but
>>> not displaying what that code it thinks is wrong...
>>>
>>> -Tom
>>>
>>> On Thu, Jan 14, 2016 at 5:59 AM, Hugh Sasse <hgs at dmu.ac.uk
>>> <mailto:hgs at dmu.ac.uk>> wrote:
>>>
>>>     Hello,
>>>
>>>     I've been writing an assembler of sorts, and this is mostly working.
>>>     It does have diagnostic puts statements in it, but otherwise does
>>>     not interact
>>>     with the terminal.  It runs to completion under Ruby 2.1.6p336
>>>     (Mingw), and I can get jruby 9.0.3.0 to produce a class file from it.
>>>     I got a ParserSyntaxException from jrubyc, with unclear (to me)
>>>     diagnostics
>>>     about where the problem was, so I upgraded to jruby 9.0.4.0.  I get
>>>     much the same results from jrubyc, i.e.:
>>>
>>>
>>>     C:\hgs_documents\electronics_club\Assembler\bin>jrubyc --javac
>>>     assembler.rb
>>>     Unhandled Java exception: org.jruby.parser.ParserSyntaxException:
>>>     syntax error,
>>>     unexpected LPAREN
>>>
>>>     org.jruby.parser.ParserSyntaxException: syntax error, unexpected
>>> LPAREN
>>>
>>>                            build_signature at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:142
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:228
>>>                   block in visit_args_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:35
>>>                                  with_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:188
>>>                   block in visit_args_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:34
>>>                              visitArgsNode at
>>>     JRuby$$Compiler$$ClassNodeWalker_385928
>>>     906.gen:13
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:240
>>>                   block in visit_defn_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:35
>>>                                  with_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:188
>>>                   block in visit_defn_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:34
>>>                              visitDefnNode at
>>>     JRuby$$Compiler$$ClassNodeWalker_385928
>>>     906.gen:13
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:270
>>>                                       each at
>>>     uri:classloader:/jruby/java/java_ext/ja
>>>     va.util.rb:7
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:270
>>>                  block in visit_block_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:35
>>>                                  with_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:188
>>>                  block in visit_block_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:34
>>>                             visitBlockNode at
>>>     JRuby$$Compiler$$ClassNodeWalker_385928
>>>     906.gen:13
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:234
>>>                  block in visit_class_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:35
>>>                                  with_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:188
>>>                  block in visit_class_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:34
>>>                             visitClassNode at
>>>     JRuby$$Compiler$$ClassNodeWalker_385928
>>>     906.gen:13
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:270
>>>                                       each at
>>>     uri:classloader:/jruby/java/java_ext/ja
>>>     va.util.rb:7
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:270
>>>                  block in visit_block_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:35
>>>                                  with_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:188
>>>                  block in visit_block_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:34
>>>                             visitBlockNode at
>>>     JRuby$$Compiler$$ClassNodeWalker_385928
>>>     906.gen:13
>>>                   block in ClassNodeWalker at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:281
>>>                   block in visit_root_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:35
>>>                                  with_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:188
>>>                   block in visit_root_node at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:34
>>>                              visitRootNode at
>>>     JRuby$$Compiler$$ClassNodeWalker_385928
>>>     906.gen:13
>>>                              generate_java at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler/java_class.rb:8
>>>        block in compile_files_with_options at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler.rb:141
>>>        block in compile_files_with_options at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler.rb:291
>>>                                       each at
>>> org/jruby/RubyArray.java:1560
>>>                 compile_files_with_options at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler.rb:275
>>>                               compile_argv at
>>>     C:/jruby-9.0.4.0/lib/ruby/stdlib/jruby/
>>>     compiler.rb:94
>>>                                      <top> at
>>>     C_3a_/jruby_minus_9_dot_0_dot_4_dot_0/b
>>>     in/C:/jruby-9.0.4.0/bin/jrubyc:5
>>>
>>>
>>>     C:\hgs_documents\electronics_club\Assembler\bin>
>>>
>>>     What I'm failing to see here is anything specific about where my
>>>     code is wrong.
>>>     I also can't see anything wrong with the parentheses at javaclass.rb
>>>     line 142, but I'd expect that to have been spotted and fixed by now,
>>>     of course.
>>>
>>>     I also get:
>>>
>>>     C:\hgs_documents\electronics_club\Assembler\bin>jruby -W -c
>>> assembler.rb
>>>     io/console not supported; tty will not be manipulated
>>>     Syntax OK
>>>
>>>     C:\hgs_documents\electronics_club\Assembler\bin>
>>>
>>>     Hence my remarks about puts, earlier.
>>>
>>>     My java is 1.8.0_66, if that is useful diagnostics, on Windows 7
>>> 32bit.
>>>
>>>     I'm not about to say: "here's my code, debug this for me" :-), so
>>>     how do I get more useful information out of jrubyc as to what is
>>>     going on?
>>>     That way, I could attempt to produce a smaller failing case to pass
>>>     on for unit test purposes.  Provided that will help, that is.
>>>
>>>     My goal is to produce a jar file I can run as an executable,
>>>     supplying two filenames on the command line, as I do for the present
>>>     ruby code.  I have failed to produce such a thing with Warbler.
>>>     (My other approach to creating an executable
>>>     with rubyscript2exe failed also, but that is off-topic for this
>>> list.)
>>>
>>>     Thank you,
>>>     Hugh
>>>
>>>
>>>
>>>
>>>
>>> --
>>> blog: http://blog.enebo.com       twitter: tom_enebo
>>> mail: tom.enebo at gmail.com <mailto:tom.enebo at gmail.com>
>>>
>>
>>
>>
>
>


-- 
blog: http://blog.enebo.com       twitter: tom_enebo
mail: tom.enebo at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ruby-lang.org/pipermail/jruby/attachments/20160114/9d2adf99/attachment-0001.html>


More information about the JRuby mailing list