Development/Java

From The Document Foundation Wiki
Jump to: navigation, search

LibreOffice contains various pieces of code written in Java. Some of these pieces are currently being replaced/rewritten, but it is likely that LibreOffice will contain Java code for quite some time.

What pieces of LibreOffice are written in Java?

Some basic GNU/Linux tools can be run over the source code to report on various aspects relating to Java usage. Each example command below has been run against an extracted copy of the v4.2.6.3 archived (tar/7z) source tree.

Which directories contain *.java files?

It is worth routing the output from the find command to a text file for later (as required) post-processing.

$ find libreoffice-4.2.6.3 -type f -name "*.java" > LOv4263_find_java.txt
$ sed -e 's/^libreoffice-4.2.6.3\///' -e 's/[^/]*.java$//' -e 's/\([^/]\/\).*/\1/' LOv4263_find_java.txt | awk '!x[$0]++' | sort

Output from the above sed/awk/sort commands gives only the first level directory:

accessibility/
android/
bean/
bridges/
chart2/
cli_ure/
codemaker/
comphelper/
connectivity/
cppuhelper/
dbaccess/
desktop/
embeddedobj/
extensions/
external/
filter/
forms/
framework/
javaunohelper/
jurt/
jvmaccess/
jvmfwk/
linguistic/
nlpsolver/
odk/
package/
qadevOOo/
reportbuilder/
reportdesign/
ridljar/
sc/
scripting/
sfx2/
smoketest/
sot/
stoc/
svl/
sw/
swext/
testtools/
toolkit/
ucb/
unotest/
unotools/
unoxml/
ure/
vcl/
wizards/
xmerge/
xmlsecurity/

Note though that very little of this Java code is actually part of the shipped product. Most of these lines of code are actually only testcode from the $MODULE/qa subdirectory. A more relevant analysis would exclude that subdirectories as they are never shipped with the product. Doing this on a ~recent checkout of master@64914e407ccac91fbbaa5022a6854be9a01027f8:

find . -type f -name "*.java" |grep -v workdir |grep -v instdir |grep -v '\/qa\/' |grep -v '\/test\/'> lo_find_java.txt
sed -e 's/^.\///' -e 's/[^/]*.java$//' -e 's/\([^/]\/\).*/\1/' lo_find_java.txt | awk '!x[$0]++' | sort

shows (with some resorting) this:

android/       # android port -- not part of the core product
 
bridges/       # modules that provide the bridge to Java itself -- little to no LibreOffice core functionality by itself
javaunohelper/
jurt/
jvmaccess/
jvmfwk/
odk/
ridljar/
ure/
 
qadevOOo/      # various forms of integration tests -- little to no LibreOffice core functionality by itself
smoketest/
testtools/
xmlsecurity/
 
bean/          # extensions and scripting -- little to no LibreOffice core functionality by itself
nlpsolver/
reportbuilder/
scripting/
swext/
xmerge/
 
wizards/       # seems to be dead code only really by now
filter/
 
external/      # third-party code not maintained by LibreOffice
 
connectivity/  # remaining core functionality -- mostly hsqldb 1.8 driver for LibreOffice Base default database (<5 KLOC)

For a comprehensive list of directories:

$ sed -e 's/^libreoffice-4.2.6.3\///' -e 's/[^/]*.java$//' LOv4263_find_java.txt | awk '!x[$0]++' | sort

Output (first few lines) from the above sed/awk/sort commands:

accessibility/bridge/org/openoffice/accessibility/
accessibility/bridge/org/openoffice/java/accessibility/
accessibility/bridge/org/openoffice/java/accessibility/logging/
android/abs-lib/src/android/support/v4/app/
android/abs-lib/src/com/actionbarsherlock/
android/abs-lib/src/com/actionbarsherlock/app/

For the complete list, please see Development/Java/Directories containing .java files

How many lines of java source code in each main directory?

It is worth routing the output from sloccount to a text file for later (as required) post-processing.

$ sloccount libreoffice-4.2.6.3 > LOv4263_sloccount.txt
$ grep -Po "^[0-9]{1,6}[ ]*[a-z0-9]*[ ]*[^ ]*?java=[^,]*" LOv4263_sloccount.txt | sed -e 's/^........//' -e 's/\(\([a-z]\{2,6\}=[0-9]\{1,6\},\)*\)\?java/java/' | sort

Output from above grep/sed/sort commands:

accessibility   java=8212
android         java=28887
bean            java=3691
bridges         java=5707
chart2          java=754
codemaker       java=579
comphelper      java=478
connectivity    java=3234
cppuhelper      java=239
dbaccess        java=3146
desktop         java=627
embeddedobj     java=2100
extensions      java=900
external        java=91
filter          java=1288
forms           java=4655
framework       java=6169
javaunohelper   java=7243
jurt            java=8604
jvmaccess       java=56
jvmfwk          java=54
linguistic      java=278
nlpsolver       java=2989
odk             java=35604
package         java=9158
reportbuilder   java=15862
reportdesign    java=402
ridljar         java=2567
sc              java=2292
scripting       java=20011
sfx2            java=3722
smoketest       java=156
sot             java=176
stoc            java=115
svl             java=434
swext           java=3221
sw              java=5125
testtools       java=1620
toolkit         java=10334
ucb             java=1344
unotest         java=650
unotools        java=366
unoxml          java=3100
ure             java=143
vcl             java=772
wizards         java=34752
xmerge          java=8894
xmlsecurity     java=142

Java use (as a percentage) in each LibreOffice end-of-train release, is also available in the Ask thread Is there any plan to ditch Java in the future and use only C/C++ code?. Note though that very little of this Java code is actually part of the shipped product. Most of these lines of code are actually only testcode from the $MODULE/qa subdirectory. A more relevant analysis would exclude that subdirectories as they are never shipped with the product.

Which directories contain *.jar files?

$ find libreoffice-4.2.6.3 -type f -name "*.jar" | sed -e 's/^libreoffice-4.2.6.3\///'

Output from above find/sort commands:

qadevOOo/testdocs/qadevlibs/JobExecutor.jar
qadevOOo/testdocs/qadevlibs/MyPersistObjectImpl.jar

Building LibreOffice without Java

Compile LibreOffice with the flag --without-java

Suggestion to Remove Java Components

Per Development/Crazy Ideas,

Some think java is a slow memory hog, others think it is a legal swamp that invites lawsuits. Neither might be true, but some developers have nevertheless expressed their desire to remove Java usage in LO over time.

More notes:


Resources