[Scons-users] JavaH builder doesn't get output file names right for inner classes
Abigail Bunyan
abigail.bunyan at microsoft.com
Mon Feb 20 12:40:24 EST 2017
This is the case with both OpenJDK 7 and OpenJDK 8, specifically:
* javah full version "1.8.0_121-8u121-b13-0ubuntu1.16.10.2-b13"
* javah full version "1.7.0_95-b00"
(These are the versions available in the Ubuntu 16.10 (yakkety) packages
openjdk-7-jdk and openjdk-8-jdk-headless, respectively.)
On Mon, Feb 20, 2017 at 11:45 AM, Bill Deegan wrote:
> 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.
More information about the Scons-users
mailing list