Stormin' the coffee cup with Apache Harmony
Tim Ellison Apache Harmony Project
http://harmony.apache.org
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 2http://harmony.apache.org
Join me during the next 45 mins to…
Learn about the motivations, current status, and future plans of the Apache Harmony project.
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 3http://harmony.apache.org
Agenda
Project History
Development Model
Code and Runtime Modularity
How Are We Doing?
Demo
Harmony and the JCK
Wrap-up
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 4http://harmony.apache.org
Apache Harmony – a brief history
Primary goals1. Protect IP rights of the Java ecosystem.
2. Independent implementation of virtual machines, related class libraries, and other software commonly associated with Java platform implementations.
3. Community-developed, modular architecture allowing sharing and innovation.
2005 2006 2007 2008
Harmony established in Apache incubator
May 2005
IBM contributes core classesand binary VM license
November 2005
Intel contributesVM/JIT/GC/classlib
code
January 2006…
Established legal frame- work around Harmony
No code Subset of 1.4 / 5.0 >99% 5.0, >90% 6.0
Java 6 work started
March 2006
Open letter to Sunfor JCK 5
April 2007Harmonygraduates
as top level project
October 2006
Day to day developmentcorrectness, completeness, performance, …
ME code contribution
April 2008
1 52 3 4
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 5http://harmony.apache.org
• Contributors detail their prior access via a projectquestionnaire.
• Developers can contribute in functional areas wherethey have not studied closed-source implementations (exceptions apply).
• Existing code being contributed to the project must provide acceptable pedigree information.
See: http://harmony.apache.org/auth_cont_quest.html
Enhanced IP-cleanliness
This is in addition to the standard Apache contribution processes
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 6http://harmony.apache.org
Bootstrapping the project
• Establish a common goal• compliant and compatible Java SE 5 implementation
• JVM contributions• initial VM implementations, … from Cobbs and Lydick
• DRLVM, … from Intel
• Class library code contributions• core lang, util, net, IO, beans, … from IBM
• security, print, sound, awt, swing, … from Intel
• math, rmi, … from National University of Cordoba, Argentina
• Production-quality VMs for build and test• IBM J9 and BEA JRockit made available to project
● Used for development● Not under open source license, not a contribution
© javic flickr.com/photos/javic
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 7http://harmony.apache.org
Agenda
Project History
Development Model
Code and Runtime Modularity
How Are We Doing?
Demo
Harmony and the JCK
Wrap-up
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 8http://harmony.apache.org
Producing a compliant implementationSpec-driven development
• Implementing the Java specifications as found in• Java SE platform Javadoc• Java Programming Language Specification• Java Virtual Machine (JVM) Specification, etc.
• Ambiguities and omissions...• resolved by consulting the Reference Implementation• determined by functional API testing
Writing Unit Tests
Specification Reading
Post intentions on the dev list
Send patch anddiscuss problems on
dev list
Writing implementation
iterative
progress
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 9http://harmony.apache.org
Producing a robust, compatible implementationTest-driven development
• Functional testing• API tests, internal interfaces tests,
bug regression tests• Component oriented
• Integration testing• Build verification, test with different VMs• Component assembly oriented
• Application / System testing• Running popular applications, ad hoc and test suites• End-product and compatibility oriented
• Platform, Performance and Stress testing• Multi-platform continuous integration, performance / stress suites• Robustness and quality oriented
until proven innocent
all code is guilty
©B Tal, flickr.com
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 10http://harmony.apache.org
/classlib– the class library code
/drlvm– the VM, JIT, GC
/jdktools– Java technology development tools (javac, javah, javap, ...)
/trunk– federation point (builds everything together)
Project repository organizationJava 5 code base is >1.5 Million
non-comment lines of code
0
200
400
600
800
1000
1200
Class library DRLVM Toolskl
oc
other
C/C++
Java
generated using David A. Wheeler's 'SLOCCount'
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 11http://harmony.apache.org
Bringing it all togetherFederated workspace build
• Uses svn switch “trick” to assemble source code
• Downloads project dependencies
• Running “ant” results in complete HDK, Java Development Kit (JDK) and Java Runtime Environment (JRE)
• Can work in any directory (svn commit does the Right Thing)
• ant -Dsvn.revision=X builds any SVN revision
/trunk build.xml /working_classlib -> /classlib /working_vm -> /<your favorite vm> /working_jdktools -> /jdktools /current_resources -> /current_resources
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 12http://harmony.apache.org
Heterogeneous build and test farm across communityDistributed build-test
@
bug tracker
committers
GIT | Quilt | ?
Check out
Patches Continuous integration and test
by community’s heterogeneous
build farm
Notify
SVN Server
contributors
Check in/out
Apache infrastructure
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 13http://harmony.apache.org
Agenda
Project History
Development Model
Code and Runtime Modularity
How Are We Doing?
Demo
Harmony and the JCK
Wrap-up
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 14http://harmony.apache.org
Trace JITcompiler Interpreter
Memorymanager
Threadmanager
VM
XML NIO
beans
nativecode
JavaNative
Interface (JNI™)
Portability Layer
Hardware / Operating System
VMI (C)
securityJava SE class libraries
Java SE Platform API
Launcher
Class library
Kernel classes (Java class files)
Everything is pluggableArchitectural overview
langutilnetio
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 15http://harmony.apache.org
Harmony DRLVM – the Java Virtual Machine
• Core interpreter• Bytecode verifier, class file loading / unloading, debug interface, JVMTI etc.
• Just in Time compilers• profiling engine selects compiler based on typical code paths, data values, …
• “JET” fast compiler
• ~14K NSLOC, ~10-20K methods/sec, resulting code 10x faster than interpreter
• “OPT” optimizing compiler
• multiple code transformations, resulting code 2x faster than JET
• Memory managers
• “GCv4” stop the world, sequential copying compacting
• “GCv5” stop the world, parallel copying compacting generational
• “Tick” on the fly, concurrent mark, parallel, mark-sweep-compact generational
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 16http://harmony.apache.org
Code execution and memory managementVirtual Machine modularity
• Well-defined interfaces, consistent across platforms
• Interfaces do not compromise runtime performance
• Modules either build-time or runtime replaceable
• Multiple implementations already exist for some modules
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 17http://harmony.apache.org
Virtual Machine Interface to the class librariesHarmony’s VMI
• VM-specific ‘kernel’ classes• 23 publicly defined Java SE types that the VM typically knows intimately, plus one helper
• Access to our C struct from JavaVM / JNIEnv pointers
• 10 new C functions that augment standard JNI
• The VMI provides:
• Access to the operating system abstraction library (port library)
• Access to per-VM storage functions (VMLS) which allows multiple VMs to exist in a single address space
• Ability to get/set/iterate system properties
• The VMI does not :
• Require any enhanced VM/class library linkage
• Prescribe object layout, garbage collection, synchronization, and so on
class libraries
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 18http://harmony.apache.org
Java SE platform implemented in ~30 componentsClass library modularization
• A module…
• is related functionality scoped by Java packages
• ‘exports’ user-API and internal-API, hides private internal implementation
• defined by dependenciesin the Java specification
• minimizes coupling byexplicit internal APIs
• is delivered as a JAR file, a real OSGi bundle
XML NIO
Beans
Class LibraryNativeCodeVMI (C) JNI APIKernel classes (Java class files)
langutilnetio
Security
Java SE Platform 5 API
• Observed benefits• easier to manage prior exposure• freedom of assembly for module consumers• unit of replacement for fixes and updates• facilitates contributions
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 19http://harmony.apache.org
The Harmony Development Kit (“HDK”)Development time modularity
• Not a replacement for JDK software• HDK Harmony developers :: JDK software Java developers
• Contains all files necessary for Harmony development and testing
• Enables fast rebuild of individual modules – Java platform and native
• Removes necessity to check out whole source tree
• Supports separate or in-place development of HDK trees
$ svn co http://... modules/nio$ cd modules/nio$ ant -DHY.HDK=path/to/hdk -DHY.TARGET=path/to/target
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 20http://harmony.apache.org
rt.jar
Software assembliesPackaging Modularity
AppletAWT
BeansLUNIAnnotation
InstrumentLang-mgmt
MathNIONIO_char
SecuritySQL
TextConcurrent
ArchiveLogging
Prefsjsse.jar
jce.jar…
prefs.jar +prefs-src.jar +hyprefs.dll
Harmony’s approachConventional approach
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 21http://harmony.apache.org
Multi-configuration support
• Harmony modules can be easily configured:
– Apache Harmony : builds all modules into Java 5 and Java 6 configurations
– IBM Java 6 SE : a number of modules sourced from Harmony
– Android : core libraries adapted to run on Dalvik VM
“Right sized” application runtimes
Harmony IBM Java 6 Android
accessibility annotation applet archive auth awt beans concurrent crypto imageio instrument jndi lang-management logging luni math nio nio_char pack200 prefs print regex rmi security sound sql swing text xml Xerces kXMLx-net
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 22http://harmony.apache.org
Multi-VM and tools launcherRuntime modularity
• Single native launcher program
• Runs command-line Java technology programs, including generic launcher and JDK software tools
• Select VM provider based on command-line option
• Select runtime specified modules (e.g. GC algorithm)
jre/bin/ java.exe default/ drlvm-v1/ drlvm-v2/ ibm-j9/$ java MyClass$ java –vmdir:ibm-j9 MyClass$ java –vmdir:drlvm-v1 MyClass
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 23http://harmony.apache.org
Agenda
Project History
Development Model
Code and Runtime Modularity
How Are We Doing?
Demo
Harmony and the JCK
Wrap-up
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 24http://harmony.apache.org
• Completeness “heat map” courtesy of JAPI tool• compares API compatibility
• Over 99% 1.5 API complete
• Missing functionality is now primarily in…• providers
● sound formats encoding / decoding● Kerberos authentication
• command-line tools● appletviewer, javaws, jstack, native2ascii,
serialver, etc.
See: http://kaffe.org/~stuart/japi
Our original goal - Java SE platform 5API completeness
October 2008
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 25http://harmony.apache.org
• Harmony suites: • Class library unit tests
• DRL VM unit and regression tests
• Functional test suite
• JDKTools unit tests
• Reliability test suite
• Stress test suite
• VM Validation test suite
• Application scenarios:• Apache Ant scenario
• Apache Axis2 client-server scenario
• Apache Struts scenario
• Apache Tomcat scenario
• Dacapo benchmark
• Eclipse hello world application
• Eclipse Geronimo application
• JEdit scenario
• Jetty scenario
• LDAP scenario
• Scimark benchmark
testing, bug fixing, metrics, ...Code quality
• External test suites: •Apache Ant 1.7.0 unit tests
•Apache Maven unit tests
•Eclipse unit tests.
•Eclipse TPTP tests
•Geronimo unit tests.
•JUnit tests
•Mauve test suite
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 26http://harmony.apache.org
Performance
Blackburn, S. M., et al The DaCapo Benchmarks: Java Benchmarking Development and Analysis, OOPSLA '06: Proceedings of the 21st annual ACM SIGPLAN conference on Object-Oriented Programming, Systems, Languages, and Applications, (Portland, OR, USA, October 22-26, 2006)
Source: http://www.dacapobench.org
2008-11-01dacapo-2006-10-MR2
Tracked by DaCapo performance benchmarks
Key:
worst result
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 27http://harmony.apache.org
• Community builds, tests, and reports results on :• x86 Windows 2000, Windows XP• x86 Debian, SUSE9, RHEL AS 4, Ubuntu 6• x86_64 SUSE 9, RHEL AS 4, Ubuntu 6
• Known work in progress on :• Itanium Linux and Windows• PPC 32bit / 64bit Linux and AIX• x86 Mac OS X and FreeBSD• zSeries 31bit / 64 bit zLinux and zOS
• Interested in other platforms? Us too!
Write once, debug everywhere!Multi-platform support
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 28http://harmony.apache.org
DEMO
• Harmony in action
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 29http://harmony.apache.org
Agenda
Project History
Development Model
Code and Runtime Modularity
How Are We Doing?
Demo
Harmony and the JCK
Wrap-up
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 30http://harmony.apache.org
Apache’s JCK issue with Sun
• First request for Java SE JCK v5 - August 2006• As per changes to agreement in JSPA, the “Apache Compromise”
• Sun offer JCK with FoU restrictions – 3Q2006 / 1Q2007• Limits how users can use compliant software, ASF reject as not allowing
distribution under ALv2.
• Open Letter from ASF to Sun – April 2007• Appeal directly to Schwartz gets no response.
• ASF position on the JCP – August 2007• The ASF will vote “no” on any proposal involving:
× JCP lead who is not complying with the JSPA
× JSRs where the TCK-license contains FoU restrictions
• Java ME & SE/EE Executive Committees• Originally raised with EC back in February 2007
• In August 2007 Apache raised a motion…
+
His
tor
y
©speakuplibrarian
Used with permission
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 31http://harmony.apache.org
What do the JCP ECs think about it?
The chair reported the results of an electronic vote on a motion proposed by Apache and seconded by Intel addressing the use of Field Of Use clauses in TCK licenses. The text of the motion was:
"TCK licenses must not be used to discriminate against or restrict compatible implementations of Java specifications by including field of use restrictions on the tested implementations or otherwise. Licenses containing such limitations do not meet the requirements of the JSPA, the agreement under which the JCP operates, and violate the expectations of the Java community that JCP specs can be openly implemented."
The results were:
ME EC: 13 in favor, 1 against, 2 ineligible to voteSE/EE EC: 13 in favor, 1 against, 2 ineligible to vote
The Chair informed the EC that the PMO will take no further action on this motion.
http://jcp.org/aboutJava/communityprocess/summaries/2007/September07-summary.html
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 32http://harmony.apache.org
Apache’s JCK issue with Sun +
• Current position• Sun have offered new terms for the JCK, that are still
unacceptable.
• Contains FoU limitations on ASF’s usage of the JCK (rather than downstream user restrictions).
• This would allow us to redistribute under ALv2.
• However, terms contain the requirement for an ‘official’ notice from Sun regarding IP notice and certification requirements – effectively a de facto augmentation of the Apache License, and therefore unacceptable.
Apache does not make statements regarding intellectual property
other than facts we explicitly know to be true and are thereby
disclosed in Notice files and the Apache License.
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 33http://harmony.apache.org
Agenda
Project History
Development Model
Code and Runtime Modularity
How Are We Doing?
Demo
Harmony and the JCK
Wrap-up
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 34http://harmony.apache.org
The best is yet to come...Summary
• We invested time up-front getting the IP infrastructure right.
• Rapidly approaching a full compatible, open-source, implementation of Java SE.
• The core code has been picked up and used in non-trivial commercial runtimes.
• Our modularity story has given usflexibility and robustness to progressquickly and maintain stability.
• Harmony is a fountain of innovationin Java technology.
©mary_gaston22 flickr.com
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 35http://harmony.apache.org
What we still need to do … help appreciatedActive areas of effort
• Class library providers completion
• VM performance work
• Porting to new operating systems
• Improved test case coverage
• Real-world application testing
• Community growth
Apache Harmony
| ApacheConUS 2008 Conference | New Orleans, LA | Stormin' the coffee cup with Apache Harmony | 36http://harmony.apache.org
Q&A
http://harmony.apache.org
Tim Ellison