NativeJava

From FedoraProject

Revision as of 11:45, 3 June 2011 by Akurtakov (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Stop (medium size).png
CAUTION
Information here is badly outdated and following these steps is not recommended by Fedora Java SIG


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.

  • For packages in which all jarfiles are in the main package:
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}
  • For packages in which all jarfiles are in one subpackage the Requires(), %post, %postun and %files lines should refer to that subpackage.
  • For packages in which more than one subpackage (including the main package) contains jarfiles then each subpackage should have its own Requires(), %post and %postun lines, and the %files lists should be split such that the subpackage that contains /path/to/foo-x.y.z.jar should have the following %files line:

%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 .)