NativeJava

From FedoraProject

Jump to: navigation, search

Like other Java runtimes, libgcj can load classes from bytecode class files. Unlike other Java runtimes, libgcj can also load classes that have been compiled to native machine code using GCJ. As you might expect, code sourced from native classes executes much faster than code sourced from bytecode classes.

Many of the Java packages in Fedora contain native code in addition to the usual bytecode. If you have a package that doesn't, then adding it is simple.

1. Remove the following if present:
BuildArch: noarch
2. Add the following dependencies:
BuildRequires:    java-gcj-compat-devel >= 1.0.31
Requires(post):   java-gcj-compat >= 1.0.31
Requires(postun): java-gcj-compat >= 1.0.31
3. Add the following to the end of %install section:
%{_bindir}/aot-compile-rpm
4. If the package has no %post section then add the following after the %install section:
%post
if [ -x %{_bindir}/rebuild-gcj-db ] 
then
%{_bindir}/rebuild-gcj-db
fi
If the package does have a %post section then just add the rebuild-gcj-db line to it. 5. If the package has no %postun section then add the following after the %post section:
%postun
if [ -x %{_bindir}/rebuild-gcj-db ] 
then
%{_bindir}/rebuild-gcj-db
fi
If the package does have a %postun section then just add the rebuild-gcj-db line to it. 6. Add the following to the %files section:
%attr(-,root,root) %{_libdir}/gcj/%{name}

%attr(-,root,root) %{_libdir}/gcj/%{name}/foo-x.y.z.jar.*

Note that the path has been stripped and .* has been appended.

(These instructions extend and replace the earlier aot-compile-rpm HOWTO .)