[Scons-users] IndexError in Java parser with anonymous classes

William Keith wak at kaon.co.uk
Wed Oct 7 12:30:22 EDT 2015


Bill,

Same result with 2.4.0, stack trace is marginally different:

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 "/opt/scons/lib/scons-2.4.0/SCons/Script/SConscript.py", line 614:
    return method(*args, **kw)
  File "/opt/scons/lib/scons-2.4.0/SCons/Environment.py", line 224:
    return self.method(*nargs, **kwargs)
  File "/opt/scons/lib/scons-2.4.0/SCons/Tool/javac.py", line 195:
    result.extend(b(t, s, *args, **kw))
  File "/opt/scons/lib/scons-2.4.0/SCons/Environment.py", line 260:
    return MethodWrapper.__call__(self, target, source, *args, **kw)
  File "/opt/scons/lib/scons-2.4.0/SCons/Environment.py", line 224:
    return self.method(*nargs, **kwargs)
  File "/opt/scons/lib/scons-2.4.0/SCons/Builder.py", line 626:
    return self._execute(env, target, source, OverrideWarner(kw), ekw)
  File "/opt/scons/lib/scons-2.4.0/SCons/Builder.py", line 547:
    tlist, slist = self._create_nodes(env, target, source)
  File "/opt/scons/lib/scons-2.4.0/SCons/Builder.py", line 511:
    target, source = self.emitter(target=tlist, source=slist, env=env)
  File "/opt/scons/lib/scons-2.4.0/SCons/Tool/javac.py", line 97:
    pkg_dir, classes = parse_java_file(f.rfile().get_abspath(), version)
  File "/opt/scons/lib/scons-2.4.0/SCons/Tool/JavaCommon.py", line 286:
    return parse_java(open(fn, 'r').read(), version)
  File "/opt/scons/lib/scons-2.4.0/SCons/Tool/JavaCommon.py", line 298:
    currstate = currstate.parseToken(token)
  File "/opt/scons/lib/scons-2.4.0/SCons/Tool/JavaCommon.py", line 221:
    self.outer_state.addAnonClass()
  File "/opt/scons/lib/scons-2.4.0/SCons/Tool/JavaCommon.py", line 178:
    self.__getAnonStack()[-1] = self.__getAnonStack()[-1] + 1

Will

On 7 October 2015 at 17:15, 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.
>>>>
>>>> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20151007/f2acf717/attachment.html>


More information about the Scons-users mailing list