Repository navigation
Description
This issue was originally created at: 2006-06-07 13:20:01.
This issue was reported by: backblast.
backblast said at 2006-06-07 13:20:01
I've noticed that scons has some issues figuring out the right names for
anonymous classes, and in some simple sub classes I found a case where it labels
it as anonymous. I have the latest version as far as I can tell (which is much
better than the previous version BTW). I've looked at the code but I really
can't make heads or tails of the JavaCommon.py.With anonymous classes, scons mislabels nested anonymous classes.
Anonymous classes, including nested anonymous classes are labeled $1, $2, $3,
$4, etc by scons. The java compiler (build 1.5.0_06-b05) labels nested
anonymous classes $1$1, $1$2 and so on. There appears to be no support in the
parsing for recognizing these nested anonymous classes.
backblast said at 2006-06-07 13:35:30
Created an attachment (id=54)
Failing anonymous class example.
backblast said at 2006-06-07 13:45:46
Created an attachment (id=55)
Nested anonymous class Example
toaster said at 2007-02-19 07:44:27
I have exact the same problem here. It leads to unnecessary rebuilds.
My scons version: 0.96.94. A patch would be great :).
stevenknight said at 2007-02-19 10:50:45
Have nested anonymous classes always been named in this way, or is this specific
to only some versions of the Java compiler?
stevenknight said at 2007-02-19 11:40:36
Okay, I just tested Brandon's example using javac from j2sdk1.4.2, and it
generates the files that SCons is expecting (NestedExample.class,
NestedExample$1.class and NestedExample$2.class), so this is apparently behavior
that's changed in 1.5? Can someone with Java knowledge confirm this?In the meantime, I'm changing the Summary line to be more descriptive.
toaster said at 2007-02-19 22:41:31
I tested with Java 1.4, 1.5 and 1.6.
You are right: the behaviour changed to Java 1.5.
I could not find a document on java.sun.com which mentions this.
toaster said at 2007-03-07 00:39:10
Created an attachment (id=140)
Patch to do Java 1.5 naming
toaster said at 2007-03-07 00:40:52
Created an attachment (id=141)
TestCase with nested inner/anon classes
toaster said at 2007-03-07 00:46:03
Hi,
I attached a patch for JavaCommon.py to do the Java 5 naming.
It is totally a hack. IMHO the parser should be refactored because it is too
hard to handle nested blocks.
Also it should be somehow configurable which naming (1.4/5) should be used.
But I have not the time to do it :).I have also attached a test case with multiple nested inner/anon classes.
toaster said at 2007-03-07 02:41:39
Created an attachment (id=142)
Patch to do Java 1.5 naming
toaster said at 2007-03-07 02:44:53
The patch from attachement 140 did not work in real life :).
I patched the patch ;) and attachement 142 worked for me in real life and with
the test environment.
stevenknight said at 2007-03-07 06:37:00
Hi Tilo--
Thanks for the patch, I agree that some refactoring in the parser would be good.
Integrating this patch will have to wait until someone can make it
configurable, of course, since we obviously can't break the 1.4 support. But
this should, I hope, give someone a head start in making that happen.Thanks again,
--SK
stevenknight said at 2007-05-26 20:16:12
Target for 0.97.1.
stevenknight said at 2007-05-26 20:16:51
Forgot to make it blocking for the release task.
stevenknight said at 2007-07-13 14:19:05
Fix has been checked in for next release, that merges Tilo's code with the
existing behavior.The behavior is controlled by a new $JAVAVERSION variable, which can be set to
'1.5' (or '1.6') to specify the Java version being used, in which case the
emitter uses Tilo's code to generate the new .class file names.Many thanks for the patch.
Votes for this issue: 10.
backblast attached Example.java at 2006-06-07 13:35:30.
Failing anonymous class example.
backblast attached NestedExample.java at 2006-06-07 13:45:46.
Nested anonymous class Example
toaster attached JavaCommon.py.patch2 at 2007-03-07 00:39:09.
Patch to do Java 1.5 naming
toaster attached Test.java at 2007-03-07 00:40:52.
TestCase with nested inner/anon classes
toaster attached JavaCommon.py.patch2 at 2007-03-07 02:41:39.
Patch to do Java 1.5 naming
stevenknight said this issue blocks #1664 at 2007-05-26 20:16:51.
Activity