[Scons-users] java problems
Mats Wichmann
mats at wichmann.us
Tue Dec 12 15:32:54 EST 2017
Had a little discussion on IRC about a problem we're having with java,
bringing it here to the list.
The problem is summarized as follows:
* a piece of example code has two source files in a directory,
Light.java, Simpleserver.java
* invoking Java() results in six class files, namely:
Light.class Light$1.class Light$2.class Light$3.class
SimpleServer.class SimpleServer$1.class
* the code saves the result returned by Java(), which is a list with
only five nodes in it, the one for Light$3.class is omitted
* this saved result is used as input to Jar(), resulting in a jarfile
that is not complete, and the example does not run.
The short sconscript snippet that does this is:
simpleserver_classes = jdk_env.Java(target='classes',
source=['src/main/java'])
simpleserver_classes.append('MANIFEST.MF')
example_jar = jdk_env.Jar(target='simpleserver.jar',
source=simpleserver_classes)
This whole scenario sounds similar to
http://scons.tigris.org/issues/show_bug.cgi?id=1594, which is not a new bug.
The source files are here:
https://github.com/iotivity/iotivity/tree/master/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples
I'm not wise enough in the ways of Java to see where the third Light
inner class is even coming from. If I'm not wrong, I see two in the form
of anonymous classes where Runnable is being extended here (line 160):
160 new Thread(new Runnable() {
161 public void run() {
162 handleSlowResponse(request);
163 }
164 }).start();
and here (line 245):
245 mObserverNotifier = new Thread(new Runnable() {
246 public void run() {
247 notifyObservers(request);
248 }
249 });
Is this a different bug than 1594? The conditions are not the same, but
the outcome - javac generates more classes than is being expected by
scons - seems to be.
(I'm using java 8, others seeing this issue have used 6 and 7)
More information about the Scons-users
mailing list