[Scons-users] IndexError in Java parser with anonymous classes
William Blevins
wblevins001 at gmail.com
Wed Oct 7 13:07:12 EDT 2015
If I'm following the token parser follow correctly, it makes a mistake with
the nested templates within the AnonClass state handler, but I'm not 100%
sure that causes the crash.
On Wed, Oct 7, 2015 at 5:51 PM, William Keith <wak at kaon.co.uk> wrote:
> Yes it does; curiously if you remove one of the template parameters (e.g.,
> new Foo<Baz> rather than new Foo<Bar<Baz>>) then the issue goes away. It
> also goes away if you remove either of the other anonymous class instances,
> however.
>
> On 7 October 2015 at 17:47, William Blevins <wblevins001 at gmail.com> wrote:
>
>>
>>
>> On Wed, Oct 7, 2015 at 5:39 PM, William Keith <wak at kaon.co.uk> wrote:
>>
>>> I'm not so sure that the missing symbols are affecting it - as I said,
>>> this is a pared down version of the original, which has no such missing
>>> symbols. Additionally, if I modify the example as follows:
>>>
>>> class MyApp
>>> {
>>> private interface SomethingElse {}
>>> private static class Something
>>> {
>>> public Something(SomethingElse se) {}
>>> }
>>> private static class Bar<T> {}
>>> private static class Baz {}
>>> private static interface Foo<U>
>>> {
>>> public void boz();
>>> }
>>> private static interface Whatsit {}
>>>
>>> private static class MyInnerClass
>>> {
>>> private void blah()
>>> {
>>> new Something(new SomethingElse()
>>> {
>>> });
>>> }
>>> }
>>>
>>> private static void doStuff()
>>> {
>>> new Foo<Bar<Baz>>() {
>>> @Override
>>> public void boz()
>>> {
>>> }
>>> };
>>>
>>
>> It appears to be related with this particular instance.
>>
>>> }
>>>
>>> public static void main(String[] args)
>>> {
>>> new Whatsit()
>>> {
>>> };
>>> }
>>> }
>>>
>>> then the example compiles fine with javac, but I still get the same
>>> IndexError with scons (both 2.3.1 and 2.4.0)
>>>
>>>
>>>
>>>
>>> On 7 October 2015 at 17:31, William Blevins <wblevins001 at gmail.com>
>>> wrote:
>>>
>>>>
>>>> On Wed, Oct 7, 2015 at 5:27 PM, William Blevins <wblevins001 at gmail.com>
>>>> wrote:
>>>>
>>>>> I just tried his sample with minimal tweaks, and I get a similar stack
>>>>> trace from SCons dev branch latest.
>>>>>
>>>>> On Wed, Oct 7, 2015 at 5:15 PM, Bill Deegan <bill at baddogconsulting.com
>>>>> > wrote:
>>>>>
>>>>>> Will,
>>>>>>
>>>>>> Can you try 2.4.0 or the default branch?
>>>>>> I checked your stack trace and the line numbers don't entirely match
>>>>>> up with current default, so its possible there are some changes which may
>>>>>> affect your issue, and if nothing else will make it easier to look at the
>>>>>> stacktrace/code.
>>>>>>
>>>>>> -Bill
>>>>>>
>>>>>> On Wed, Oct 7, 2015 at 12:04 PM, William Keith <wak at kaon.co.uk>
>>>>>> wrote:
>>>>>>
>>>>>>> Bill,
>>>>>>>
>>>>>>> I knew there was something I forgot to mention :)
>>>>>>>
>>>>>>> Version 2.3.1
>>>>>>>
>>>>>>> Will
>>>>>>>
>>>>>>> On 7 October 2015 at 16:50, Bill Deegan <bill at baddogconsulting.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Will,
>>>>>>>>
>>>>>>>> What version of SCons are you running?
>>>>>>>>
>>>>>>>> -Bill
>>>>>>>>
>>>>>>>> On Wed, Oct 7, 2015 at 11:10 AM, William Keith <wak at kaon.co.uk>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> I am trying to use SCons to build the following Java file:
>>>>>>>>>
>>>>>>>>> class MyApp
>>>>>>>>> {
>>>>>>>>> private static class MyInnerClass
>>>>>>>>> {
>>>>>>>>> private void blah()
>>>>>>>>> {
>>>>>>>>> new Something(new SomethingElse()
>>>>>>>>> {
>>>>>>>>> });
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> private static void doStuff()
>>>>>>>>> {
>>>>>>>>> new Foo<Bar<Baz>>() {
>>>>>>>>> @Override
>>>>>>>>> public void boz()
>>>>>>>>> {
>>>>>>>>> }
>>>>>>>>> };
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> public static void main(String[] args)
>>>>>>>>> {
>>>>>>>>> new Whatsit()
>>>>>>>>> {
>>>>>>>>> };
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> My SConstruct is as follows:
>>>>>>>>>
>>>>>>>>> app_classes = Java(target='build/classes', source='src',
>>>>>>>>> JAVAVERSION='1.7')
>>>>>>>>> jar_sources = app_classes
>>>>>>>>> Jar(target='build/target.jar', source=jar_sources)
>>>>>>>>>
>>>>>>>>> Running scons with the above results in an IndexError with the
>>>>>>>>> following stack trace:
>>>>>>>>>
>>>>>>>>> scons: Reading SConscript files ...
>>>>>>>>> IndexError: list index out of range:
>>>>>>>>> File "/home/projects/scons_java_test/SConstruct", line 7:
>>>>>>>>> app_classes = Java(target='build/classes', source='src',
>>>>>>>>> JAVAVERSION='1.7')
>>>>>>>>> File "/usr/lib/scons/SCons/Script/SConscript.py", line 609:
>>>>>>>>> return method(*args, **kw)
>>>>>>>>> File "/usr/lib/scons/SCons/Environment.py", line 224:
>>>>>>>>> return self.method(*nargs, **kwargs)
>>>>>>>>> File "/usr/lib/scons/SCons/Tool/javac.py", line 195:
>>>>>>>>> result.extend(b(t, s, *args, **kw))
>>>>>>>>> File "/usr/lib/scons/SCons/Environment.py", line 260:
>>>>>>>>> return MethodWrapper.__call__(self, target, source, *args,
>>>>>>>>> **kw)
>>>>>>>>> File "/usr/lib/scons/SCons/Environment.py", line 224:
>>>>>>>>> return self.method(*nargs, **kwargs)
>>>>>>>>> File "/usr/lib/scons/SCons/Builder.py", line 633:
>>>>>>>>> return self._execute(env, target, source, OverrideWarner(kw),
>>>>>>>>> ekw)
>>>>>>>>> File "/usr/lib/scons/SCons/Builder.py", line 554:
>>>>>>>>> tlist, slist = self._create_nodes(env, target, source)
>>>>>>>>> File "/usr/lib/scons/SCons/Builder.py", line 518:
>>>>>>>>> target, source = self.emitter(target=tlist, source=slist,
>>>>>>>>> env=env)
>>>>>>>>> File "/usr/lib/scons/SCons/Tool/javac.py", line 97:
>>>>>>>>> pkg_dir, classes = parse_java_file(f.rfile().get_abspath(),
>>>>>>>>> version)
>>>>>>>>> File "/usr/lib/scons/SCons/Tool/JavaCommon.py", line 286:
>>>>>>>>> return parse_java(open(fn, 'r').read(), version)
>>>>>>>>> File "/usr/lib/scons/SCons/Tool/JavaCommon.py", line 300:
>>>>>>>>> currstate = currstate.parseToken(token)
>>>>>>>>> File "/usr/lib/scons/SCons/Tool/JavaCommon.py", line 221:
>>>>>>>>> self.outer_state.addAnonClass()
>>>>>>>>> File "/usr/lib/scons/SCons/Tool/JavaCommon.py", line 178:
>>>>>>>>> self.__getAnonStack()[-1] = self.__getAnonStack()[-1] + 1
>>>>>>>>>
>>>>>>>>> Note that I have attempted to pare the example down to just what
>>>>>>>>> is essential to reproduce this issue. Apart from some missing symbols, it
>>>>>>>>> should be valid Java. The original (un-pared-down) version compiles cleanly
>>>>>>>>> with javac but produces the same exception in SCons' Java parser.
>>>>>>>>>
>>>>>>>>>
>>>> The missing symbols my actually be important here because SCons
>>>> requires parsing the *.java files in order to determine the *.java to
>>>> *.class input/output relationship. Java files often generate more than one
>>>> class file when compiled and these files need to be accounted for in the
>>>> dependency graph.
>>>>
>>>>
>>>>> I am fairly sure this is a new bug. Can someone please advise?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>>
>>>>>>>>> Will
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Scons-users mailing list
>>>>>>>>> Scons-users at scons.org
>>>>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Scons-users mailing list
>>>>>>>> Scons-users at scons.org
>>>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Scons-users mailing list
>>>>>>> Scons-users at scons.org
>>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Scons-users mailing list
>>>>>> Scons-users at scons.org
>>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Scons-users mailing list
>>>> Scons-users at scons.org
>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>
>>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20151007/9befe76c/attachment-0001.html>
More information about the Scons-users
mailing list