Skip to content

Commit

Permalink
Add userguide update on javah as well
Browse files Browse the repository at this point in the history
Also add more linux locations for Java headers (old saved patch)

Signed-off-by: Mats Wichmann <mats@linux.com>
  • Loading branch information
mwichmann committed Nov 5, 2021
1 parent 027c15f commit 1716ce5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ RELEASE 3.1.0 - Mon, 20 Jul 2019 16:59:23 -0700
From Lukas Schrangl:
- Enable LaTeX scanner to find more than one include per line

From Sergey Torokhov:
- Recognize jdk on Gentoo systems.

From Mats Wichmann:
- scons-time takes more care closing files and uses safer mkdtemp to avoid
possible races on multi-job runs.
Expand Down
7 changes: 5 additions & 2 deletions SCons/Tool/JavaCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,17 @@

java_linux_include_dirs_glob = [
'/usr/lib/jvm/default-java/include',
'/usr/lib/jvm/java-*/include'
'/usr/lib/jvm/java-*/include',
'/opt/oracle-jdk-bin-*/include',
'/opt/openjdk-bin-*/include',
'/usr/lib/openjdk-*/include',
]
# Need to match path like below (from Centos 7)
# /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64/include/
java_linux_version_include_dirs_glob = [
'/usr/lib/jvm/java-*-sun-%s*/include',
'/usr/lib/jvm/java-%s*-openjdk*/include',
'/usr/java/jdk%s*/include'
'/usr/java/jdk%s*/include',
]

if java_parsing:
Expand Down
35 changes: 24 additions & 11 deletions doc/user/java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Java('classes', 'src', JAVAVERSION='1.6')
After building the class files,
it's common to collect them into
a Java archive (<filename>.jar</filename>) file,
which you do by calling the &b-link-Jar; Builder method.
which you do by calling the &b-link-Jar; Builder.
If you want to just collect all of the
class files within a subdirectory,
you can just specify that subdirectory
Expand Down Expand Up @@ -488,8 +488,8 @@ public class Example3

Although it's more convenient to use
the list of class files returned by
the &b-Java; Builder
as the source of a call to the &b-JavaH; Builder,
the &b-link-Java; Builder
as the source of a call to the &b-link-JavaH; Builder,
you <emphasis>can</emphasis>
specify the list of class files
by hand, if you prefer.
Expand All @@ -502,11 +502,13 @@ public class Example3

<scons_example name="java_JAVACLASSDIR">
<file name="SConstruct" printme="1">
Java(target = 'classes', source = 'src/pkg/sub')
class_file_list = ['classes/pkg/sub/Example1.class',
'classes/pkg/sub/Example2.class',
'classes/pkg/sub/Example3.class']
JavaH(target = 'native', source = class_file_list, JAVACLASSDIR = 'classes')
Java(target='classes', source='src/pkg/sub')
class_file_list = [
'classes/pkg/sub/Example1.class',
'classes/pkg/sub/Example2.class',
'classes/pkg/sub/Example3.class',
]
JavaH(target='native', source=class_file_list, JAVACLASSDIR='classes')
</file>
<file name="src/pkg/sub/Example1.java">
package pkg.sub;
Expand Down Expand Up @@ -560,8 +562,8 @@ public class Example3

<scons_example name="java_javah_file">
<file name="SConstruct" printme="1">
classes = Java(target = 'classes', source = 'src/pkg/sub')
JavaH(target = File('native.h'), source = classes)
classes = Java(target='classes', source='src/pkg/sub')
JavaH(target=File('native.h'), source=classes)
</file>
<file name="src/pkg/sub/Example1.java">
package pkg.sub;
Expand Down Expand Up @@ -595,7 +597,7 @@ public class Example3
<para>

Because &SCons; assumes by default
that the target of the &b-JavaH; builder is a directory,
that the target of the &b-link-JavaH; builder is a directory,
you need to use the &File; function
to make sure that &SCons; doesn't
create a directory named <filename>native.h</filename>.
Expand All @@ -609,6 +611,17 @@ public class Example3
<scons_output_command>scons -Q</scons_output_command>
</scons_output>

<para>

Note that the the <command>javah</command> command was
removed from the JDK as of JDK 10, and the approved method
(available since JDK 8) is to use <command>javac</command>
to generate native headers at the same time as the Java source
code is compiled.. As such the &b-link-JavaH; builder
is of limited utility in later Java versions.

</para>

</section>

<section>
Expand Down

0 comments on commit 1716ce5

Please sign in to comment.