[Scons-users] JavaH builder doesn't get output file names right for inner classes

Bill Deegan bill at baddogconsulting.com
Mon Feb 20 11:45:41 EST 2017


Which version of Java?

On Mon, Feb 20, 2017 at 3:23 AM, Abigail Bunyan via Scons-users <
scons-users at scons.org> wrote:

> Given a Java source file like:
>
>     class Outer {
>         class Inner {
>             public native void f();
>         }
>     }
>
> javac will create Outer.class and Outer$Inner.class, but javah will create
> Outer.h and Outer_Inner.h. However, the SCons JavaH builder expects it to
> create Outer$Inner.h, leading to unnecessary rerunning of javah:
>
>     $ echo "JavaH('jni', 'Outer.java')" > SConstruct
>     $ scons -Q --debug=explain
>     scons: building `Outer/Outer$Inner.class' because it doesn't exist
>     javac -d Outer -sourcepath . Outer.java
>     scons: building `jni/Outer$Inner.h' because it doesn't exist
>     javah -d jni -classpath Outer Outer Outer
>     $ ls jni
>     Outer.h Outer_Inner.h
>     $ scons -Q --debug=explain
>     scons: building `jni/Outer$Inner.h' because it doesn't exist
>     javah -d jni -classpath Outer Outer Outer
>
> This issue can also cause builds to fail due to the missing dependency:
>
>     $ echo '#include "jni/Outer_Inner.h"' > Outer_Inner.c
>     $ echo 'Library("outer", ["outer.c"])' >> SConstruct
>     $ rm -rf jni/ Outer/ && scons -Q
>     javac -d Outer -sourcepath . Outer.java
>     gcc -o outer.o -c outer.c
>     outer.c:1:29: fatal error: jni/Outer_Inner.h: No such file or directory
>      #include "jni/Outer_Inner.h"
>                                  ^
>     compilation terminated.
>     scons: *** [Outer_Inner.o] Error 1
>
> This is occurring under SCons v2.5.1.
> _______________________________________________
> 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/20170220/d15f6ece/attachment.html>


More information about the Scons-users mailing list