changeset 0:d2f08862ccfd

Initial load
author duke
date Wed, 28 May 2014 14:27:14 -0400
parents
children 31b8b8b57271
files .hgignore LICENSE Makefile README config/dio.properties-raspberrypi samples/gpio/gpio.policy samples/gpio/src/com/oracle/dio/sample/gpio/GPIOLEDSample.java src/se/classes/com/oracle/dio/gpio/impl/GPIOEventHandler.java src/se/classes/com/oracle/dio/gpio/impl/GPIOPinEventHandler.java src/se/classes/com/oracle/dio/gpio/impl/GPIOPinRegistryFactory.java src/se/classes/com/oracle/dio/gpio/impl/GPIOPortEventHandler.java src/se/classes/com/oracle/dio/gpio/impl/GPIOPortRegistryFactory.java src/se/classes/com/oracle/dio/i2cbus/impl/I2CDeviceRegistryFactory.java src/se/classes/com/oracle/dio/impl/Event.java src/se/classes/com/oracle/dio/impl/EventHandler.java src/se/classes/com/oracle/dio/impl/EventQueue.java src/se/classes/com/oracle/dio/impl/FakeHandle.java src/se/classes/com/oracle/dio/impl/Handle.java src/se/classes/com/oracle/dio/impl/Platform.java src/se/classes/com/oracle/dio/registry/DeviceRegistryFactory.java src/se/classes/com/oracle/dio/registry/RegistrationEventHandlerImpl.java src/se/classes/com/oracle/dio/registry/RegistrationEventSenderImpl.java src/se/classes/com/oracle/dio/registry/RegistryContent.java src/se/classes/com/oracle/dio/registry/RegistryData.java src/se/classes/com/oracle/dio/registry/RegistryImpl.java src/se/classes/com/oracle/dio/registry/RegistryList.java src/se/classes/com/oracle/dio/spibus/impl/SPIDeviceRegistryFactory.java src/se/classes/com/oracle/dio/uart/impl/ModemSignalDispatcher.java src/se/classes/com/oracle/dio/uart/impl/ModemUARTRegistryFactory.java src/se/classes/com/oracle/dio/uart/impl/UARTEventHandler.java src/se/classes/com/oracle/dio/uart/impl/UARTRegistryFactory.java src/se/classes/com/oracle/dio/utils/Configuration.java src/se/classes/com/oracle/dio/utils/ExceptionMessage.java src/se/classes/com/oracle/dio/utils/InterIsolateMutex.java src/se/classes/com/oracle/dio/utils/Logging.java src/se/classes/com/oracle/dio/utils/PrivilegeController.java src/se/classes/com/oracle/dio/utils/PrivilegedAction.java src/se/classes/impl/romizer/DontRenameClass.java src/se/classes/impl/romizer/DontRenameMethod.java src/se/classes/impl/romizer/Hidden.java src/se/classes/serializator/SerializeMe.java src/se/linux/native/com/oracle/dio/javacall_platform_defs.h src/se/linux/native/com/oracle/dio/memory.c src/se/linux/native/com/oracle/dio/os.c src/se/native/com/oracle/dio/dio_common.cpp src/se/native/com/oracle/dio/dio_common.h src/se/native/com/oracle/dio/dio_event_queue.cpp src/se/native/com/oracle/dio/dio_event_queue.h src/se/native/com/oracle/dio/dio_exceptions.cpp src/se/native/com/oracle/dio/dio_exceptions.h src/se/native/com/oracle/dio/dio_nio.cpp src/se/native/com/oracle/dio/dio_nio.h src/se/native/com/oracle/dio/gpio/impl/jni_gpio.cpp src/se/native/com/oracle/dio/i2cbus/impl/jni_i2c.cpp src/se/native/com/oracle/dio/javacall_defs.h src/se/native/com/oracle/dio/javacall_logging.h src/se/native/com/oracle/dio/javacall_memory.h src/se/native/com/oracle/dio/javacall_os.h src/se/native/com/oracle/dio/javacall_properties.c src/se/native/com/oracle/dio/javacall_properties.h src/se/native/com/oracle/dio/javautil_circular_buffer.c src/se/native/com/oracle/dio/javautil_circular_buffer.h src/se/native/com/oracle/dio/javautil_linked_list.c src/se/native/com/oracle/dio/javautil_linked_list.h src/se/native/com/oracle/dio/javautil_unicode.c src/se/native/com/oracle/dio/javautil_unicode.h src/se/native/com/oracle/dio/spibus/impl/jni_spi.cpp src/se/native/com/oracle/dio/uart/impl/jni_signal_dispatcher.cpp src/se/native/com/oracle/dio/uart/impl/jni_uart.cpp src/share/classes/com/oracle/dio/gpio/impl/GPIOPinFactory.java src/share/classes/com/oracle/dio/gpio/impl/GPIOPinFake.java src/share/classes/com/oracle/dio/gpio/impl/GPIOPinImpl.java src/share/classes/com/oracle/dio/gpio/impl/GPIOPortFactory.java src/share/classes/com/oracle/dio/gpio/impl/GPIOPortImpl.java src/share/classes/com/oracle/dio/i2cbus/impl/I2CCombinedMessage.java src/share/classes/com/oracle/dio/i2cbus/impl/I2CDeviceFactory.java src/share/classes/com/oracle/dio/i2cbus/impl/I2CSlaveImpl.java src/share/classes/com/oracle/dio/impl/AbstractPeripheral.java src/share/classes/com/oracle/dio/impl/PeripheralDescriptorImpl.java src/share/classes/com/oracle/dio/impl/PeripheralFactory.java src/share/classes/com/oracle/dio/power/impl/PowerManagedBase.java src/share/classes/com/oracle/dio/registry/RegistrationEventHandler.java src/share/classes/com/oracle/dio/registry/RegistrationEventSender.java src/share/classes/com/oracle/dio/registry/Registry.java src/share/classes/com/oracle/dio/spibus/impl/SPIDeviceFactory.java src/share/classes/com/oracle/dio/spibus/impl/SPISlaveImpl.java src/share/classes/com/oracle/dio/uart/impl/ModemUARTFactory.java src/share/classes/com/oracle/dio/uart/impl/UARTFactory.java src/share/classes/com/oracle/dio/uart/impl/UARTImpl.java src/share/classes/com/oracle/dio/utils/Constants.java src/share/classes/jdk/dio/AsyncErrorHandler.java src/share/classes/jdk/dio/BufferAccess.java src/share/classes/jdk/dio/ClosedDeviceException.java src/share/classes/jdk/dio/Device.java src/share/classes/jdk/dio/DeviceAlreadyExistsException.java src/share/classes/jdk/dio/DeviceConfig.java src/share/classes/jdk/dio/DeviceDescriptor.java src/share/classes/jdk/dio/DeviceEvent.java src/share/classes/jdk/dio/DeviceEventListener.java src/share/classes/jdk/dio/DeviceException.java src/share/classes/jdk/dio/DeviceManager.java src/share/classes/jdk/dio/DeviceMgmtPermission.java src/share/classes/jdk/dio/DeviceNotFoundException.java src/share/classes/jdk/dio/DevicePermission.java src/share/classes/jdk/dio/InputRoundListener.java src/share/classes/jdk/dio/InvalidDeviceConfigException.java src/share/classes/jdk/dio/OutputRoundListener.java src/share/classes/jdk/dio/RegistrationEvent.java src/share/classes/jdk/dio/RegistrationListener.java src/share/classes/jdk/dio/RoundCompletionEvent.java src/share/classes/jdk/dio/Transactional.java src/share/classes/jdk/dio/UnavailableDeviceException.java src/share/classes/jdk/dio/UnsupportedAccessModeException.java src/share/classes/jdk/dio/UnsupportedDeviceTypeException.java src/share/classes/jdk/dio/adc/ADCChannel.java src/share/classes/jdk/dio/adc/ADCChannelConfig.java src/share/classes/jdk/dio/adc/ADCPermission.java src/share/classes/jdk/dio/adc/AcquisitionRoundListener.java src/share/classes/jdk/dio/adc/InvalidInputSamplingRateException.java src/share/classes/jdk/dio/adc/MonitoringEvent.java src/share/classes/jdk/dio/adc/MonitoringListener.java src/share/classes/jdk/dio/adc/package-info.java src/share/classes/jdk/dio/atcmd/ATDevice.java src/share/classes/jdk/dio/atcmd/ATDeviceConfig.java src/share/classes/jdk/dio/atcmd/ATModem.java src/share/classes/jdk/dio/atcmd/ATPermission.java src/share/classes/jdk/dio/atcmd/CommandResponseHandler.java src/share/classes/jdk/dio/atcmd/DataConnection.java src/share/classes/jdk/dio/atcmd/DataConnectionHandler.java src/share/classes/jdk/dio/atcmd/UnsolicitedResponseHandler.java src/share/classes/jdk/dio/atcmd/package-info.java src/share/classes/jdk/dio/counter/CounterPermission.java src/share/classes/jdk/dio/counter/CountingEvent.java src/share/classes/jdk/dio/counter/CountingListener.java src/share/classes/jdk/dio/counter/PulseCounter.java src/share/classes/jdk/dio/counter/PulseCounterConfig.java src/share/classes/jdk/dio/counter/package-info.java src/share/classes/jdk/dio/dac/DACChannel.java src/share/classes/jdk/dio/dac/DACChannelConfig.java src/share/classes/jdk/dio/dac/DACPermission.java src/share/classes/jdk/dio/dac/GenerationRoundListener.java src/share/classes/jdk/dio/dac/InvalidOutputSamplingRateException.java src/share/classes/jdk/dio/dac/package-info.java src/share/classes/jdk/dio/generic/GenericBufferIODevice.java src/share/classes/jdk/dio/generic/GenericDevice.java src/share/classes/jdk/dio/generic/GenericDeviceConfig.java src/share/classes/jdk/dio/generic/GenericDeviceControl.java src/share/classes/jdk/dio/generic/GenericEvent.java src/share/classes/jdk/dio/generic/GenericEventListener.java src/share/classes/jdk/dio/generic/GenericPermission.java src/share/classes/jdk/dio/generic/package-info.java src/share/classes/jdk/dio/gpio/GPIOPin.java src/share/classes/jdk/dio/gpio/GPIOPinConfig.java src/share/classes/jdk/dio/gpio/GPIOPinPermission.java src/share/classes/jdk/dio/gpio/GPIOPort.java src/share/classes/jdk/dio/gpio/GPIOPortConfig.java src/share/classes/jdk/dio/gpio/GPIOPortPermission.java src/share/classes/jdk/dio/gpio/PinEvent.java src/share/classes/jdk/dio/gpio/PinListener.java src/share/classes/jdk/dio/gpio/PortEvent.java src/share/classes/jdk/dio/gpio/PortListener.java src/share/classes/jdk/dio/gpio/package-info.java src/share/classes/jdk/dio/i2cbus/I2CCombinedMessage.java src/share/classes/jdk/dio/i2cbus/I2CDevice.java src/share/classes/jdk/dio/i2cbus/I2CDeviceConfig.java src/share/classes/jdk/dio/i2cbus/I2CPermission.java src/share/classes/jdk/dio/i2cbus/package-info.java src/share/classes/jdk/dio/modem/ModemSignalEvent.java src/share/classes/jdk/dio/modem/ModemSignalListener.java src/share/classes/jdk/dio/modem/ModemSignalsControl.java src/share/classes/jdk/dio/modem/package-info.java src/share/classes/jdk/dio/package-info.java src/share/classes/jdk/dio/power/PowerManaged.java src/share/classes/jdk/dio/power/PowerSavingHandler.java src/share/classes/jdk/dio/power/package-info.java src/share/classes/jdk/dio/pwm/GenerationEvent.java src/share/classes/jdk/dio/pwm/GenerationListener.java src/share/classes/jdk/dio/pwm/GenerationRoundListener.java src/share/classes/jdk/dio/pwm/InvalidPulseRateException.java src/share/classes/jdk/dio/pwm/PWMChannel.java src/share/classes/jdk/dio/pwm/PWMChannelConfig.java src/share/classes/jdk/dio/pwm/PWMPermission.java src/share/classes/jdk/dio/pwm/package-info.java src/share/classes/jdk/dio/spi/AbstractDevice.java src/share/classes/jdk/dio/spi/DeviceProvider.java src/share/classes/jdk/dio/spi/package-info.java src/share/classes/jdk/dio/spibus/InvalidWordLengthException.java src/share/classes/jdk/dio/spibus/SPIDevice.java src/share/classes/jdk/dio/spibus/SPIDeviceConfig.java src/share/classes/jdk/dio/spibus/SPIPermission.java src/share/classes/jdk/dio/spibus/package-info.java src/share/classes/jdk/dio/uart/ModemUART.java src/share/classes/jdk/dio/uart/UART.java src/share/classes/jdk/dio/uart/UARTConfig.java src/share/classes/jdk/dio/uart/UARTEvent.java src/share/classes/jdk/dio/uart/UARTEventListener.java src/share/classes/jdk/dio/uart/UARTPermission.java src/share/classes/jdk/dio/uart/package-info.java src/share/classes/jdk/dio/watchdog/WatchdogTimer.java src/share/classes/jdk/dio/watchdog/WatchdogTimerConfig.java src/share/classes/jdk/dio/watchdog/WatchdogTimerPermission.java src/share/classes/jdk/dio/watchdog/WindowedWatchdogTimer.java src/share/classes/jdk/dio/watchdog/package-info.java src/share/linux/native/com/oracle/dio/gpio.c src/share/linux/native/com/oracle/dio/gpio_resource.h src/share/linux/native/com/oracle/dio/i2c.c src/share/linux/native/com/oracle/dio/mmio.c src/share/linux/native/com/oracle/dio/serial.c src/share/linux/native/com/oracle/dio/spi.c src/share/native/com/oracle/dio/javacall_dio.h src/share/native/com/oracle/dio/javacall_gpio.h src/share/native/com/oracle/dio/javacall_i2c.h src/share/native/com/oracle/dio/javacall_mmio.h src/share/native/com/oracle/dio/javacall_serial.h src/share/native/com/oracle/dio/javacall_spi.h src/share/native/com/oracle/dio/javanotify_gpio.h
diffstat 216 files changed, 38812 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,1 @@
+./build
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LICENSE	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,348 @@
+The GNU General Public License (GPL)
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this license
+document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share
+and change it.  By contrast, the GNU General Public License is intended to
+guarantee your freedom to share and change free software--to make sure the
+software is free for all its users.  This General Public License applies to
+most of the Free Software Foundation's software and to any other program whose
+authors commit to using it.  (Some other Free Software Foundation software is
+covered by the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+When we speak of free software, we are referring to freedom, not price.  Our
+General Public Licenses are designed to make sure that you have the freedom to
+distribute copies of free software (and charge for this service if you wish),
+that you receive source code or can get it if you want it, that you can change
+the software or use pieces of it in new free programs; and that you know you
+can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny
+you these rights or to ask you to surrender the rights.  These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have.  You must
+make sure that they, too, receive or can get the source code.  And you must
+show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software.  If the
+software is modified by someone else and passed on, we want its recipients to
+know that what they have is not the original, so that any problems introduced
+by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents.  We
+wish to avoid the danger that redistributors of a free program will
+individually obtain patent licenses, in effect making the program proprietary.
+To prevent this, we have made it clear that any patent must be licensed for
+everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms of
+this General Public License.  The "Program", below, refers to any such program
+or work, and a "work based on the Program" means either the Program or any
+derivative work under copyright law: that is to say, a work containing the
+Program or a portion of it, either verbatim or with modifications and/or
+translated into another language.  (Hereinafter, translation is included
+without limitation in the term "modification".) Each licensee is addressed as
+"you".
+
+Activities other than copying, distribution and modification are not covered by
+this License; they are outside its scope.  The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made by
+running the Program).  Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as
+you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may
+at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus
+forming a work based on the Program, and copy and distribute such modifications
+or work under the terms of Section 1 above, provided that you also meet all of
+these conditions:
+
+    a) You must cause the modified files to carry prominent notices stating
+    that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in whole or
+    in part contains or is derived from the Program or any part thereof, to be
+    licensed as a whole at no charge to all third parties under the terms of
+    this License.
+
+    c) If the modified program normally reads commands interactively when run,
+    you must cause it, when started running for such interactive use in the
+    most ordinary way, to print or display an announcement including an
+    appropriate copyright notice and a notice that there is no warranty (or
+    else, saying that you provide a warranty) and that users may redistribute
+    the program under these conditions, and telling the user how to view a copy
+    of this License.  (Exception: if the Program itself is interactive but does
+    not normally print such an announcement, your work based on the Program is
+    not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If identifiable
+sections of that work are not derived from the Program, and can be reasonably
+considered independent and separate works in themselves, then this License, and
+its terms, do not apply to those sections when you distribute them as separate
+works.  But when you distribute the same sections as part of a whole which is a
+work based on the Program, the distribution of the whole must be on the terms
+of this License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your
+rights to work written entirely by you; rather, the intent is to exercise the
+right to control the distribution of derivative or collective works based on
+the Program.
+
+In addition, mere aggregation of another work not based on the Program with the
+Program (or with a work based on the Program) on a volume of a storage or
+distribution medium does not bring the other work under the scope of this
+License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1 and
+2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable source
+    code, which must be distributed under the terms of Sections 1 and 2 above
+    on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three years, to
+    give any third party, for a charge no more than your cost of physically
+    performing source distribution, a complete machine-readable copy of the
+    corresponding source code, to be distributed under the terms of Sections 1
+    and 2 above on a medium customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer to
+    distribute corresponding source code.  (This alternative is allowed only
+    for noncommercial distribution and only if you received the program in
+    object code or executable form with such an offer, in accord with
+    Subsection b above.)
+
+The source code for a work means the preferred form of the work for making
+modifications to it.  For an executable work, complete source code means all
+the source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and installation
+of the executable.  However, as a special exception, the source code
+distributed need not include anything that is normally distributed (in either
+source or binary form) with the major components (compiler, kernel, and so on)
+of the operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the source
+code from the same place counts as distribution of the source code, even though
+third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License.  Any attempt otherwise to copy, modify,
+sublicense or distribute the Program is void, and will automatically terminate
+your rights under this License.  However, parties who have received copies, or
+rights, from you under this License will not have their licenses terminated so
+long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the Program
+or its derivative works.  These actions are prohibited by law if you do not
+accept this License.  Therefore, by modifying or distributing the Program (or
+any work based on the Program), you indicate your acceptance of this License to
+do so, and all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program),
+the recipient automatically receives a license from the original licensor to
+copy, distribute or modify the Program subject to these terms and conditions.
+You may not impose any further restrictions on the recipients' exercise of the
+rights granted herein.  You are not responsible for enforcing compliance by
+third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License.  If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices.  Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose that
+choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded.  In
+such case, this License incorporates the limitation as if written in the body
+of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the
+General Public License from time to time.  Such new versions will be similar in
+spirit to the present version, but may differ in detail to address new problems
+or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any later
+version", you have the option of following the terms and conditions either of
+that version or of any later version published by the Free Software Foundation.
+If the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission.  For software which is copyrighted by the Free Software Foundation,
+write to the Free Software Foundation; we sometimes make exceptions for this.
+Our decision will be guided by the two goals of preserving the free status of
+all derivatives of our free software and of promoting the sharing and reuse of
+software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE
+PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE,
+YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
+ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE
+PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
+INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
+BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
+OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
+
+How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the greatest possible
+use to the public, the best way to achieve this is to make it free software
+which everyone can redistribute and change under these terms.
+
+To do so, attach the following notices to the program.  It is safest to attach
+them to the start of each source file to most effectively convey the exclusion
+of warranty; and each file should have at least the "copyright" line and a
+pointer to where the full notice is found.
+
+    One line to give the program's name and a brief idea of what it does.
+
+    Copyright (C) <year> <name of author>
+
+    This program is free software; you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by the Free
+    Software Foundation; either version 2 of the License, or (at your option)
+    any later version.
+
+    This program is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+    more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc., 59
+    Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this when it
+starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
+    with ABSOLUTELY NO WARRANTY; for details type 'show w'.  This is free
+    software, and you are welcome to redistribute it under certain conditions;
+    type 'show c' for details.
+
+The hypothetical commands 'show w' and 'show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may be
+called something other than 'show w' and 'show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.  Here
+is a sample; alter the names:
+
+    Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+    'Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+    signature of Ty Coon, 1 April 1989
+
+    Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General Public
+License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL
+
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
+
+    Linking this library statically or dynamically with other modules is making
+    a combined work based on this library.  Thus, the terms and conditions of
+    the GNU General Public License cover the whole combination.
+
+    As a special exception, the copyright holders of this library give you
+    permission to link this library with independent modules to produce an
+    executable, regardless of the license terms of these independent modules,
+    and to copy and distribute the resulting executable under terms of your
+    choice, provided that you also meet, for each linked independent module,
+    the terms and conditions of the license of that module.  An independent
+    module is a module which is not derived from or based on this library.  If
+    you modify this library, you may extend this exception to your version of
+    the library, but you are not obligated to do so.  If you do not wish to do
+    so, delete this exception statement from your version.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,176 @@
+#########################################################################
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+#########################################################################
+# Functions
+
+# find-suffix-files
+# finds all files with given suffix below given directories
+# usage: $(call find-suffix-files <dir-list>,<suffix>)
+# note: <suffix> should not contain the '.'
+define find-suffix-files
+$(patsubst ./%,%, \
+  $(shell find $(1) -name "*.$(2)" -and -not -name ".*") \
+)
+endef
+
+LIB_NAME := dio
+
+###########################################################
+# Defaults for Hudson build vars
+BUILD_NUMBER ?= dev
+JOB_NAME ?= $(LIB_NAME)-$(BUILD_NUMBER)
+BUILD_ID ?= $(shell date +%Y-%b-%d_%H-%M-%S)
+###########################################################
+
+###########################################################
+# check for required env vars
+ifeq ($(PI_TOOLS),)
+  $(error "PI_TOOLS is not defined. Please set PI_TOOLS to point to the location of the raspberry pi GNU toolchain")
+endif
+
+ifeq ($(JAVA_HOME),)
+  $(error "JAVA_HOME is not defined. Please set JAVA_HOME to point to the location of the JDK8 installation")
+endif
+
+BUILD_DEVICEACCESS := true
+
+# specify java src directories
+DIO_JAVA_SRC_DIRS := \
+                     src/se/classes \
+                     src/share/classes
+
+# specify native src directories
+DIO_NATIVE_SRC_DIRS := \
+                       src/se/native \
+                       src/share/native \
+                       src/se/linux/native \
+                       src/share/linux/native
+
+# specify sample java src directories
+DIO_SAM_JAVA_SRC_DIR := \
+                        samples/gpio/src
+
+# Output directorires
+BUILD_DIR := $(CURDIR)/build
+SO_OUT_DIR := $(BUILD_DIR)/so
+JAVA_OUT_DIR := $(BUILD_DIR)/classes
+SAM_JAVA_OUT_DIR := $(BUILD_DIR)/samples/classes
+NATIVE_OUT_DIR := $(BUILD_DIR)/obj
+JAR_OUT_DIR := $(BUILD_DIR)/jar
+DEVICE_IO_OUT_DIR := $(BUILD_DIR)/deviceio
+BUNDLE_OUT_DIR := $(BUILD_DIR)/bundles
+
+# find all src files
+CPP_SRC_FILES := $(call find-suffix-files, $(DIO_NATIVE_SRC_DIRS),cpp)
+C_SRC_FILES :=  $(call find-suffix-files, $(DIO_NATIVE_SRC_DIRS),c)
+JAVA_SRC_FILES := $(call find-suffix-files, $(DIO_JAVA_SRC_DIRS),java)
+SAM_JAVA_SRC_FILES := $(call find-suffix-files, $(DIO_SAM_JAVA_SRC_DIR),java)
+
+DIO_INCLUDE_DIRS := $(sort $(dir $(call find-suffix-files, $(DIO_NATIVE_SRC_DIRS),h)))
+
+# calculate obj files needed
+CPP_OBJ_FILES := $(notdir $(subst .cpp,.o,$(CPP_SRC_FILES)))
+C_OBJ_FILES := $(notdir $(subst .c,.o,$(C_SRC_FILES)))
+
+# setup search paths
+vpath %.cpp $(sort $(dir $(CPP_SRC_FILES)))
+vpath %.c $(sort $(dir $(C_SRC_FILES)))
+vpath %.o $(NATIVE_OUT_DIR)
+
+#######################################################################################################
+# tool and flag setup for arm (rasp pi) build
+TARGET_TOOLCHAIN := $(PI_TOOLS)
+TARGET_CC := $(TARGET_TOOLCHAIN)/bin/gcc
+TARGET_CXX := $(TARGET_TOOLCHAIN)/bin/g++
+TARGET_LD := $(TARGET_TOOLCHAIN)/bin/gcc
+JAVAC := $(JAVA_HOME)/bin/javac
+JAR := $(JAVA_HOME)/bin/jar
+MKDIR := mkdir -p
+TARGET_CPU_LEGACY_LIB := arm
+TARGET_C_FLAGS = -Wno-psabi -DJAVACALL_REPORT_LEVEL=4 -DENABLE_DEVICEACCESS -c -MMD -MF $(NATIVE_OUT_DIR)/$(@).d
+TARGET_INCLUDES := $(foreach d,$(DIO_INCLUDE_DIRS),-I$(d)) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
+TARGET_CXX_FLAGS := -Wno-psabi -DJAVACALL_REPORT_LEVEL=4 -DENABLE_DEVICEACCESS -c
+TARGET_LD_FLAGS:= -Xlinker -z -Xlinker defs -Xlinker -O1 \
+          -shared \
+          -Xlinker -rpath -Xlinker \$$ORIGIN -lpthread -lrt \
+          -Xlinker -z -Xlinker muldefs -lstdc++
+
+#######################################################################################################
+#
+BUNDLE_NAME := $(JOB_NAME)-b$(BUILD_NUMBER)
+
+#######################################################################################################
+# targets
+
+.PHONY: clean all dirs device-io bundle
+
+all: dirs $(LIB_NAME).jar lib$(LIB_NAME).so $(LIB_NAME)-samples.jar device-io
+
+dirs:
+	@echo "Creating output directories"
+	@$(MKDIR) $(SO_OUT_DIR)
+	@$(MKDIR) $(JAVA_OUT_DIR)
+	@$(MKDIR) $(SAM_JAVA_OUT_DIR)
+	@$(MKDIR) $(NATIVE_OUT_DIR)
+	@$(MKDIR) $(JAR_OUT_DIR)
+	@$(MKDIR) $(DEVICE_IO_OUT_DIR)
+	@$(MKDIR) $(BUNDLE_OUT_DIR)
+
+$(CPP_OBJ_FILES): %.o: %.cpp dirs
+	@echo Compiling $<
+	@$(TARGET_CC) $(TARGET_C_FLAGS) $(TARGET_INCLUDES) $< -o $(NATIVE_OUT_DIR)/$@
+
+$(C_OBJ_FILES): %.o: %.c dirs
+	@echo compiling $<
+	@$(TARGET_CC) $(TARGET_C_FLAGS) $(TARGET_INCLUDES) $< -o $(NATIVE_OUT_DIR)/$@
+
+lib$(LIB_NAME).so: $(CPP_OBJ_FILES) $(C_OBJ_FILES) dirs
+	@echo linking $@
+	@$(TARGET_LD) $(TARGET_LD_FLAGS) -o $(SO_OUT_DIR)/$@ $(foreach o,$(CPP_OBJ_FILES) $(C_OBJ_FILES),$(NATIVE_OUT_DIR)/$(o))
+
+$(LIB_NAME).jar: $(JAVA_SRC_FILES) dirs
+	@echo Compiling Java source files to $(JAR_OUT_DIR)/$@
+	@$(JAVAC) -d $(JAVA_OUT_DIR) $(JAVA_SRC_FILES)
+	@(cd $(JAVA_OUT_DIR) ; $(JAR) cf $(JAR_OUT_DIR)/$@ .)
+
+$(LIB_NAME)-samples.jar: $(SAM_JAVA_SRC_FILES) dirs $(LIB_NAME).jar
+	@echo Compiling Java source files to $(JAR_OUT_DIR)/$@
+	@$(JAVAC) -cp $(JAR_OUT_DIR)/$(LIB_NAME).jar -d $(SAM_JAVA_OUT_DIR) $(SAM_JAVA_SRC_FILES)
+	@(cd $(SAM_JAVA_OUT_DIR) ; $(JAR) cf $(JAR_OUT_DIR)/$@ .)
+
+device-io: dirs $(LIB_NAME).jar lib$(LIB_NAME).so
+	@$(MKDIR) $(DEVICE_IO_OUT_DIR)/lib/ext
+	@$(MKDIR) $(DEVICE_IO_OUT_DIR)/lib/$(TARGET_CPU_LEGACY_LIB)
+	@cp $(JAR_OUT_DIR)/$(LIB_NAME).jar $(DEVICE_IO_OUT_DIR)/lib/ext
+	@cp $(SO_OUT_DIR)/lib$(LIB_NAME).so $(DEVICE_IO_OUT_DIR)/lib/$(TARGET_CPU_LEGACY_LIB)
+
+bundle: device-io dirs
+	@echo creating $(BUNDLE_NAME)
+	@tar czvf $(BUNDLE_OUT_DIR)/$(BUNDLE_NAME).tar.gz -C $(BUILD_DIR) deviceio
+
+clean:
+	@echo "clean: removing $(BUILD_DIR)"
+	@rm -rf $(BUILD_DIR)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,19 @@
+README:
+
+This file should be located at the root of the device-io OpenJDK Mercurial repository.
+ 
+People unfamiliar with Mercurial should read the first few chapters of
+  the Mercurial book: http://hgbook.red-bean.com/read/
+
+Simple Build Instructions for the Raspberry Pi:
+
+  The Device I/O build is currently supoorted as a cross-compile on a Linux x86 host for the Raspberry Pi.
+
+  Required tools: Linaro GCC 4.7.2 ARM toolchain, JDK 8, GNU make 3.81 or newer
+
+  export PI_TOOLS=<location of Linaro GCC tool install>
+  export JAVA_HOME=<location of JDK8 install>
+  make
+
+The resulting Device I/O library files should be found in build/jar and build/so
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config/dio.properties-raspberrypi	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,61 @@
+#########################################################################
+# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+#########################################################################
+
+13 = deviceType: atcmd.ATDevice, name:EMUL, properties : ["com.oracle.atcmd.emulation=true", ]
+2  = deviceType: gpio.GPIOPin, pinNumber:2, name:GPIO2, mode:1
+3  = deviceType: gpio.GPIOPin, pinNumber:3, name:GPIO3, mode:1
+4  = deviceType: gpio.GPIOPin, pinNumber:4, name:GPIO4
+17 = deviceType: gpio.GPIOPin, pinNumber:17, name:GPIO17
+27 = deviceType: gpio.GPIOPin, pinNumber:27, name:GPIO27
+22 = deviceType: gpio.GPIOPin, pinNumber:22, name:GPIO22
+10 = deviceType: gpio.GPIOPin, pinNumber:10, name:GPIO10
+9  = deviceType: gpio.GPIOPin, pinNumber:9, name:GPIO9
+11 = deviceType: gpio.GPIOPin, pinNumber:11, name:GPIO11
+14 = deviceType: gpio.GPIOPin, pinNumber:14, name:GPIO14, mode:4, direction:1
+15 = deviceType: gpio.GPIOPin, pinNumber:15, name:GPIO15, mode:4, direction:1
+18 = deviceType: gpio.GPIOPin, pinNumber:18, name:GPIO18, mode:4, direction:1
+23 = deviceType: gpio.GPIOPin, pinNumber:23, name:GPIO23, mode:4, direction:1
+24 = deviceType: gpio.GPIOPin, pinNumber:24, name:GPIO24, mode:4, direction:1
+25 = deviceType: gpio.GPIOPin, pinNumber:25, name:GPIO25, mode:4, direction:1
+8  = deviceType: gpio.GPIOPin, pinNumber:8, name:GPIO8, mode:4, direction:1
+7  = deviceType: gpio.GPIOPin, pinNumber:7, name:GPIO7, mode:4, direction:1
+61 = deviceType: mmio.MMIODevice, name:MMIO, byteOrdering:little, address:0x2020C000, size:28, memConfigs : [ \
+        {type:REGISTER_TYPE_INT, offset:0, name:CTL,}, \
+        {type:REGISTER_TYPE_INT, offset:4, name:STA,}, \
+        {type:REGISTER_TYPE_INT, offset:16, name:RNG1,}, \
+        {type:REGISTER_TYPE_INT, offset:20, name:DAT1,}, \
+        {type:REGISTER_TYPE_INT, offset:24, name:FIF1,}, \
+        ]
+12 = deviceType: spibus.SPIDevice, name:SPI_Slave, deviceNumber:0, address:1, csActive:0, wordLength:8, clockFrequency:500000, clockMode:1, bitOrdering:1
+40 = deviceType: uart.UART, deviceNumber:0, name:UART, baudRate:19200, dataBits:8, parity:0, stopBits:1, flowControl:0
+30 = deviceType: watchdog.WatchdogTimer, name:WDG, timerNumber:1
+31 = deviceType: watchdog.WindowedWatchdogTimer, name:WWDG, timerNumber:2
+
+atcmd.ATDevice = deviceNumber:1, channelNumber:1
+gpio.GPIOPin = initValue:0, deviceNumber:0, direction:0, mode:1, trigger:3
+mmio.MMIODevice =
+uart.UART = baudRate:19200, parity:0, dataBits:8, stopBits:1, flowControl:0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/gpio/gpio.policy	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+grant {
+        // permissions for using GPIO pin 18 GPIOLEDSample
+        permission jdk.dio.gpio.GPIOPinPermission ":18";
+        permission jdk.dio.gpio.GPIOPinPermission "0:18";
+        permission jdk.dio.DeviceMgmtPermission "GPIO18:18", "open";
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/samples/gpio/src/com/oracle/dio/sample/gpio/GPIOLEDSample.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+
+ *   - Neither the name of Oracle nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.oracle.dio.samples.gpio;
+
+import java.util.*;
+
+import jdk.dio.*;
+import jdk.dio.gpio.*;
+import java.io.IOException;
+
+public class GPIOLEDSample {
+
+    public static void blinkLEDByGPIONumber(int pinNumber) {
+        System.out.println("Blinking LED on GPIO pin number " + pinNumber);
+        GPIOPin pin = null;
+        try {
+            GPIOPinConfig pinConfig = new GPIOPinConfig(DeviceConfig.DEFAULT,
+                                                        pinNumber,
+                                                        GPIOPinConfig.DIR_OUTPUT_ONLY,
+                                                        GPIOPinConfig.MODE_OUTPUT_PUSH_PULL,
+                                                        GPIOPinConfig.TRIGGER_NONE,
+                                                        false);
+            pin = (GPIOPin)DeviceManager.open(GPIOPin.class, pinConfig);
+            boolean pinOn = false;
+            for (int i = 0; i < 20; i++) {
+                Thread.sleep(2500);
+                pinOn = !pinOn;
+                pin.setValue(pinOn);
+            }
+        } catch (IOException ioe) {
+            throw new LEDExampleException("IOException while opening device. Make sure you have the appropriate operating system permission to access GPIO devices.", ioe);
+        } catch(InterruptedException ie) {
+            // ignore
+        } finally {
+            try {
+                System.out.println("Closing GPIO pin number " + pinNumber);
+                if (pin != null) {
+                    pin.close();
+                }
+            } catch (Exception e) {
+                throw new LEDExampleException("Received exception while trying to close device.", e);
+            }
+        }
+    }
+
+    public static void blinkLEDByDeviceId(int deviceId) {
+        System.out.println("Blinking LED on device ID " + deviceId);
+        GPIOPin pin = null;
+        try {
+            pin = (GPIOPin)DeviceManager.open(deviceId);
+            boolean pinOn = false;
+            for (int i = 0; i < 20; i++) {
+                Thread.sleep(2500);
+                pinOn = !pinOn;
+                pin.setValue(pinOn);
+            }
+        } catch (IOException ioe) {
+            throw new LEDExampleException("IOException while opening device. Make sure you have the appropriate operating system permission to access GPIO devices.", ioe);
+        } catch(InterruptedException ie) {
+            // ignore
+        } finally {
+            try {
+        System.out.println("Closing device ID " + deviceId);
+                if (pin != null) {
+                    pin.close();
+                }
+            } catch (Exception e) {
+                throw new LEDExampleException("Received exception while trying to close device.", e);
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        // First, blink the LED by specifying the GPIO pin number
+        blinkLEDByGPIONumber(18);
+        // Next, blink the LED by looking up the device associated with
+        // the device id
+        blinkLEDByDeviceId(18);
+    }
+}
+
+class LEDExampleException extends RuntimeException {
+    public LEDExampleException(String msg, Throwable t) {
+        super(msg,t);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/gpio/impl/GPIOEventHandler.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.gpio.impl;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import jdk.dio.Device;
+import com.oracle.dio.impl.AbstractPeripheral;
+import com.oracle.dio.impl.Event;
+import com.oracle.dio.impl.EventHandler;
+import com.oracle.dio.impl.EventQueue;
+
+abstract class GPIOEventHandler<T extends AbstractPeripheral> implements EventHandler {
+
+    private final Hashtable<T, Object> listeners = new Hashtable<>();
+    private static final int QUEUE_BUFFER_SIZE = 4096;
+    protected final EventQueue queue = EventQueue.createEventQueue(QUEUE_BUFFER_SIZE);
+
+    protected <U extends GPIOEvent> GPIOEventHandler(Class<U> eventClass) {
+        queue.registerForEvent(eventClass, this);
+    }
+
+    synchronized void setEventListener(T peripheral, Object listener) {
+        listeners.put(peripheral, listener);
+    }
+
+    synchronized void removeEventListener(T peripheral) {
+        listeners.remove(peripheral);
+    }
+
+    public synchronized boolean handleEvent(Event event) {
+        GPIOEvent e = (GPIOEvent)event;
+        Enumeration<T> peripherals = listeners.keys();
+        while (peripherals.hasMoreElements()) {
+            T p = peripherals.nextElement();
+            if (p.getHandle().getNativeHandle() == e.getNativeHandle()) {
+                Object listener = listeners.get(p);
+                handleGPIOEvent(listener, p, e);
+            }
+        }
+        return true;
+    }
+
+    protected abstract void handleGPIOEvent(Object listener, T peripheral, GPIOEvent event);
+
+    protected abstract class GPIOEvent extends Event {
+        int getNativeHandle() {
+            byte[] payload = getPayload();
+            int handle = ((int)payload[0] << 24) |
+                         ((int)payload[1] << 16) |
+                         ((int)payload[2] << 8)  |
+                         ((int)payload[3]);
+            return handle;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/gpio/impl/GPIOPinEventHandler.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.gpio.impl;
+
+import jdk.dio.gpio.PinEvent;
+import jdk.dio.gpio.PinListener;
+import java.nio.Buffer;
+
+final class GPIOPinEventHandler extends GPIOEventHandler<GPIOPinImpl> {
+
+    private static final GPIOPinEventHandler instance = new GPIOPinEventHandler();
+
+    private GPIOPinEventHandler() {
+        super(InternalEvent.class);
+    }
+
+    static GPIOPinEventHandler getInstance() {
+        return instance;
+    }
+
+    static {
+        setNativeEntries(instance.queue.getNativeBuffer(), InternalEvent.class);
+    }
+
+    protected void handleGPIOEvent(Object listener, GPIOPinImpl pin, GPIOEvent event) {
+        boolean value = ((InternalEvent)event).getValue();
+        PinListener pinListener = (PinListener)listener;
+        pinListener.valueChanged(new PinEvent(pin, value));
+    }
+
+    class InternalEvent extends GPIOEvent {
+        boolean getValue() {
+            byte[] payload = getPayload();
+            int value = ((int)payload[4] << 24) |
+                        ((int)payload[5] << 16) |
+                        ((int)payload[6] << 8)  |
+                        ((int)payload[7]);
+            return (value != 0);
+        }
+    }
+
+    private static native void setNativeEntries(Buffer buffer, Class<InternalEvent> eventClass);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/gpio/impl/GPIOPinRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.gpio.impl;
+
+import jdk.dio.DeviceConfig;
+import jdk.dio.DeviceDescriptor;
+import jdk.dio.gpio.GPIOPin;
+import jdk.dio.gpio.GPIOPinConfig;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.registry.RegistryData;
+import com.oracle.dio.registry.DeviceRegistryFactory;
+import com.oracle.dio.utils.Constants;
+import java.io.IOException;
+
+public final class GPIOPinRegistryFactory extends DeviceRegistryFactory {
+
+    private static final String PIN_NUMBER = "pinNumber";
+    private static final String MODE = "mode";
+    private static final String TRIGGER = "trigger";
+    private static final String TYPE_VALUE = "gpio.GPIOPin";
+
+    public GPIOPinRegistryFactory() {}
+
+    public DeviceDescriptor<GPIOPin> createDeviceDescriptor(int id, RegistryData data) throws IOException {
+        String name = data.getCharacterProperty(Constants.NAME);
+        GPIOPinConfig cfg = createConfig(data);
+        String[] properties = super.getProperties(data);
+        return new PeripheralDescriptorImpl(id, name, cfg, GPIOPin.class, properties);
+    }
+
+    public RegistryData createRegistryData(DeviceDescriptor descriptor) {
+        GPIOPinConfig cfg = (GPIOPinConfig)descriptor.getConfiguration();
+        String name = descriptor.getName();
+
+        RegistryData data = createData(cfg);
+        data.putCharacterProperty(DEVICE_TYPE, TYPE_VALUE);
+
+        if (name != null) {
+            data.putCharacterProperty(Constants.NAME, name);
+        }
+
+        super.putProperties(data, descriptor.getProperties());
+        return data;
+    }
+
+    static GPIOPinConfig createConfig(RegistryData data) {
+        String deviceName = data.getCharacterProperty(Constants.PATH);
+        int pin = data.getIntegerProperty(PIN_NUMBER, DeviceConfig.DEFAULT);
+        int dir = data.getIntegerProperty(Constants.DIRECTION, GPIOPinConfig.DIR_INPUT_ONLY);
+        int mode = data.getIntegerProperty(MODE, DeviceConfig.DEFAULT);
+        int trigger = data.getIntegerProperty(TRIGGER, GPIOPinConfig.TRIGGER_NONE);
+        boolean initValue = data.getBooleanProperty(Constants.INIT_VALUE, false);
+
+        GPIOPinConfig cfg;
+        if (null == deviceName) {
+            int deviceNumber = data.getIntegerProperty(Constants.DEVICE_NUMBER, DeviceConfig.DEFAULT);
+            cfg = new GPIOPinConfig(deviceNumber, pin, dir, mode, trigger, initValue);
+        } else {
+            cfg = new GPIOPinConfig(deviceName, pin, dir, mode, trigger, initValue);
+        }
+        return cfg;
+    }
+
+    static RegistryData createData(GPIOPinConfig cfg) {
+        RegistryData data = new RegistryData();
+        String deviceName = cfg.getControllerName();
+        if (deviceName != null) {
+            data.putCharacterProperty(Constants.PATH, deviceName);
+        }
+        int deviceNumber = cfg.getControllerNumber();
+        if (deviceNumber != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.DEVICE_NUMBER, deviceNumber);
+        }
+        int pin = cfg.getPinNumber();
+        if (pin != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(PIN_NUMBER, pin);
+        }
+        int mode = cfg.getDriveMode();
+        if (mode != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(MODE, mode);
+        }
+        data.putIntegerProperty(Constants.DIRECTION, cfg.getDirection());
+        data.putIntegerProperty(TRIGGER, cfg.getTrigger());
+        data.putBooleanProperty(Constants.INIT_VALUE, cfg.getInitValue());
+        return data;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/gpio/impl/GPIOPortEventHandler.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.gpio.impl;
+
+import jdk.dio.gpio.PortEvent;
+import jdk.dio.gpio.PortListener;
+import java.nio.Buffer;
+
+final class GPIOPortEventHandler extends GPIOEventHandler<GPIOPortImpl> {
+
+    private static final GPIOPortEventHandler instance = new GPIOPortEventHandler();
+
+    private GPIOPortEventHandler() {
+        super(InternalEvent.class);
+    }
+
+    static GPIOPortEventHandler getInstance() {
+        return instance;
+    }
+
+    static {
+        setNativeEntries(instance.queue.getNativeBuffer(), InternalEvent.class);
+    }
+
+    protected void handleGPIOEvent(Object listener, GPIOPortImpl port, GPIOEvent event) {
+        int value = ((InternalEvent)event).getValue();
+        PortListener portListener = (PortListener)listener;
+        portListener.valueChanged(new PortEvent(port, value));
+    }
+
+    class InternalEvent extends GPIOEvent {
+        int getValue() {
+            byte[] payload = getPayload();
+            int value = ((int)payload[4] << 24) |
+                        ((int)payload[5] << 16) |
+                        ((int)payload[6] << 8)  |
+                        ((int)payload[7]);
+            return value;
+        }
+    }
+
+    private static native void setNativeEntries(Buffer buffer, Class<InternalEvent> eventClass);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/gpio/impl/GPIOPortRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.gpio.impl;
+
+import jdk.dio.DeviceConfig;
+import jdk.dio.DeviceDescriptor;
+import jdk.dio.gpio.GPIOPin;
+import jdk.dio.gpio.GPIOPinConfig;
+import jdk.dio.gpio.GPIOPort;
+import jdk.dio.gpio.GPIOPortConfig;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.registry.RegistryData;
+import com.oracle.dio.registry.RegistryList;
+import com.oracle.dio.registry.DeviceRegistryFactory;
+import com.oracle.dio.utils.Constants;
+import java.io.IOException;
+import java.util.Enumeration;
+
+public final class GPIOPortRegistryFactory extends DeviceRegistryFactory {
+
+    private static final String PINS = "pins";
+    private static final String TYPE_VALUE = "gpio.GPIOPort";
+
+    public GPIOPortRegistryFactory() {}
+
+    public DeviceDescriptor<GPIOPort> createDeviceDescriptor(int id, RegistryData data) throws IOException {
+        String name = data.getCharacterProperty(Constants.NAME);
+        int dir = data.getIntegerProperty(Constants.DIRECTION, DeviceConfig.DEFAULT);
+        int initValue = data.getIntegerProperty(Constants.INIT_VALUE, 0);
+
+        RegistryList pinList = data.getListProperty(PINS);
+        if (pinList == null) {
+            return null;
+        }
+        GPIOPinConfig parray[] = new GPIOPinConfig[pinList.size()];
+        Enumeration<?> pins = pinList.elements();
+        for (int i = 0; pins.hasMoreElements(); i++) {
+            RegistryData pin = (RegistryData)pins.nextElement();
+            pin = (RegistryData)pin.clone();
+            pin.putIntegerProperty(Constants.DIRECTION, dir);
+            parray[i] = GPIOPinRegistryFactory.createConfig(pin);
+        }
+
+        GPIOPortConfig cfg = new GPIOPortConfig(dir, initValue, parray);
+        String[] properties = super.getProperties(data);
+        return new PeripheralDescriptorImpl(id, name, cfg, GPIOPort.class, properties);
+    }
+
+    public RegistryData createRegistryData(DeviceDescriptor descriptor) {
+        GPIOPortConfig cfg = (GPIOPortConfig)descriptor.getConfiguration();
+        String name = descriptor.getName();
+
+        RegistryData data = new RegistryData();
+        data.putCharacterProperty(DEVICE_TYPE, TYPE_VALUE);
+
+        if (name != null) {
+            data.putCharacterProperty(Constants.NAME, name);
+        }
+
+        int dir = cfg.getDirection();
+        if (dir != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.DIRECTION, dir);
+        }
+
+        data.putIntegerProperty(Constants.INIT_VALUE, cfg.getInitValue());
+
+        GPIOPinConfig[] parray = cfg.getPinConfigs();
+        if (parray.length > 0) {
+            RegistryList pinList = new RegistryList();
+            for (int i = 0; i < parray.length; i++) {
+                RegistryData pinData = GPIOPinRegistryFactory.createData(parray[i]);
+                pinList.add(pinData);
+            }
+            data.putListProperty(PINS, pinList);
+        }
+
+        super.putProperties(data, descriptor.getProperties());
+        return data;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/i2cbus/impl/I2CDeviceRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.i2cbus.impl;
+
+import jdk.dio.DeviceConfig;
+import jdk.dio.DeviceDescriptor;
+import jdk.dio.i2cbus.I2CDevice;
+import jdk.dio.i2cbus.I2CDeviceConfig;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.registry.RegistryData;
+import com.oracle.dio.registry.DeviceRegistryFactory;
+import com.oracle.dio.utils.Constants;
+import java.io.IOException;
+
+public final class I2CDeviceRegistryFactory extends DeviceRegistryFactory {
+
+    private static final String ADDRESS = "address";
+    private static final String ADDRESS_SIZE = "addressSize";
+    private static final String CLOCK_FREQUENCY = "clockFrequency";
+    private static final String TYPE_VALUE = "i2cbus.I2CDevice";
+
+    public I2CDeviceRegistryFactory() {}
+
+    public DeviceDescriptor<I2CDevice> createDeviceDescriptor(int id, RegistryData data) throws IOException {
+        String name = data.getCharacterProperty(Constants.NAME);
+        String deviceName = data.getCharacterProperty(Constants.PATH);
+        int address = data.getIntegerProperty(ADDRESS, DeviceConfig.DEFAULT);
+        int addressSize = data.getIntegerProperty(ADDRESS_SIZE, DeviceConfig.DEFAULT);
+        int clockFrequency = data.getIntegerProperty(CLOCK_FREQUENCY, DeviceConfig.DEFAULT);
+
+        I2CDeviceConfig cfg;
+        if (null == deviceName) {
+            int deviceNumber = data.getIntegerProperty(Constants.DEVICE_NUMBER, DeviceConfig.DEFAULT);
+            cfg = new I2CDeviceConfig(deviceNumber, address, addressSize, clockFrequency);
+        } else {
+            cfg = new I2CDeviceConfig(deviceName, address, addressSize, clockFrequency);
+        }
+
+        String[] properties = super.getProperties(data);
+        return new PeripheralDescriptorImpl(id, name, cfg, I2CDevice.class, properties);
+    }
+
+    public RegistryData createRegistryData(DeviceDescriptor descriptor) {
+        I2CDeviceConfig cfg = (I2CDeviceConfig)descriptor.getConfiguration();
+        String name = descriptor.getName();
+
+        RegistryData data = new RegistryData();
+        data.putCharacterProperty(DEVICE_TYPE, TYPE_VALUE);
+
+        if (name != null) {
+            data.putCharacterProperty(Constants.NAME, name);
+        }
+
+        String deviceName = cfg.getControllerName();
+        if (deviceName != null) {
+            data.putCharacterProperty(Constants.PATH, deviceName);
+        }
+        int deviceNumber = cfg.getControllerNumber();
+        if (deviceNumber != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.DEVICE_NUMBER, deviceNumber);
+        }
+        int address = cfg.getAddress();
+        if (address != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(ADDRESS, address);
+        }
+        int addressSize = cfg.getAddressSize();
+        if (addressSize != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(ADDRESS_SIZE, addressSize);
+        }
+        int clockFrequency = cfg.getClockFrequency();
+        if (clockFrequency != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(CLOCK_FREQUENCY, clockFrequency);
+        }
+
+        super.putProperties(data, descriptor.getProperties());
+        return data;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/impl/Event.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.impl;
+
+/**
+ * Base class for all events.
+ */
+public class Event {
+    private byte[] payload;
+
+    /**
+     * Creates event object with payload.
+     * @param payload event payload
+     */
+    public Event(byte[] payload) {
+        this.payload = payload;
+    }
+
+    /**
+     * Creates event object with empty payload.
+     */
+    public Event() {
+        payload = null;
+    }
+
+    /**
+     * Returns event payload. Interpretation of the byte array is left to
+     * component implementation.
+     * @return event payload
+     */
+    public byte[] getPayload() {
+        return payload;
+    }
+
+    void setPayload(byte[] payload) {
+        this.payload = payload;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder();
+
+        if (payload != null) {
+            b.append(" length = ").append(payload.length).append(" bytes =");
+        }
+        for (int i = 0; i < payload.length; i++) {
+            b.append(" ").append(payload[i]);
+        }
+
+        return b.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/impl/EventHandler.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.impl;
+
+/**
+ * Event handler interface.
+ */
+public interface EventHandler {
+    /**
+     * This method is called by EventQueue.dispatch(). Each call is made on a
+     * separate thread.
+     * @param evt a previously queued event to handle
+     * @return
+     */
+    public boolean handleEvent(Event evt);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/impl/EventQueue.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,200 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.impl;
+
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.LinkedList;
+
+/**
+ * Event queue implementation.
+ */
+public class EventQueue {
+    private final ByteBuffer        buffer;
+    private final LinkedList<Event> queue = new LinkedList<>();
+    private final ArrayList<Object> listeners = new ArrayList<>();
+
+    private static final int        SHARED_QUEUE_BUFFER_SIZE = 4096;
+
+    private Thread                  nativeEventThread;
+    private Thread                  eventDispatchThread;
+
+    private static class QueueInstanceHolder {
+        private static EventQueue sharedEventQueue = new EventQueue(SHARED_QUEUE_BUFFER_SIZE);
+    }
+
+    private EventQueue(int bufferSize) {
+        buffer = ByteBuffer.allocateDirect(bufferSize);
+        buffer.position(0).limit(0);
+        startQueue();
+    }
+
+    /**
+     * This method creates new event queue.
+     * @param bufferSize size of the native buffer in bytes
+     * @return event queue
+     */
+    public static EventQueue createEventQueue(int bufferSize) {
+        return new EventQueue(bufferSize);
+    }
+
+    /**
+     * This methods returns the reference to the shared event queue. Actual queue
+     * is lazily created and started upon first call of this method.
+     * @return event queue
+     */
+    public static EventQueue getSharedEventQueue() {
+        return QueueInstanceHolder.sharedEventQueue;
+    }
+
+    private class NativeMethodThread implements Runnable {
+        @Override
+        public void run() {
+            synchronized (buffer) {
+                try {
+                    while (true) {
+                        while (buffer.hasRemaining()) {
+                            Class<? extends Event> eventClass = getEventClass(buffer, buffer.position());
+                            byte[] payload = null;
+                            byte hibyte = buffer.get();
+                            byte lobyte = buffer.get();
+                            short len = (short)((hibyte << 8) | (lobyte & 0xff));
+                            if (len > 0) {
+                                payload = new byte[len];
+                                buffer.get(payload);
+                            }
+                            try {
+                                Event e = eventClass.newInstance();
+                                e.setPayload(payload);
+                                postEvent(e);
+                            } catch (InstantiationException | IllegalAccessException ex) {
+                                // do nothing, just skip
+                            }
+                        }
+                        buffer.position(0).limit(0);
+                        buffer.wait();
+                    }
+                } catch (InterruptedException ex) {
+                    // do nothing on interrupt
+                }
+            }
+        }
+    }
+
+    private class EventDispatchThread implements Runnable {
+        @Override
+        public void run() {
+            while (true) {
+                synchronized (queue) {
+                    try {
+                        if (queue.isEmpty()) {
+                            queue.wait();
+                        }
+
+                        while (!queue.isEmpty()) {
+                            Event evt = queue.poll();
+                            if (evt != null) {
+                                dispatch(evt);
+                            }
+                        }
+                    } catch (InterruptedException ex) {
+                        // do something
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * This method posts event to be asynchronously dispatched. Can be used by
+     * Java components.
+     * @param evt event
+     */
+    public void postEvent(Event evt) {
+        if (evt == null) {
+            throw new IllegalArgumentException();
+        }
+
+        synchronized (queue) {
+            queue.add(evt);
+            queue.notify();
+        }
+    }
+
+    /**
+     * Registers listener for event with specified class.
+     * @param <T> event class
+     * @param evtClass class object of event class
+     * @param handler listener
+     */
+    public <T extends Event> void registerForEvent(Class<T> evtClass, EventHandler handler) {
+        if (evtClass == null || handler == null) {
+            throw new IllegalArgumentException();
+        }
+
+        synchronized (listeners) {
+            listeners.add(evtClass);
+            listeners.add(handler);
+        }
+    }
+
+    private void dispatch(final Event evt) {
+        synchronized (listeners) {
+            for (int i = 0; i < listeners.size(); i += 2) {
+                if (listeners.get(i).equals(evt.getClass())) {
+                    final EventHandler h = (EventHandler)listeners.get(i+1);
+                    new Thread() {
+                        @Override
+                        public void run() {
+                            h.handleEvent(evt);
+                        }
+                    }.start();
+                }
+            }
+        }
+    }
+
+    private void startQueue() {
+        nativeEventThread = new Thread(new NativeMethodThread());
+        nativeEventThread.start();
+        eventDispatchThread = new Thread(new EventDispatchThread());
+        eventDispatchThread.start();
+    }
+
+    /**
+     * Returns native buffer. This is intended solely for components with native
+     * event generating. Java components must not call any methods of the
+     * returned buffer object.
+     * @return native buffer
+     */
+    public Buffer getNativeBuffer() {
+        return buffer;
+    }
+
+    private static native Class<? extends Event> getEventClass(ByteBuffer buffer, int position);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/impl/FakeHandle.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.dio.impl;
+
+/**
+ * Pure Java device handle.
+ */
+public final class FakeHandle extends Handle {
+    static int counter;
+
+    private FakeHandle() {
+    }
+
+    public static synchronized FakeHandle getFakeHandle() {
+        FakeHandle h = new FakeHandle();
+        h.device_reference = counter++;
+        return h;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/impl/Handle.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.dio.impl;
+
+import com.oracle.dio.utils.Constants;
+
+/**
+ * A device handle abstraction with basic operations.
+ */
+public class Handle {
+
+    /** Device native handle */
+    protected int device_reference = Constants.INVALID_HANDLE;
+
+    /** Closes the device */
+    public native void close();
+
+    /** Tries locking the device */
+    public native boolean tryLock(int timeout);
+
+    /** Unlocks the device */
+    public native void unlock();
+
+    /** Returns the device handle */
+    public final int getNativeHandle() {
+        return device_reference;
+    }
+
+    /** Reports if the device is opened or not */
+    public final boolean isOpen() {
+        return device_reference != Constants.INVALID_HANDLE;
+    }
+
+    /** Returns a hash code value for the object. */
+    @Override
+    public int hashCode() {
+        return device_reference;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/impl/Platform.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.dio.impl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public final class Platform {
+    /** Don't let anyone instantiate this class */
+    private Platform() {
+    }
+
+    /** Place any platform specific initialization here */
+    public static void initialize() {
+        // load the main library
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                @Override
+                public Void run() {
+                    System.loadLibrary("dio");
+                    return null;
+                }
+            });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/DeviceRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import jdk.dio.Device;
+import jdk.dio.DeviceDescriptor;
+import java.io.IOException;
+import com.oracle.dio.utils.Constants;
+
+public abstract class DeviceRegistryFactory {
+
+    public static final String DEVICE_TYPE = "deviceType";
+    private static final String FACTORY_POSTFIX = "RegistryFactory";
+
+    public abstract DeviceDescriptor createDeviceDescriptor(int id, RegistryData data) throws IOException;
+
+    public abstract RegistryData createRegistryData(DeviceDescriptor descriptor);
+
+    public static String registryFactoryName(String deviceType) {
+        int pos = deviceType.indexOf('.');
+        if (pos == -1) {
+            return null;
+        }
+        String pack = deviceType.substring(0, pos);
+        String type = deviceType.substring(pos + 1);
+        String factoryName = Constants.FACTORY_PREFIX + pack + Constants.IMPL + type + FACTORY_POSTFIX;
+        return factoryName;
+    }
+
+    public static <T extends Device> String registryFactoryName(Class<T> intf) {
+        String clazz = intf.getName();
+        if (clazz.indexOf(Constants.PREFIX) != 0) {
+            return null;
+        }
+        String deviceType = clazz.substring(Constants.PREFIX.length());
+        return registryFactoryName(deviceType);
+    }
+
+    protected String[] getProperties(RegistryData data) {
+        RegistryList list = data.getListProperty(Constants.PROPERTIES);
+        String[] properties = null;
+        if (list != null && list.size() > 0) {
+            properties = new String[list.size()];
+            try {
+                System.arraycopy(list.toArray(), 0, properties, 0, properties.length);
+            } catch (ArrayStoreException e) {
+                throw new ClassCastException();
+            }
+        }
+        return properties;
+    }
+
+    protected void putProperties(RegistryData data, String[] properties) {
+        if (properties != null && properties.length > 0) {
+            RegistryList list = new RegistryList();
+            for (int i = 0; i < properties.length; i++) {
+                list.add(properties[i]);
+            }
+            data.putListProperty(Constants.PROPERTIES, list);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/RegistrationEventHandlerImpl.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import jdk.dio.Device;
+import jdk.dio.DeviceDescriptor;
+
+class RegistrationEventHandlerImpl<T extends Device> extends RegistrationEventHandler<T> {
+
+    static synchronized void registered(DeviceDescriptor dscr) {
+        if (null != singleton) {
+            singleton.notifyRegistered(dscr);
+        }
+    }
+
+    static synchronized void removed(DeviceDescriptor dscr) {
+        if (null != singleton) {
+            singleton.notifyRemoved(dscr);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/RegistrationEventSenderImpl.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import jdk.dio.DeviceDescriptor;
+
+class RegistrationEventSenderImpl {
+
+    protected void sendRegistered(String initiator, DeviceDescriptor dscr) {
+        RegistrationEventHandlerImpl.registered(dscr);
+    }
+
+    protected void sendUnregistered(String initiator, DeviceDescriptor dscr) {
+        RegistrationEventHandlerImpl.removed(dscr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/RegistryContent.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+final class RegistryContent {
+    private final Hashtable<Integer, RegistryData> entries;
+    private final RegistryData defaults;
+
+    public RegistryContent() {
+        entries = new Hashtable<>();
+        defaults = new RegistryData();
+    }
+
+    public void put(int id, RegistryData data) {
+        entries.put(id, data);
+    }
+
+    public RegistryData get(int id) {
+        return entries.get(id);
+    }
+
+    public void remove(int id) {
+        entries.remove(id);
+    }
+
+    public Enumeration<Integer> entries() {
+        return (Enumeration<Integer>)entries.keys();
+    }
+
+    public void putType(String type, RegistryData typeDefaults) {
+        defaults.putCompoundProperty(type, typeDefaults);
+    }
+
+    public RegistryData getType(String type) {
+        return defaults.getCompoundProperty(type);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/RegistryData.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,153 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+
+public final class RegistryData {
+    private final Hashtable<String, Object> data;
+
+    public RegistryData() {
+        data = new Hashtable<>();
+    }
+
+    private RegistryData(Hashtable<String, Object> data) {
+        this.data = data;
+    }
+
+    public String getCharacterProperty(String key) {
+        return (String)data.get(key);
+    }
+
+    public void putCharacterProperty(String key, String value) {
+        data.put(key, value);
+    }
+
+    public int getIntegerProperty(String key, int def) {
+        return (int)getIntegerProperty(key, (long)def);
+    }
+
+    public long getIntegerProperty(String key, long def) {
+        String value = (String)data.get(key);
+        if (value == null) {
+            return def;
+        }
+        try {
+            int radix = 10;
+            if (value.startsWith("0x")) {
+                value = value.substring(2);
+                radix = 16;
+            }
+            return Long.parseLong(value, radix);
+        } catch (NumberFormatException | IndexOutOfBoundsException e) {
+            return def;
+        }
+    }
+
+    public void putIntegerProperty(String key, long value, int radix) {
+        data.put(key, Long.toString(value, radix));
+    }
+
+    public void putIntegerProperty(String key, int value) {
+        data.put(key, Integer.toString(value));
+    }
+
+    public boolean getBooleanProperty(String key, boolean def) {
+        String value = (String)data.get(key);
+        if (value == null) {
+            return def;
+        }
+        if ("true".equals(value) || "1".equals(value) || "yes".equals(value)) {
+            return true;
+        } else if ("false".equals(value) || "0".equals(value) || "no".equals(value)) {
+            return false;
+        }
+        return def;
+    }
+
+    public void putBooleanProperty(String key, boolean value) {
+        data.put(key, Boolean.toString(value));
+    }
+
+    public RegistryData getCompoundProperty(String key) {
+        return (RegistryData)data.get(key);
+    }
+
+    public void putCompoundProperty(String key, RegistryData value) {
+        data.put(key, value);
+    }
+
+    public RegistryList getListProperty(String key) {
+        return (RegistryList)data.get(key);
+    }
+
+    public void putListProperty(String key, RegistryList value) {
+        data.put(key, value);
+    }
+
+    public Enumeration<String> keys() {
+        return (Enumeration<String>)data.keys();
+    }
+
+    public boolean hasProperty(String key) {
+        return data.containsKey(key);
+    }
+
+    public boolean isEmpty() {
+        return data.isEmpty();
+    }
+
+    public void copyProperty(String key, RegistryData source) {
+        Object value = source.data.get(key);
+        data.put(key, value);
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer output = new StringBuffer();
+        Enumeration<String> keys = (Enumeration<String>)data.keys();
+        while (keys.hasMoreElements()) {
+            String key = keys.nextElement();
+            output.append(key + ':');
+            Object value = data.get(key);
+            if (value instanceof RegistryData) {
+                output.append('{');
+                output.append(value.toString());
+                output.append('}');
+            } else {
+                output.append(value.toString());
+            }
+            output.append(',');
+        }
+        return output.toString();
+    }
+
+    @Override
+    public Object clone() {
+        return new RegistryData((Hashtable<String, Object>)data.clone());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/RegistryImpl.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,353 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import jdk.dio.Device;
+import jdk.dio.DeviceConfig;
+import jdk.dio.DeviceDescriptor;
+import jdk.dio.UnsupportedDeviceTypeException;
+import java.lang.ref.WeakReference;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Enumeration;
+import java.util.Vector;
+import java.util.Collection;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.utils.Configuration;
+import com.oracle.dio.utils.Constants;
+
+class RegistryImpl<T extends Device> extends Registry<T> {
+
+    private static final String REGISTRY_FILE_PATH = "jdk.dio.registry";
+    private static final String PREDEFINED = "predefined";
+
+    private WeakReference<Properties> registryCache;
+    private WeakReference<RegistryContent> contentCache;
+
+    @Override
+    public synchronized DeviceDescriptor<? super T> get(int id) {
+        Properties registry = loadRegistry();
+        RegistryContent content = readRegistryContent(registry);
+        return createDescriptor(id, content);
+    }
+
+    @Override
+    public synchronized Iterator<DeviceDescriptor<? super T>> get(String name, Class<T> intf, String... properties) {
+        return createDescriptorList(name, intf, properties);
+    }
+
+    @Override
+    public synchronized void register(int id, Class<T> intf,
+                                      DeviceConfig<? super T> config,
+                                      String name,
+                                      String... properties)
+                                      throws UnsupportedOperationException, IOException {
+        Properties registry = loadRegistry();
+        RegistryContent content = readRegistryContent(registry);
+        String factory = DeviceRegistryFactory.registryFactoryName(intf);
+        if (factory == null) {
+            throw new UnsupportedDeviceTypeException("Unsupported type: " + intf.getName());
+        }
+        DeviceDescriptor<? super T> descriptor = new PeripheralDescriptorImpl(id, name, config, intf, properties);
+        RegistryData data = null;
+        try {
+            data = ((DeviceRegistryFactory)Class.forName(factory).newInstance()).createRegistryData(descriptor);
+        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
+            throw new UnsupportedDeviceTypeException("Unsupported type: " + intf.getName());
+        }
+        content.put(id, data);
+        registry.setProperty(Integer.toString(id), data.toString());
+        try {
+            saveRegistry(registry);
+        } catch (Exception e) {
+            content.remove(id);
+            registry.remove(Integer.toString(id));
+            throw e;
+        }
+    }
+
+    @Override
+    public synchronized void unregister(int id) {
+        Properties registry = loadRegistry();
+        RegistryContent content = readRegistryContent(registry);
+        RegistryData config = content.get(id);
+        if (config == null) {
+            return;
+        }
+        if (config.getBooleanProperty(PREDEFINED, false)) {
+            throw new IllegalArgumentException("Device cannot be unregistered");
+        }
+        content.remove(id);
+        registry.remove(Integer.toString(id));
+        try {
+            saveRegistry(registry);
+        } catch (IOException e) {
+        }
+    }
+
+    @Override
+    public synchronized Iterator<DeviceDescriptor<? super T>> list(Class<T> intf) {
+        return createDescriptorList(null, intf);
+    }
+
+    private Properties loadRegistry() {
+        Properties registry = null;
+        if (registryCache != null) {
+            registry = registryCache.get();
+        }
+        if (registry == null) {
+            registry = new Properties();
+            try {
+                String path = Configuration.getSystemProperty(REGISTRY_FILE_PATH);
+                if (path != null) {
+                    registry.load(new InputStreamReader(new FileInputStream(path)));
+                }
+            } catch (IOException | SecurityException | IllegalArgumentException e) {
+                registry.clear();
+            }
+            registryCache = new WeakReference(registry);
+        }
+        return registry;
+    }
+
+    private void saveRegistry(Properties registry) throws IOException {
+        String path = Configuration.getSystemProperty(REGISTRY_FILE_PATH);
+        if (path == null) {
+            throw new IOException("Registry is not available");
+        }
+        registry.store(new OutputStreamWriter(new FileOutputStream(path)), null);
+    }
+
+    private RegistryContent readRegistryContent(Properties registry) {
+        RegistryContent content = null;
+        if (contentCache != null) {
+            content = contentCache.get();
+        }
+        if (content == null) {
+            content = new RegistryContent();
+            Enumeration<?> names = registry.propertyNames();
+            while (names.hasMoreElements()) {
+                String name = (String)names.nextElement();
+                if (!name.isEmpty()) {
+                    String value = registry.getProperty(name);
+                    processProperty(name, value, content);
+                }
+            }
+            contentCache = new WeakReference(content);
+        }
+        return content;
+    }
+
+    private void processProperty(String name, String value, RegistryContent content) {
+        try {
+            int id = Integer.parseInt(name);
+            processEntryProperty(id, value, content);
+        } catch(NumberFormatException e) {
+            processTypeProperty(name, value, content);
+        }
+    }
+
+    private void processEntryProperty(int id, String value, RegistryContent content) {
+        RegistryData data = new RegistryData();
+        parseBlock(value, data);
+        if (!data.isEmpty()) {
+            content.put(id, data);
+        }
+    }
+
+    private void processTypeProperty(String name, String value, RegistryContent content) {
+        RegistryData data = new RegistryData();
+        parseBlock(value, data);
+        if (!data.isEmpty()) {
+            content.putType(name, data);
+        }
+    }
+
+    private static void parseBlock(String block, RegistryData data) {
+        while (true) {
+            int inc = 2, pos = block.indexOf("\\:");
+            if (pos == -1) {
+                inc = 1; pos = block.indexOf(':');
+                if (pos == -1) {
+                    break;
+                }
+            }
+            String key = block.substring(0, pos).trim();
+            block = block.substring(pos + inc).trim();
+            if (block.charAt(0) == '[') {
+                int end = block.indexOf(']');
+                if (end == -1) {
+                    break;
+                }
+                RegistryList list = new RegistryList();
+                parseList(block.substring(1, end).trim(), list);
+                if (!list.isEmpty()) {
+                    data.putListProperty(key, list);
+                }
+                pos = block.indexOf(',', end + 1);
+                if (pos == -1) {
+                    break;
+                }
+                block = block.substring(pos + 1).trim();
+            } else {
+                int end = block.indexOf(',');
+                String value;
+                if (end == -1) {
+                    value = block;
+                    block = "";
+                } else {
+                    value = block.substring(0, end).trim();
+                    block = block.substring(end + 1).trim();
+                }
+                if (!value.isEmpty()) {
+                    data.putCharacterProperty(key, value);
+                }
+            }
+        }
+    }
+
+    private static void parseList(String block, RegistryList list) {
+        while (!block.isEmpty()) {
+            if (block.charAt(0) == '{') {
+                int pos = block.indexOf('}');
+                if (pos == -1) {
+                    break;
+                }
+                RegistryData data = new RegistryData();
+                parseBlock(block.substring(1, pos), data);
+                if (!data.isEmpty()) {
+                    list.add(data);
+                }
+                int end = block.indexOf(',', pos + 1);
+                if (end == -1) {
+                    break;
+                }
+                block = block.substring(end + 1).trim();
+            } else if (block.charAt(0) == '\"') {
+                int pos = block.indexOf('\"', 1);
+                if (pos == -1) {
+                    break;
+                }
+                String value = block.substring(1, pos).trim();
+                if (!value.isEmpty()) {
+                    list.add(value);
+                }
+                int end = block.indexOf(',', pos);
+                if (end == -1) {
+                    break;
+                }
+                block = block.substring(end + 1).trim();
+            } else {
+                break;
+            }
+        }
+    }
+
+    private DeviceDescriptor createDescriptor(int id, RegistryContent content) {
+        RegistryData config = content.get(id);
+        if (config == null) {
+            return null;
+        }
+        String type = config.getCharacterProperty(DeviceRegistryFactory.DEVICE_TYPE);
+        if (type == null) {
+            return null;
+        }
+        String factory = DeviceRegistryFactory.registryFactoryName(type);
+        if (factory == null) {
+            return null;
+        }
+        RegistryData defaults = content.getType(type);
+        if (defaults != null) {
+            config = (RegistryData)config.clone();
+            Enumeration<String> keys = defaults.keys();
+            while (keys.hasMoreElements()) {
+                String key = (String)keys.nextElement();
+                if (!config.hasProperty(key)) {
+                    config.copyProperty(key, defaults);
+                }
+            }
+        }
+        try {
+            return ((DeviceRegistryFactory)Class.forName(factory).newInstance()).createDeviceDescriptor(id, config);
+        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | ClassCastException | IOException e) {
+            return null;
+        }
+    }
+
+    private Iterator<DeviceDescriptor<? super T>> createDescriptorList(String name, Class<T> intf, String... properties) {
+        Collection<DeviceDescriptor<? super T>> result = new Vector<>();
+        Properties registry = loadRegistry();
+        RegistryContent content = readRegistryContent(registry);
+        Enumeration<Integer> entries = content.entries();
+        while (entries.hasMoreElements()) {
+            int id = entries.nextElement().intValue();
+            RegistryData config = content.get(id);
+            if (intf != null) {
+                String deviceType = config.getCharacterProperty(DeviceRegistryFactory.DEVICE_TYPE);
+                if (deviceType == null || intf.getName().indexOf(deviceType) == -1) {
+                    continue;
+                }
+            }
+            if (name != null) {
+                String deviceName = config.getCharacterProperty(Constants.NAME);
+                if (deviceName == null || !deviceName.equals(name)) {
+                    continue;
+                }
+            }
+            DeviceDescriptor<? super T> descriptor = createDescriptor(id, content);
+            if (descriptor == null) {
+                continue;
+            }
+            if (properties != null && properties.length > 0) {
+                String[] descriptorProps = descriptor.getProperties();
+                if (descriptorProps == null || descriptorProps.length == 0) {
+                    continue;
+                }
+                boolean match = true;
+                for (int i = 0; match && (i < properties.length); i++) {
+                    match = false;
+                    for (int j = 0; j < descriptorProps.length; j++) {
+                        if (properties[i].equalsIgnoreCase(descriptorProps[j])) {
+                            match = true;
+                            break;
+                        }
+                    }
+                }
+                if (!match) {
+                    continue;
+                }
+            }
+            result.add(descriptor);
+        }
+        return result.iterator();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/registry/RegistryList.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.registry;
+
+import java.util.Vector;
+import java.util.Enumeration;
+import java.util.Arrays;
+
+public final class RegistryList {
+    private final Vector data;
+
+    public RegistryList() {
+        data = new Vector();
+    }
+
+    private RegistryList(Vector data) {
+        this.data = data;
+    }
+
+    public void add(Object element) {
+        data.add(element);
+    }
+
+    public int size() {
+        return data.size();
+    }
+
+    public boolean isEmpty() {
+        return data.isEmpty();
+    }
+
+    public Enumeration<?> elements() {
+        return data.elements();
+    }
+
+    public Object[] toArray() {
+        return data.toArray();
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer output = new StringBuffer();
+        output.append('[');
+        Enumeration<?> elements = data.elements();
+        while (elements.hasMoreElements()) {
+            Object element = elements.nextElement();
+            if (element instanceof RegistryData) {
+                output.append('{');
+                output.append(element.toString());
+                output.append('}');
+            } else {
+                output.append('\"');
+                output.append(element.toString());
+                output.append('\"');
+            }
+            output.append(',');
+        }
+        output.append(']');
+        return output.toString();
+    }
+
+    @Override
+    public Object clone() {
+        return new RegistryList((Vector)data.clone());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/spibus/impl/SPIDeviceRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.spibus.impl;
+
+import jdk.dio.DeviceConfig;
+import jdk.dio.DeviceDescriptor;
+import jdk.dio.spibus.SPIDevice;
+import jdk.dio.spibus.SPIDeviceConfig;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.registry.RegistryData;
+import com.oracle.dio.registry.DeviceRegistryFactory;
+import com.oracle.dio.utils.Constants;
+import java.io.IOException;
+
+public final class SPIDeviceRegistryFactory extends DeviceRegistryFactory {
+
+    private static final String CLOCK_MODE = "clockMode";
+    private static final String WORD_LENGTH = "wordLength";
+    private static final String BIT_ORDERING = "bitOrdering";
+    private static final String CS_ACTIVE = "csActive";
+    private static final String TYPE_VALUE = "spibus.SPIDevice";
+
+    public SPIDeviceRegistryFactory() {}
+
+    public DeviceDescriptor<SPIDevice> createDeviceDescriptor(int id, RegistryData data) throws IOException {
+        String name = data.getCharacterProperty(Constants.NAME);
+        String deviceName = data.getCharacterProperty(Constants.PATH);
+        int address = data.getIntegerProperty(Constants.ADDRESS, DeviceConfig.DEFAULT);
+        int clockFrequency = data.getIntegerProperty(Constants.CLOCK_FREQUENCY, DeviceConfig.DEFAULT);
+        int clockMode = data.getIntegerProperty(CLOCK_MODE, DeviceConfig.DEFAULT);
+        int wordLength = data.getIntegerProperty(WORD_LENGTH, DeviceConfig.DEFAULT);
+        int bitOrdering = data.getIntegerProperty(BIT_ORDERING, DeviceConfig.DEFAULT);
+        int csActive = data.getIntegerProperty(CS_ACTIVE, DeviceConfig.DEFAULT);
+
+        SPIDeviceConfig cfg;
+        if (null == deviceName) {
+            int deviceNumber = data.getIntegerProperty(Constants.DEVICE_NUMBER, DeviceConfig.DEFAULT);
+            cfg = new SPIDeviceConfig(deviceNumber, address, csActive, clockFrequency, clockMode, wordLength, bitOrdering);
+        } else {
+            cfg = new SPIDeviceConfig(deviceName, address, csActive, clockFrequency, clockMode, wordLength, bitOrdering);
+        }
+
+        String[] properties = super.getProperties(data);
+        return new PeripheralDescriptorImpl(id, name, cfg, SPIDevice.class, properties);
+    }
+
+    public RegistryData createRegistryData(DeviceDescriptor descriptor) {
+        SPIDeviceConfig cfg = (SPIDeviceConfig)descriptor.getConfiguration();
+        String name = descriptor.getName();
+
+        RegistryData data = new RegistryData();
+        data.putCharacterProperty(DEVICE_TYPE, TYPE_VALUE);
+
+        if (name != null) {
+            data.putCharacterProperty(Constants.NAME, name);
+        }
+
+        String deviceName = cfg.getControllerName();
+        if (deviceName != null) {
+            data.putCharacterProperty(Constants.PATH, deviceName);
+        }
+        int deviceNumber = cfg.getControllerNumber();
+        if (deviceNumber != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.DEVICE_NUMBER, deviceNumber);
+        }
+        int address = cfg.getAddress();
+        if (address != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.ADDRESS, address);
+        }
+        int clockFrequency = cfg.getClockFrequency();
+        if (clockFrequency != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.CLOCK_FREQUENCY, clockFrequency);
+        }
+        int clockMode = cfg.getClockMode();
+        if (clockMode != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(CLOCK_MODE, clockMode);
+        }
+        int wordLength = cfg.getWordLength();
+        if (wordLength != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(WORD_LENGTH, wordLength);
+        }
+        int bitOrdering = cfg.getBitOrdering();
+        if (bitOrdering != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(BIT_ORDERING, bitOrdering);
+        }
+        int csActive = cfg.getCSActiveLevel();
+        if (csActive != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(CS_ACTIVE, csActive);
+        }
+
+        super.putProperties(data, descriptor.getProperties());
+        return data;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/uart/impl/ModemSignalDispatcher.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.dio.uart.impl;
+
+import com.oracle.dio.utils.Constants;
+import com.oracle.dio.impl.EventQueue;
+import com.oracle.dio.impl.EventHandler;
+import com.oracle.dio.impl.Event;
+import java.util.*;
+import java.nio.Buffer;
+
+/**
+ * Serial signal proxy
+ * @see SerialSignalListener
+ */
+class ModemSignalDispatcher implements EventHandler {
+
+    /**
+     * Serial signal event listener
+     */
+    static interface SerialSignalListener {
+
+        /**
+         * This method is called on any change of the corresponding signal line of the serial interface.
+         *
+         * @param signalLine signal line
+         * @param state state of the signal
+         */
+        void signalChanged(int signalLine, boolean state);
+
+    }
+
+    synchronized static ModemSignalDispatcher getInstance() {
+        if (instance == null) {
+            instance = new ModemSignalDispatcher();
+        }
+        return instance;
+    }
+
+    private static ModemSignalDispatcher instance;
+    private static final int QUEUE_BUFFER_SIZE = 4096;
+    private final EventQueue queue =
+                             EventQueue.createEventQueue(QUEUE_BUFFER_SIZE);
+
+    private ModemSignalDispatcher() {
+        queue.registerForEvent(SignalEvent.class, this);
+    }
+
+    private static class SerialContext {
+
+        /** Serial signal context */
+        final int context;
+
+        /** Serial signal listeners */
+        final List<SerialSignalListener> listeners = new ArrayList<SerialSignalListener>();
+
+        SerialContext(int context) {
+            this.context = context;
+        }
+    }
+
+    private Map<Integer, SerialContext> contextMap = new HashMap<Integer, SerialContext>();
+
+    private List<SerialSignalListener> getListeners(int serialHandler) {
+        return contextMap.get(serialHandler).listeners;
+    }
+
+    private int getContext(int serialHandler) {
+        return contextMap.get(serialHandler).context;
+    }
+
+    /**
+     * Register a listener to receive state changes of a modem signal line,
+     *
+     * @param serialHandler serial port handler
+     * @param listener serial signal listener
+     */
+    synchronized void addListener(int serialHandler, SerialSignalListener listener) {
+        if (! contextMap.containsKey(serialHandler)) {
+            int context = startListening(serialHandler);
+            contextMap.put(serialHandler, new SerialContext(context));
+        }
+
+        List<SerialSignalListener> listeners = getListeners(serialHandler);
+        if (! listeners.contains(listener)) {
+            listeners.add(listener);
+        }
+    }
+
+    /**
+     * Remove a listener,
+     *
+     * @param serialHandler serial port handler
+     * @param listener serial signal listener
+     */
+    synchronized void removeListener(int serialHandler, SerialSignalListener listener) {
+        if (contextMap.containsKey(serialHandler)) {
+            List<SerialSignalListener> listeners = getListeners(serialHandler);
+            listeners.remove(listener);
+
+            if (listeners.isEmpty()) {
+                int context = getContext(serialHandler);
+                stopListening(context);
+                contextMap.remove(serialHandler);
+            }
+        }
+    }
+
+    /**
+     * Starts serial signal listening
+     *
+     * @param serialHandler serial port handler
+     * @return handler of serial signal context
+     */
+    private int startListening(int serialHandler) {
+        return startListening0(serialHandler);
+    }
+
+    /**
+     * Stops serial signal listening
+     *
+     * @param context handler of serial signal context
+     */
+    private void stopListening(int context) {
+        if (context != Constants.INVALID_HANDLE) {
+            stopListening0(context);
+        }
+    }
+
+    private static class SignalEvent extends Event {
+        int getHandler() {
+            byte[] payload = getPayload();
+            int handler = (((int)payload[0]) << 24) | (((int)payload[1]) << 16) |
+                          (((int)payload[2]) << 8 ) | (((int)payload[3]));
+            return handler;
+        }
+        int getLine() {
+            byte[] payload = getPayload();
+            int line = (((int)payload[4]) << 24) | (((int)payload[5]) << 16) |
+                       (((int)payload[6]) << 8 ) | (((int)payload[7]));
+            return line;
+        }
+        boolean getState() {
+            byte[] payload = getPayload();
+            boolean state =  payload[8] != 0;
+            return state;
+        }
+    }
+
+    /**
+     * This method is called by EventQueue.dispatch(). Each call is made on a
+     * separate thread.
+     * @param event a previously queued event to handle
+     */
+    public boolean handleEvent(Event event) {
+        SignalEvent e = (SignalEvent)event;
+
+        int serialHandler = e.getHandler();
+        int signalLine = e.getLine();
+        boolean signalState = e.getState();
+
+        synchronized(this) {
+            List<SerialSignalListener> listeners = getListeners(serialHandler);
+            Iterator<SerialSignalListener> iter = listeners.iterator();
+            while (iter.hasNext()) {
+                iter.next().signalChanged(signalLine, signalState);
+            }
+        }
+        return true;
+    }
+
+    static {
+        setNativeEntries(instance.queue.getNativeBuffer(), SignalEvent.class);
+    }
+
+    private static native void setNativeEntries(Buffer buffer,
+                                                Class<SignalEvent> eventClass);
+
+    /**
+     * Starts serial signal listening
+     *
+     * @param serialHandler serial port handler
+     * @return handler of serial signal context
+     */
+    private native int startListening0(int serialHandler);
+
+    /**
+     * Stops serial signal listening
+     *
+     * @param context handler of serial signal context
+     */
+    private native void stopListening0(int context);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/uart/impl/ModemUARTRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.uart.impl;
+
+import jdk.dio.uart.UART;
+import jdk.dio.uart.ModemUART;
+import jdk.dio.uart.UARTConfig;
+import jdk.dio.DeviceDescriptor;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.registry.RegistryData;
+import com.oracle.dio.registry.DeviceRegistryFactory;
+import com.oracle.dio.utils.Constants;
+import java.io.IOException;
+
+public final class ModemUARTRegistryFactory extends DeviceRegistryFactory {
+
+    private static final String TYPE_VALUE = "uart.ModemUART";
+
+    public ModemUARTRegistryFactory() {}
+
+    public DeviceDescriptor<UART> createDeviceDescriptor(int id, RegistryData data) throws IOException {
+        String name = data.getCharacterProperty(Constants.NAME);
+        String[] properties = super.getProperties(data);
+        return new PeripheralDescriptorImpl(id, name, UARTRegistryFactory.createConfig(data), ModemUART.class, properties);
+    }
+
+    public RegistryData createRegistryData(DeviceDescriptor descriptor) {
+        UARTConfig cfg = (UARTConfig)descriptor.getConfiguration();
+        String name = descriptor.getName();
+
+        RegistryData data = UARTRegistryFactory.createData(cfg);
+        data.putCharacterProperty(DEVICE_TYPE, TYPE_VALUE);
+
+        if (name != null) {
+            data.putCharacterProperty(Constants.NAME, name);
+        }
+
+        super.putProperties(data, descriptor.getProperties());
+        return data;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/uart/impl/UARTEventHandler.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.dio.uart.impl;
+
+import com.oracle.dio.impl.EventQueue;
+import com.oracle.dio.impl.EventHandler;
+import com.oracle.dio.impl.Event;
+import java.util.Hashtable;
+import java.nio.Buffer;
+
+class UARTEventHandler implements EventHandler {
+
+    private static class UARTHash {
+        final int port;
+        final int eventType;
+        final int hash;
+
+        UARTHash(int port, int eventType) {
+            this.port = port;
+            this.eventType = eventType;
+            long lHash = 17 + port;
+            lHash = 17 * lHash + eventType;
+            hash = (int)lHash;
+        }
+
+        @Override
+        public int hashCode() {
+            return hash;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (obj instanceof UARTHash) {
+                return (((UARTHash)obj).port == port &&
+                        ((UARTHash)obj).eventType == eventType);
+            } else {
+                return super.equals(obj);
+            }
+        }
+    }
+
+    private final Hashtable<UARTHash, UARTImpl> listenerRegistry = new Hashtable();
+    private static final UARTEventHandler instance = new UARTEventHandler();
+    private static final int QUEUE_BUFFER_SIZE = 4096;
+    private final EventQueue queue =
+                             EventQueue.createEventQueue(QUEUE_BUFFER_SIZE);
+
+    static UARTEventHandler getInstance() {
+        return instance;
+    }
+
+    private UARTEventHandler() {
+        queue.registerForEvent(UARTEvent.class, this);
+    }
+
+    void addEventListener(int eventType, UARTImpl uart) {
+        if (null == uart) {
+            throw new NullPointerException("uart == null");
+        }
+        int port = uart.getHandle().getNativeHandle();
+        listenerRegistry.put(new UARTHash(port, eventType), uart);
+    }
+
+    UARTImpl getEventListener(int port, int eventType) {
+        return listenerRegistry.get(new UARTHash(port, eventType));
+    }
+
+    void removeEventListener(int eventType, UARTImpl uart) {
+        int port = uart.getHandle().getNativeHandle();
+        listenerRegistry.remove(new UARTHash(port, eventType));
+    }
+
+    private static class UARTEvent extends Event {
+        int getPort() {
+            byte[] payload = getPayload();
+            int port = (((int)payload[0]) << 24) | (((int)payload[1]) << 16) |
+                       (((int)payload[2]) << 8 ) | (((int)payload[3]));
+            return port;
+        }
+        int getEventType() {
+            byte[] payload = getPayload();
+            int type = (((int)payload[4]) << 24) | (((int)payload[5]) << 16) |
+                       (((int)payload[6]) << 8 ) | (((int)payload[7]));
+            return type;
+        }
+        int getBytesProcessed() {
+            byte[] payload = getPayload();
+            int bytes = (((int)payload[8])  << 24) | (((int)payload[9]) << 16) |
+                        (((int)payload[10]) << 8 ) | (((int)payload[11]));
+            return bytes;
+        }
+    }
+
+    /**
+     * This method is called by EventQueue.dispatch(). Each call is made on a
+     * separate thread.
+     * @param event a previously queued event to handle
+     */
+    public boolean handleEvent(Event event) {
+        UARTEvent e = (UARTEvent)event;
+        int port = e.getPort();
+        int type = e.getEventType();
+        int bytesProcessed = e.getBytesProcessed();
+        UARTImpl uart = listenerRegistry.get(new UARTHash(port, type));
+        if (uart != null) {
+            uart.processEvent(type, bytesProcessed);
+        }
+        return true;
+    }
+
+    static {
+        setNativeEntries(instance.queue.getNativeBuffer(), UARTEvent.class);
+    }
+
+    private static native void setNativeEntries(Buffer buffer,
+                                                Class<UARTEvent> eventClass);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/uart/impl/UARTRegistryFactory.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.uart.impl;
+
+import jdk.dio.DeviceConfig;
+import jdk.dio.DeviceDescriptor;
+import jdk.dio.uart.UART;
+import jdk.dio.uart.UARTConfig;
+import com.oracle.dio.impl.PeripheralDescriptorImpl;
+import com.oracle.dio.registry.RegistryData;
+import com.oracle.dio.registry.DeviceRegistryFactory;
+import com.oracle.dio.utils.Constants;
+import java.io.IOException;
+
+public final class UARTRegistryFactory extends DeviceRegistryFactory {
+
+    private static final String BAUD_RATE = "baudRate";
+    private static final String DATA_BITS = "dataBits";
+    private static final String FLOW_CONTROL = "flowControl";
+    private static final String PARITY = "parity";
+    private static final String STOP_BITS = "stopBits";
+    private static final String TYPE_VALUE = "uart.UART";
+
+    public UARTRegistryFactory() {}
+
+    public DeviceDescriptor<UART> createDeviceDescriptor(int id, RegistryData data) throws IOException {
+        String name = data.getCharacterProperty(Constants.NAME);
+        String[] properties = super.getProperties(data);
+        return new PeripheralDescriptorImpl(id, name, createConfig(data), UART.class, properties);
+    }
+
+    public RegistryData createRegistryData(DeviceDescriptor descriptor) {
+        UARTConfig cfg = (UARTConfig)descriptor.getConfiguration();
+        String name = descriptor.getName();
+
+        RegistryData data = createData(cfg);
+        data.putCharacterProperty(DEVICE_TYPE, TYPE_VALUE);
+
+        if (name != null) {
+            data.putCharacterProperty(Constants.NAME, name);
+        }
+
+        super.putProperties(data, descriptor.getProperties());
+        return data;
+    }
+
+    static UARTConfig createConfig(RegistryData data) {
+        String deviceName = data.getCharacterProperty(Constants.PATH);
+        int baudRate = data.getIntegerProperty(BAUD_RATE, DeviceConfig.DEFAULT);
+        int dataBits = data.getIntegerProperty(DATA_BITS, DeviceConfig.DEFAULT);
+        int flowControl = data.getIntegerProperty(FLOW_CONTROL, DeviceConfig.DEFAULT);
+        int parity = data.getIntegerProperty(PARITY, DeviceConfig.DEFAULT);
+        int stopBits = data.getIntegerProperty(STOP_BITS, DeviceConfig.DEFAULT);
+        int channelNumber = data.getIntegerProperty(Constants.CHANNEL_NUMBER, DeviceConfig.DEFAULT);
+
+        UARTConfig cfg;
+        if (null == deviceName) {
+            int deviceNumber = data.getIntegerProperty(Constants.DEVICE_NUMBER, DeviceConfig.DEFAULT);
+            cfg = new UARTConfig(deviceNumber, channelNumber, baudRate, dataBits, parity, stopBits, flowControl);
+        } else {
+            cfg = new UARTConfig(deviceName, channelNumber, baudRate, dataBits, parity, stopBits, flowControl);
+        }
+
+        return cfg;
+    }
+
+    static RegistryData createData(UARTConfig cfg) {
+        RegistryData data = new RegistryData();
+
+        String deviceName = cfg.getControllerName();
+        if (deviceName != null) {
+            data.putCharacterProperty(Constants.PATH, deviceName);
+        }
+        int deviceNumber = cfg.getControllerNumber();
+        if (deviceNumber != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.DEVICE_NUMBER, deviceNumber);
+        }
+        int baudRate = cfg.getBaudRate();
+        if (baudRate != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(BAUD_RATE, baudRate);
+        }
+        int dataBits = cfg.getDataBits();
+        if (dataBits != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(DATA_BITS, dataBits);
+        }
+        int flowControl = cfg.getFlowControlMode();
+        if (flowControl != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(FLOW_CONTROL, flowControl);
+        }
+        int parity = cfg.getParity();
+        if (parity != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(PARITY, parity);
+        }
+        int stopBits = cfg.getStopBits();
+        if (stopBits != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(STOP_BITS, stopBits);
+        }
+        int channelNumber = cfg.getChannelNumber();
+        if (channelNumber != DeviceConfig.DEFAULT) {
+            data.putIntegerProperty(Constants.CHANNEL_NUMBER, channelNumber);
+        }
+
+        return data;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/utils/Configuration.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Properties;
+import java.util.Enumeration;
+
+public final class Configuration {
+
+    /** Don't let anyone instantiate this class */
+    private Configuration() {
+    }
+
+    /**
+     * Gets the implementation property indicated by the specified key.
+     *
+     * @param      key   the name of the implementation property.
+     * @return     the string value of the implementation property,
+     *             or <code>null</code> if there is no property with that key.
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static String getProperty(String key) {
+        return System.getProperty(key);
+    }
+
+    /**
+     * Returns system property value by the given key using a privileged call.
+     *
+     * @param key property key
+     * @return property value
+     */
+    public static String getSystemProperty(String key) {
+        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+                public String run() {
+                    return System.getProperty(key);
+                }
+            });
+    }
+
+    /**
+     * Gets the implementation property indicated by the specified key or
+     * returns the specified default value.
+     *
+     * @param      key   the name of the implementation property.
+     * @param      def   the default value for the property if not
+     *                  specified in the configuration files or command
+     *                  line over rides.
+     * @return     the string value of the implementation property,
+     *             or <code>def</code> if there is no property with that key.
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static String getPropertyDefault(String key, String def) {
+        return System.getProperty(key, def);
+    }
+
+    /**
+     * Gets the implementation property indicated by the specified key or
+     * returns the specified default value as an positive int.
+     *
+     * @param      key   the name of the implementation property.
+     * @param      def   the default value for the property if not
+     *                  specified in the configuration files or command
+     *                  line over rides.
+     *
+     * @return     the int value of the implementation property,
+     *             or <code>def</code> if there is no property with that key or
+     *             the config value is not a positive int (zero is not
+     *             positive).
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static int getPositiveIntProperty(String key, int def) {
+        int value = Configuration.getIntProperty(key, def);
+        return (value > 0 ? value : def);
+    }
+
+    /**
+     * Gets the implementation property indicated by the specified key or
+     * returns the specified default value as an nonzero int.
+     *
+     * @param      key   the name of the implementation property.
+     * @param      def   the default value for the property if not
+     *                  specified in the configuration files or command
+     *                  line over rides.
+     * @return     the int value of the implementation property,
+     *             or <code>def</code> if there is no property with that key or
+     *             the config value is not an int.
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static int getNonNegativeIntProperty(String key, int def) {
+        int value = Configuration.getIntProperty(key, def);
+        return (value >= 0 ? value : def);
+    }
+
+    /**
+     * Gets the implementation property indicated by the specified key or
+     * returns the specified default value as an int.
+     *
+     * @param      key   the name of the implementation property.
+     * @param      def   the default value for the property if not
+     *                  specified in the configuration files or command
+     *                  line over rides.
+     *
+     * @return     the int value of the implementation property,
+     *             or <code>def</code> if there is no property with that key or
+     *             the config value is not an int.
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static int getIntProperty(String key, int def) {
+        String value = System.getProperty(key);
+        if (value != null) {
+            try {
+                return Integer.valueOf(value).intValue();
+            } catch (NumberFormatException e) {
+            }
+        }
+        return def;
+    }
+
+    /**
+     * Gets the implementation property indicated by the specified key or
+     * returns the specified default value as a boolean.
+     *
+     * @param      key   the name of the implementation property.
+     * @param      def   the default value for the property if not
+     *                  specified in the configuration files or command
+     *                  line over rides.
+     *
+     * @return     the boolean value of the implementation property,
+     *             or <code>def</code> if there is no property with that key or
+     *             the config value is not a boolean.
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static boolean getBoolProperty(String key, boolean def) {
+        String value = System.getProperty(key);
+        if (value != null) {
+            try {
+                return Boolean.valueOf(value).booleanValue();
+            } catch (NumberFormatException e) {
+            }
+        }
+        return def;
+    }
+
+    /**
+     * Set the implementation property indicated by the specified key.
+     *
+     * @param      key   the name of the implementation property.
+     * @param      val   the value of the implementation property.
+     *
+     * @exception  NullPointerException if <code>key</code> is
+     *             <code>null</code>.
+     * @exception  IllegalArgumentException if <code>key</code> is empty.
+     */
+    public static void setProperty(String key, String val) {
+        System.setProperty(key, val);
+    }
+
+    /**
+     * Gets all system properties names.
+     *
+     * @return  the string contains space separated system properties list
+     */
+    public static String getSystemPropertiesNames() {
+        Properties props = AccessController.doPrivileged(new PrivilegedAction<Properties>() {
+                public Properties run() {
+                    return System.getProperties();
+                }
+            });
+        String result = new String();
+        try {
+            Enumeration<?> names = props.propertyNames();
+            while (names.hasMoreElements()) {
+                result += (String)names.nextElement() + " ";
+            }
+        } catch (ClassCastException e) {
+        }
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/utils/ExceptionMessage.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,304 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+public final class ExceptionMessage {
+    private ExceptionMessage() {}
+
+    public static String format(int format, Object... parameters) {
+        return String.format(strings[format], parameters);
+    }
+
+    public static final int DEVICE_FIRST = 0;
+    public static final int DEVICE_LOCKED_BY_OTHER_APP               = DEVICE_FIRST + 0;
+    public static final int DEVICE_NULL_CONFIG_OR_INTF               = DEVICE_FIRST + 1;
+    public static final int DEVICE_CONFIG_PROBLEM                    = DEVICE_FIRST + 2;
+    public static final int DEVICE_EXCLUSIVE_MODE_UNSUPPORTED        = DEVICE_FIRST + 3;
+    public static final int DEVICE_NULL_INTF                         = DEVICE_FIRST + 4;
+    public static final int DEVICE_NOT_FOUND                         = DEVICE_FIRST + 5;
+    public static final int DEVICE_HAS_DIFFERENT_TYPE                = DEVICE_FIRST + 6;
+    public static final int DEVICE_NULL_NAME_AND_PROPERTIES          = DEVICE_FIRST + 7;
+    public static final int DEVICE_INVALID_ID                        = DEVICE_FIRST + 8;
+    public static final int DEVICE_NONUNIQUE_ID                      = DEVICE_FIRST + 9;
+    public static final int DEVICE_ALREADY_EXISTING_CONFIG           = DEVICE_FIRST + 10;
+    public static final int DEVICE_NEGATIVE_ID                       = DEVICE_FIRST + 11;
+    public static final int DEVICE_INVALID_CLASSNAME                 = DEVICE_FIRST + 12;
+    public static final int DEVICE_FAULT_CONFIG_INSTANCE             = DEVICE_FIRST + 13;
+    public static final int DEVICE_FOUND_BUT_PERIPHERAL_IS_BUSY      = DEVICE_FIRST + 14;
+    public static final int DEVICE_DRIVERS_NOT_MATCH                 = DEVICE_FIRST + 15;
+    public static final int DEVICE_DRIVER_MISSING                    = DEVICE_FIRST + 16;
+    public static final int DEVICE_NULL_ACTIONS                      = DEVICE_FIRST + 17;
+    public static final int DEVICE_NULL_NAME                         = DEVICE_FIRST + 18;
+    public static final int DEVICE_EMPTY_ACTIONS                     = DEVICE_FIRST + 19;
+    public static final int DEVICE_INVALID_PERMISSION                = DEVICE_FIRST + 20;
+    public static final int DEVICE_READONLY_PERMISSION_COLLECTION    = DEVICE_FIRST + 21;
+    public static final int DEVICE_OPEN_WITH_DEVICENAME_UNSUPPORTED  = DEVICE_FIRST + 22;
+    public static final int DEVICE_LAST = DEVICE_OPEN_WITH_DEVICENAME_UNSUPPORTED;
+
+    public static final int ADC_FIRST = DEVICE_LAST + 1;
+    public static final int ADC_ANOTHER_OPERATION_PROGRESS           = ADC_FIRST + 0;
+    public static final int ADC_NONPOSITIVE_INTERVAL                 = ADC_FIRST + 1;
+    public static final int ADC_LESS_MINIMAL_INTERVAL                = ADC_FIRST + 2;
+    public static final int ADC_CANNOT_START_ACQUISITION             = ADC_FIRST + 3;
+    public static final int ADC_ARGUMENT_LOW_GREATER_THAN_HIGH       = ADC_FIRST + 4;
+    public static final int ADC_BUFFER_NO_SPACE                      = ADC_FIRST + 5;
+    public static final int ADC_LAST = ADC_BUFFER_NO_SPACE;
+
+    public static final int ATCMD_FIRST = ADC_LAST + 1;
+    public static final int ATCMD_DATA_CONNECTION_UNSUPPORTED        = ATCMD_FIRST + 0;
+    public static final int ATCMD_LAST = ATCMD_DATA_CONNECTION_UNSUPPORTED;
+
+    public static final int COUNTER_FIRST = ATCMD_LAST + 1;
+    public static final int COUNTER_INVALID_CONTROLLER_NUMBER        = COUNTER_FIRST + 0;
+    public static final int COUNTER_INVALID_CHANNEL_NUMBER           = COUNTER_FIRST + 1;
+    public static final int COUNTER_INVALID_TYPE                     = COUNTER_FIRST + 2;
+    public static final int COUNTER_CONFIG_CANNOT_BE_USED            = COUNTER_FIRST + 3;
+    public static final int COUNTER_NOT_STARTED                      = COUNTER_FIRST + 4;
+    public static final int COUNTER_NOT_SUSPENDED                    = COUNTER_FIRST + 5;
+    public static final int COUNTER_IS_STARTED                       = COUNTER_FIRST + 6;
+    public static final int COUNTER_NONPOSITIVE_LIMIT_AND_INTERVAL   = COUNTER_FIRST + 7;
+    public static final int COUNTER_NULL_LISTENER                    = COUNTER_FIRST + 8;
+    public static final int COUNTER_IS_SUSPENDED                     = COUNTER_FIRST + 9;
+    public static final int COUNTER_LAST = COUNTER_IS_SUSPENDED;
+
+    public static final int DAC_FIRST = COUNTER_LAST + 1;
+    public static final int DAC_GENERATION_IS_ACTIVE                 = DAC_FIRST + 0;
+    public static final int DAC_NO_BUFFER_DATA                       = DAC_FIRST + 1;
+    public static final int DAC_NONPOSITIVE_INTERVAL                 = DAC_FIRST + 2;
+    public static final int DAC_LESS_MINIMAL_INTERVAL                = DAC_FIRST + 3;
+    public static final int DAC_UNACCEPTABLE_VALUE                   = DAC_FIRST + 4;
+    public static final int DAC_CANNOT_START_CONVERSION              = DAC_FIRST + 5;
+    public static final int DAC_LAST = DAC_CANNOT_START_CONVERSION;
+
+    public static final int GPIO_FIRST = DAC_LAST + 1;
+    public static final int GPIO_TRIGGER_OR_MODE                     = GPIO_FIRST + 0;
+    public static final int GPIO_MODE_NOT_FOR_DIRINPUTONLY           = GPIO_FIRST + 1;
+    public static final int GPIO_MODE_NOT_FOR_DIROUTPUTONLY          = GPIO_FIRST + 2;
+    public static final int GPIO_MODE_NOT_FOR_DIRBOTH                = GPIO_FIRST + 3;
+    public static final int GPIO_INVALID_DIRECTION                   = GPIO_FIRST + 4;
+    public static final int GPIO_ILLEGAL_DIRECTION_OR_INIT_VALUE     = GPIO_FIRST + 5;
+    public static final int GPIO_DIR_UNSUPPORTED_BY_PIN_CONFIG       = GPIO_FIRST + 6;
+    public static final int GPIO_SET_TO_INPUT_PIN                    = GPIO_FIRST + 7;
+    public static final int GPIO_REGISTER_LISTENER_TO_OUTPUT_PIN     = GPIO_FIRST + 8;
+    public static final int GPIO_CANNOT_START_NOTIFICATION           = GPIO_FIRST + 9;
+    public static final int GPIO_LISTENER_ALREADY_ASSIGNED           = GPIO_FIRST + 10;
+    public static final int GPIO_DIR_SHOULD_BE_INPUT_OR_OUTPUT       = GPIO_FIRST + 11;
+    public static final int GPIO_INCOMPATIBLE_DIR                    = GPIO_FIRST + 12;
+    public static final int GPIO_WRITE_TO_INPUT_PORT                 = GPIO_FIRST + 13;
+    public static final int GPIO_REGISTER_LISTENER_TO_OUTPUT_PORT    = GPIO_FIRST + 14;
+    public static final int GPIO_LAST = GPIO_REGISTER_LISTENER_TO_OUTPUT_PORT;
+
+    public static final int I2CBUS_FIRST = GPIO_LAST + 1;
+    public static final int I2CBUS_ALREADY_TRANSFERRED_MESSAGE       = I2CBUS_FIRST + 0;
+    public static final int I2CBUS_NULL_BUFFER                       = I2CBUS_FIRST + 1;
+    public static final int I2CBUS_NEGATIVE_SKIP_ARG                 = I2CBUS_FIRST + 2;
+    public static final int I2CBUS_DIFFERENT_BUS_SLAVE_OPERATION     = I2CBUS_FIRST + 3;
+    public static final int I2CBUS_BUFFER_GIVEN_TWICE                = I2CBUS_FIRST + 4;
+    public static final int I2CBUS_EMPTY_COMBINE_MESSAGE             = I2CBUS_FIRST + 5;
+    public static final int I2CBUS_LAST = I2CBUS_EMPTY_COMBINE_MESSAGE;
+
+    public static final int MMIO_FIRST = I2CBUS_LAST + 1;
+    public static final int MMIO_NEGATIVE_SIZE                       = MMIO_FIRST + 0;
+    public static final int MMIO_NEGATIVE_OFFSET                     = MMIO_FIRST + 1;
+    public static final int MMIO_INVALID_TYPE                        = MMIO_FIRST + 2;
+    public static final int MMIO_INVALID_DEVICE_PARAMETERS           = MMIO_FIRST + 3;
+    public static final int MMIO_ADDRESS_ACCESS_NOT_ALLOWED          = MMIO_FIRST + 4;
+    public static final int MMIO_REGISTER_TYPE_UNSUPPORTED           = MMIO_FIRST + 5;
+    public static final int MMIO_INVALID_BLOCK_PARAMETERS            = MMIO_FIRST + 6;
+    public static final int MMIO_MIXED_ENDIANNESS_UNSUPPORTED        = MMIO_FIRST + 7;
+    public static final int MMIO_INVALID_INDEX                       = MMIO_FIRST + 8;
+    public static final int MMIO_LAST = MMIO_INVALID_INDEX;
+
+    public static final int POWER_FIRST = MMIO_LAST + 1;
+    public static final int POWER_INVALID_STATE_MASK                 = POWER_FIRST + 0;
+    public static final int POWER_INVALID_STATE                      = POWER_FIRST + 1;
+    public static final int POWER_INVALID_DURATION                   = POWER_FIRST + 2;
+    public static final int POWER_ALREADY_ASSIGNED_HANDLER           = POWER_FIRST + 3;
+    public static final int POWER_STANDBY_MODE                       = POWER_FIRST + 4;
+    public static final int POWER_LAST = POWER_STANDBY_MODE;
+
+    public static final int PWM_FIRST = POWER_LAST + 1;
+    public static final int PWM_OUTPUT_PIN_NOT_CONFIGURED            = PWM_FIRST + 0;
+    public static final int PWM_NONPOSITIVE_PERIOD                   = PWM_FIRST + 1;
+    public static final int PWM_OUT_OF_RANGE_PERIOD                  = PWM_FIRST + 2;
+    public static final int PWM_ILLEGAL_WIDTH_OR_COUNT               = PWM_FIRST + 3;
+    public static final int PWM_NULL_SRC                             = PWM_FIRST + 4;
+    public static final int PWM_NULL_LISTENER                        = PWM_FIRST + 5;
+    public static final int PWM_NO_DATA                              = PWM_FIRST + 6;
+    public static final int PWM_NULL_SRC1_OR_SRC2                    = PWM_FIRST + 7;
+    public static final int PWM_GENERATION_SESSION_ACTIVE            = PWM_FIRST + 8;
+    public static final int PWM_LAST = PWM_GENERATION_SESSION_ACTIVE;
+
+    public static final int SPIBUS_FIRST = PWM_LAST + 1;
+    public static final int SPIBUS_NULL_BUFFER                       = SPIBUS_FIRST + 0;
+    public static final int SPIBUS_SLAVE_WORD_LENGTH                 = SPIBUS_FIRST + 1;
+    public static final int SPIBUS_BYTE_NUMBER_BELIES_WORD_LENGTH    = SPIBUS_FIRST + 2;
+    public static final int SPIBUS_LAST = SPIBUS_BYTE_NUMBER_BELIES_WORD_LENGTH;
+
+    public static final int UART_FIRST = SPIBUS_LAST + 1;
+    public static final int UART_FAULT_PREFIX_PROPERTY               = UART_FIRST + 0;
+    public static final int UART_UTF8_UNCONVERTIBLE_DEVNAME          = UART_FIRST + 1;
+    public static final int UART_NULL_SRC_OR_LISTENER                = UART_FIRST + 2;
+    public static final int UART_NULL_SRC1_OR_SRC2_OR_LISTENER       = UART_FIRST + 3;
+    public static final int UART_NULL_DST                            = UART_FIRST + 4;
+    public static final int UART_NULL_SRC                            = UART_FIRST + 5;
+    public static final int UART_ACTIVE_READ_OPERATION               = UART_FIRST + 6;
+    public static final int UART_ACTIVE_WRITE_OPERATION              = UART_FIRST + 7;
+    public static final int UART_UNKNOWN_SIGNAL_ID                   = UART_FIRST + 8;
+    public static final int UART_SIGNALS_NOT_BITWISE_COMBINATION     = UART_FIRST + 0;
+    public static final int UART_LISTENER_ALREADY_REGISTERED         = UART_FIRST + 10;
+
+    private static final String strings[] = {
+
+        // core classes messages
+        "Locked by other application",
+        "config or intf is null",
+        "There is problem with configuration: %s",
+        "EXCLUSIVE access mode is not supported",
+        "intf is null",
+        "Device %s not found",
+        "Device %d has different type %s",
+        "Name and properties are NULL",
+        "id is not equal to UNSPECIFIED_ID or is not greater than or equal to 0",
+        "Device ID must be unique",
+        "There is configuration with such name, type and proprties",
+        "Device ID must be positive or 0",
+        "Invalid class name: %s",
+        "Invalid instance of DeviceConfig class",
+        "Device found by driver loader but peripheral is busy",
+        "Neither embedded nor installed driver knows about peripheral",
+        "There is no driver",
+        "actions is null",
+        "Name is null",
+        "actions are empty",
+        "Invalid permission class: %s",
+        "Cannot add a Permission to a readonly PermissionCollection",
+        "Opening with deviceName is unsupported",
+
+        // adc messages
+        "Another operation on ADC channel is in progress",
+        "'interval' is negative or 0",
+        "'interval' is less than minimal sampling interval",
+        "Cannot start acquisition",
+        "Argument 'low' is greater than 'high'",
+        "No free space in buffer",
+
+        // atcmd messages
+        "Emulator does not support data connection",
+
+        // counter messages
+        "Invalid controllerNumber",
+        "Invalid channelNumber",
+        "Invalid type",
+        "Provided config cannot be used as pulse input",
+        "Counting has not been started yet",
+        "Counting wasn't suspended",
+        "Counting is already started",
+        "Both limit and interval are equal or less than 0",
+        "Counting listener is null",
+        "Counting is already suspended",
+
+        // dac messages
+        "Generation is already active",
+        "No data in buffer",
+        "'interval' is negative or 0",
+        "'interval' is less than minimal sampling interval",
+        "'value' is out of an allowed range",
+        "Cannot start conversion",
+
+        // gpio messages
+        "Trigger or mode",
+        "mode is not for DIR_INPUT_ONLY",
+        "mode is not for DIR_OUTPUT_ONLY",
+        "mode is not for DIR_BOTH: %d",
+        "Invalid direction",
+        "Illegal direction or initValue",
+        "Pin config does not support required direction",
+        "Try to Set value to input pin",
+        "Try to register Listener to output pin",
+        "Cannot start notification",
+        "The listener is already assigned",
+        "Direction should be INPUT or OUTPUT",
+        "Incompatible direction",
+        "Trying to write to input port",
+        "Try to register Listener to output port",
+
+        // i2c bus messages
+        "the message has already been transferred once",
+        "buffer is null",
+        "'skip' argument is negative",
+        "operation to a slave on a different bus",
+        "the same buffer is given twice",
+        "combine message is empty",
+
+        // mmio messages
+        "size is negative",
+        "offset is negative",
+        "Invalid type: %s",
+        "Invalid MMIO device parameters",
+        "Address access is not allowed: %d, %d",
+        "Unsupported register type: %s",
+        "Invalid block parameters",
+        "Mixed endiannes is not supported",
+        "invalid index value",
+
+        // power messages
+        "Invalid power state mask %d",
+        "Invalid power state %d",
+        "Invalid duration",
+        "Handler is already assigned",
+        "Standby mode",
+
+        // pwm messages
+        "output pin is not configured for output",
+        "Period %d is negative or zero ",
+        "Period %d is out of the supported range",
+        "width or count is illegal",
+        "src buffer is null ",
+        "listener is null",
+        "No data in the buffer",
+        "src1 or src2 buffer is null",
+        "pulse generation session is already active",
+
+        // spi bus messages
+        "Buffer is null",
+        "Slave Word Length is %d",
+        "the number of bytes to receive/send belies word length",
+
+        // uart messages
+        "Unable to read mandatory property deviceaccess.uart.prefix",
+        "Unable to convert dev name to UTF-8",
+        "src buffer or listener is null",
+        "src1, src2 buffer or listener is null",
+        "dst buffer is null",
+        "src buffer is null",
+        "another synchronous or asynchronous read operation is already active",
+        "another synchronous or asynchronous write operation is already active",
+        "signalID is not one of the defined values",
+        "signals is not a bit-wise combination of valid signal IDs.",
+        "listener is not null and a listener is already registered",
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/utils/InterIsolateMutex.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+/**
+ * A wrapper class for named mutex that provides limited inter-Isolate synchronization.
+ */
+public final class InterIsolateMutex {
+
+    private InterIsolateMutex() {
+    }
+
+    /**
+     * Gets mutex instance. For any given mutex name, the method returnes the
+     * same mutex per Isolate.
+     */
+    public static InterIsolateMutex getInstance(String mutexName) {
+        return new InterIsolateMutex();
+    }
+
+    /**
+     * Locks mutex. Throws an exception if the mutex is already locked in the
+     * same Isolate.
+     */
+    public void lock() {
+        //  stubbed, unless this feature is required
+    }
+
+    /** Unlocks mutex. */
+    public void unlock() {
+        //  stubbed, unless this feature is required
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/utils/Logging.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+public final class Logging {
+
+    /** Don't let anyone instantiate this class */
+    private Logging() {
+    }
+
+    public static void reportError(String message) {
+        //  add an implementation
+    }
+
+    public static void reportError(String message1, String message2) {
+        //  add an implementation
+    }
+
+    public static void reportWarning(String message) {
+        //  add an implementation
+    }
+
+    public static void reportWarning(String message1, String message2) {
+        //  add an implementation
+    }
+
+    public static void reportInformation(String message) {
+        //  add an implementation
+    }
+
+    public static void reportInformation(String message1, String message2) {
+        //  add an implementation
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/utils/PrivilegeController.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+import java.io.IOException;
+
+public final class PrivilegeController {
+
+    /** Don't let anyone instantiate this class */
+    private PrivilegeController() {
+    }
+
+    public static <T> T doPrivileged(final PrivilegedAction<T> action)
+        throws IOException {
+
+        final IOException exception[] = {null};
+        T result = (T) java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction() {
+                public Object run() {
+                    try {
+                        return (Object) action.run();
+                    } catch (IOException e) {
+                        exception[0] = e;
+                        return null;
+                    }
+                }
+            });
+        if (exception[0] != null) {
+            throw exception[0];
+        }
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/com/oracle/dio/utils/PrivilegedAction.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.oracle.dio.utils;
+
+import java.io.IOException;
+
+public interface PrivilegedAction<T> {
+    T run() throws IOException;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/impl/romizer/DontRenameClass.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package romizer;
+
+public @interface DontRenameClass {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/impl/romizer/DontRenameMethod.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package romizer;
+
+public @interface DontRenameMethod {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/impl/romizer/Hidden.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package romizer;
+
+public @interface Hidden {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/classes/serializator/SerializeMe.java	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package serializator;
+
+public @interface SerializeMe {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/linux/native/com/oracle/dio/javacall_platform_defs.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __JAVACALL_PLATFORM_DEFINE_H_
+#define __JAVACALL_PLATFORM_DEFINE_H_
+
+#include <string.h>
+
+/**
+ * @file javacall_platform_defs.h
+ * @ingroup Common
+ * @brief Platform-dependent definitions for javacall
+ */
+
+/**
+ * @defgroup Platform Platfrom specific Common Javacall API Definitions
+ * @ingroup Common
+ * The platform specific common javacall definitions are defined in this file
+ * @{
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define JAVACALL_LOG_INFORMATION 0
+#define JAVACALL_LOG_WARNING 1
+#define JAVACALL_LOG_ERROR 2
+#define JAVACALL_LOG_CRITICAL 3
+#define JAVACALL_LOG_DISABLED 4
+
+/**
+ * @typedef javacall_utf16
+ * @brief general unicode string type
+ */
+typedef unsigned short javacall_utf16;
+
+/**
+ * @typedef javacall_uint8
+ * @brief 8 bit unsigned interger type
+ */
+typedef unsigned char javacall_uint8;
+
+/**
+ * @typedef javacall_int8
+ * @brief 8 bit signed interger type
+ */
+typedef char javacall_int8;
+
+/**
+ * @typedef javacall_uint16
+ * @brief 16 bit unsigned interger type
+ */
+typedef unsigned short javacall_uint16;
+
+/**
+ * @typedef javacall_uint32
+ * @brief 32 bit unsigned interger type
+ */
+typedef unsigned long javacall_uint32;
+
+/**
+ * @typedef javacall_uint64
+ * @brief 64 bit unsigned integer type
+ */
+typedef unsigned long long javacall_uint64;
+
+/**
+ * @typedef javacall_int16
+ * @brief 16 bit signed interger type
+ */
+typedef signed short javacall_int16;
+
+/**
+ * @typedef javacall_int32
+ * @brief 32 bit interger type
+ */
+typedef signed long javacall_int32;
+
+/**
+ * @typedef javacall_int64
+ * @brief 64 bit interger type
+ */
+typedef long long javacall_int64;
+
+/**
+ * @def JAVACALL_MAX_HOST_LENGTH
+ *
+ */
+#define JAVACALL_MAX_HOST_LENGTH (256)
+
+/**
+ * @def JAVACALL_MAX_URL_LENGTH
+ *
+ */
+#define JAVACALL_MAX_URL_LENGTH 512
+
+/**
+ * @def JAVACALL_MAX_ACCESS_POINTS
+ * Maximal number of access points defined on the device
+ */
+#define JAVACALL_MAX_ACCESS_POINTS         16
+
+/**
+ * @def JAVACALL_MAX_EVENT_SIZE
+ * Maximal length of event data
+ */
+#define JAVACALL_MAX_EVENT_SIZE        512
+
+/**
+ * @def JAVACALL_MAX_FILE_NAME_LENGTH
+ * Maximal length of file name supported
+ */
+#define JAVACALL_MAX_FILE_NAME_LENGTH         256
+
+/**
+ * @def JAVACALL_MAX_ILLEGAL_FILE_NAME_CHARS
+ * Maximal number of illegal chars
+ */
+#define JAVACALL_MAX_ILLEGAL_FILE_NAME_CHARS  256
+
+/**
+ * @def JAVACALL_MAX_ROOTS_LIST_LENGTH
+ * Maximal length of a list of file system roots
+ */
+#define JAVACALL_MAX_ROOTS_LIST_LENGTH  8192
+
+/**
+ * @def JAVACALL_MAX_ROOT_PATH_LENGTH
+ * Maximal length of a file system root path
+ */
+#define JAVACALL_MAX_ROOT_PATH_LENGTH   256
+
+/**
+ * @def JAVACALL_MAX_LOCALIZED_ROOTS_LIST_LENGTH
+ * Maximal length of a list of localized names of file system roots
+ */
+#define JAVACALL_MAX_LOCALIZED_ROOTS_LIST_LENGTH  8192
+
+/**
+ * @def JAVACALL_MAX_LOCALIZED_DIR_NAME_LENGTH
+ * Maximal length of a localized name of a special directory
+ */
+#define JAVACALL_MAX_LOCALIZED_DIR_NAME_LENGTH    512
+
+/**
+ * @def JAVACALL_PIM_MAX_ARRAY_ELEMENTS
+ *
+ */
+#define JAVACALL_PIM_MAX_ARRAY_ELEMENTS (10)
+/**
+ * @def JAVACALL_PIM_MAX_ATTRIBUTES
+ *
+ */
+#define JAVACALL_PIM_MAX_ATTRIBUTES     (15)
+/**
+ * @def JAVACALL_PIM_MAX_FIELDS
+ *
+ */
+#define JAVACALL_PIM_MAX_FIELDS         (19)
+
+
+/**
+ * @def JAVACALL_FONT_SIZE_SMALL
+ *
+ */
+#define JAVACALL_FONT_SIZE_SMALL    8
+/**
+ * @def JAVACALL_FONT_SIZE_MEDIUM
+ *
+ */
+#define JAVACALL_FONT_SIZE_MEDIUM   12
+/**
+ * @def JAVACALL_FONT_SIZE_LARGE
+ *
+ */
+#define JAVACALL_FONT_SIZE_LARGE    16
+
+/**
+ * @def JAVACALL_INVALID_NETWORK_HANDLE
+ * Defines platform specific invalid socket/datagram handle
+ *
+ * IMPL_NOTE: this value is reserved and should not used
+ * as valid handle value
+ */
+#define JAVACALL_INVALID_NETWORK_HANDLE ((javacall_handle)-1)
+
+/**
+ * @def JAVACALL_PROPERTIES_FILENAME
+ */
+#define JAVACALL_PROPERTIES_FILENAME \
+    {'j', 'w', 'c', '_', 'p', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's',\
+     '.', 'i', 'n', 'i', '\0'}
+
+#define NOT_USED(var)                   ((void)var)
+
+#ifdef ENABLE_DEVICEACCESS
+/**
+ * Maximum length of peripheral name
+ */
+#define JAVACALL_DEVICEACCESS_MAX_NAME_LEN 32
+#endif
+
+
+#define javautil_strlen strlen
+#define javautil_strcpy strcpy
+#define javautil_strcat strcat
+#define javautil_strcmp strcmp
+#define javautil_stricmp stricmp
+#define javautil_memset memset
+#define javautil_memcpy memcpy
+
+#ifdef _DEBUG
+#include <assert.h>
+#define ASSERT(_t) assert(_t)
+#else
+#define ASSERT(_t)
+#endif
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/linux/native/com/oracle/dio/memory.c	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdlib.h>
+
+#include "javacall_defs.h"
+#include "javacall_memory.h"
+#include "javacall_logging.h"
+
+/**
+ * Allocates large memory heap
+ * VM will use this memory heap for internal memory allocation/deallocation
+ * Will be called ONCE during VM startup!
+ *
+ * @param    size required heap size in bytes
+ * @param    outSize actual size of memory allocated
+ * @return        a pointer to the newly allocated memory, or <tt>0</tt> if not available
+ */
+void* javacall_memory_heap_allocate(long size, /*OUT*/ long* outSize) {
+    void* mem = (void *)malloc(size);
+
+    *outSize = mem ? size : 0;
+    return mem;
+}
+
+/**
+ * Free large memory heap
+ * VM will call this function once when VM is shutdown to free large memory heap
+ * Will be called ONCE during VM shutdown!
+ *
+ * @param    heap memory pointer to free
+ */
+void javacall_memory_heap_deallocate(void* heap) {
+    free(heap);
+}
+
+
+#if !ENABLE_MEMORY_POOL
+/**
+ * Allocates memory of the given size from the private JAVACALL memory
+ * pool.
+ *
+ * @param    size Number of byte to allocate
+ * @return        a pointer to the newly allocated memory
+ */
+void* /*OPTIONAL*/ javacall_malloc(unsigned int size){
+    if(0 == size) {
+        JAVACALL_REPORT_WARN(JC_MEMORY, "javacall_malloc << try to allocate 0 bytes");
+        return NULL;
+    }
+    return (void *)malloc(size);
+}
+
+/**
+ * Frees memory at the given pointer in the private JAVACALL memory pool.
+ *
+ * @param    ptr        Pointer to allocated memory
+ */
+void  /*OPTIONAL*/ javacall_free(void* ptr) {
+    free(ptr);
+}
+
+/**
+ * Checks JAVACALL memory pool for consistency and correctness.
+ *
+ * @retval  JAVACALL_TRUE    JAVACALL memory pool is correct
+ * @retval  JAVACALL_FALSE   JAVACALL memory pool structure is damaged
+ */
+javacall_bool /*OPTIONAL*/ javacall_memory_is_correct() {
+    return JAVACALL_TRUE;
+}
+
+/**
+ * Allocates and clears the given number of elements of the given size
+ * from the private JAVACALL memory pool.
+ *
+ * @param    numberOfElements Number of elements to allocate
+ * @param    elementSize Size of one element
+ * @return        pointer to the newly allocated and cleared memory
+ */
+void* /*OPTIONAL*/ javacall_calloc(unsigned int numberOfElements, unsigned int elementSize ) {
+        return calloc(numberOfElements, elementSize);
+}
+
+/**
+ * Re-allocates memory at the given pointer location in the private
+ * JAVACALL memory pool (or null for new memory) so that it is the given
+ * size.
+ *
+ * @param  ptr          Original memory pointer
+ * @param  size         New size
+ * @return        pointer to the re-allocated memory
+ */
+void* /*OPTIONAL*/ javacall_realloc(void* ptr, unsigned int size) {
+        return realloc(ptr,size);
+}
+
+/**
+ * Duplicates the given string after allocating the memory for it.
+ *
+ * @param    str        String to duplicate
+ * @return      pointer to the duplicate string
+ */
+char* /*OPTIONAL*/ javacall_strdup(const char* str) {
+    return strdup(str);
+}
+
+#endif /* !ENABLE_MEMORY_POOL */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/linux/native/com/oracle/dio/os.c	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>  /* symbolic names of errors */
+#include <pthread.h>
+
+#include "javacall_memory.h"
+#include "javacall_os.h"
+
+#if ENABLE_FLUSH_ICACHE
+#if TARGET_CPU_ARM
+void arm_flush_icache_eabi(void *start, void *end); // same API as __clear_cache in GCC
+#endif
+#endif
+
+extern void javacall_logging_initialize(void);
+/*
+ * Initialize the OS structure.
+ * This is where timers and threads get started for the first
+ * real_time_tick event, and where signal handlers and other I/O
+ * initialization should occur.
+ *
+*/
+void javacall_os_initialize(void){
+    javacall_logging_initialize();
+    return;
+}
+
+
+/*
+ * Performs a clean-up of all threads and other OS related activity
+ * to allow for a clean and complete restart.  This should undo
+ * all the work that initialize does.
+ */
+void javacall_os_dispose(){
+    return;
+}
+
+/**
+ * Exits calling OS process the VM is running in.
+ * @param status the exit status aligned with POSIX systems convention
+ */
+void javacall_os_exit(int status){
+    exit(status);
+}
+
+/**
+ * javacall_os_flush_icache is used, for example, to flush any caches used by a
+ * code segment that is deoptimized or moved during a garbage collection.
+ * flush at least [address, address + size] (may flush complete icache).
+ *
+ * @param address   Start address to flush
+ * @param size      Size to flush
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_FAIL in case of an error
+ */
+javacall_result javacall_os_flush_icache(unsigned char* address, int size) {
+#if ENABLE_FLUSH_ICACHE
+#if TARGET_CPU_ARM
+    arm_flush_icache_eabi(address, address+size);
+#endif
+/*
+    #if ARM_EXECUTABLE
+#if ENABLE_BRUTE_FORCE_ICACHE_FLUSH
+  // This is a brute-force way of flushing the icache. The function
+  // brute_flush_icache() contains 64KB of no-ops.
+  volatile int x;
+  volatile int * ptr = (int*)brute_force_flush_icache;
+  for (int i=0; i<8192; i++) {
+    // flush writeback cache, too.
+    x = *ptr++;
+  }
+  brute_force_flush_icache(); // IMPL_NOTE: jump to brute_flush_icache() + xx
+                              // if size is small ...
+#elif defined(__NetBSD__)
+  // arch-specific syscall from libarm
+  arm_sync_icache((unsigned int)start, size);
+#else
+  // This is in assembly language
+  arm_flush_icache(start, size);
+#endif
+#endif // ARM_EXECUTABLE
+
+  // Valgrind deploys VM technology with JITter so when after modify ourselves
+  // let Valgrind know about it
+#if ENABLE_VALGRIND
+  VALGRIND_DISCARD_TRANSLATIONS(start, size);
+#endif
+*/
+#endif
+    return JAVACALL_OK;
+}
+
+/**
+ * Returns a handle that uniquely identifies the current thread.
+ * @return current thread handle
+ */
+javacall_handle javacall_os_thread_self() {
+  return (javacall_handle)pthread_self();
+}
+
+/* Internal structure of a mutex */
+struct _javacall_mutex {
+    pthread_mutex_t mutex;
+};
+
+/* Internal structure of a condition variable */
+struct _javacall_cond {
+    pthread_cond_t condvar;
+    struct _javacall_mutex *mutex;
+};
+
+/* Debug stuff */
+#ifndef NDEBUG
+#define PRINT_ERROR(func_,text_,code_)    \
+    fprintf(stderr, \
+        "%s: %s: error=%s (#%d)\n", \
+        __FUNCTION__, #func_, text_, code_)
+
+#define REPORT_ERROR(func_)   do {\
+    PRINT_ERROR(func_,err2str(err),err); \
+} while (0)
+
+static char *err2str(int i);
+
+#else
+#define PRINT_ERROR(func_,text_,code_)
+#define REPORT_ERROR(func_)
+#endif
+
+/* creates a POSIX mutex */
+javacall_mutex javacall_os_mutex_create() {
+    struct _javacall_mutex *m = javacall_malloc(sizeof *m);
+    int err;
+
+    if (m == NULL) {
+        PRINT_ERROR(javacall_malloc, "No memory", 0);
+        return NULL;
+    }
+    if ((err = pthread_mutex_init(&m->mutex, NULL)) != 0) {
+        REPORT_ERROR(pthread_mutex_init);
+        javacall_free(m);
+        return NULL;
+    }
+    return m;
+}
+
+/* destroys the mutex */
+void javacall_os_mutex_destroy(struct _javacall_mutex *m) {
+    int err;
+
+    if (m == NULL) {
+      PRINT_ERROR(javacall_os_mutex_destroy, "Null mutex", 0);
+      return;
+    }
+    if ((err = pthread_mutex_destroy(&m->mutex)) != 0) {
+        REPORT_ERROR(pthread_mutex_destroy);
+    } else {
+        javacall_free(m);
+    }
+}
+
+/* locks the mutex */
+javacall_result javacall_os_mutex_lock(struct _javacall_mutex *m) {
+    int err;
+
+    if (m == NULL) {
+      PRINT_ERROR(javacall_os_mutex_lock, "Null mutex", 0);
+      return JAVACALL_FAIL;
+    }
+
+    if ((err = pthread_mutex_lock(&m->mutex)) != 0) {
+        REPORT_ERROR(pthread_mutex_lock);
+        return JAVACALL_FAIL;
+    }
+    return JAVACALL_OK;
+}
+
+/* tries to lock the mutex */
+javacall_result javacall_os_mutex_try_lock(struct _javacall_mutex *m) {
+    int err;
+
+    if (m == NULL) {
+      PRINT_ERROR(javacall_os_mutex_try_lock, "Null mutex", 0);
+      return JAVACALL_FAIL;
+    }
+
+    if ((err = pthread_mutex_trylock(&m->mutex)) != 0 && err != EBUSY) {
+        REPORT_ERROR(pthread_mutex_trylock);
+        return JAVACALL_FAIL;
+    }
+    return err == EBUSY ? JAVACALL_WOULD_BLOCK : JAVACALL_OK;
+}
+
+/* unlocks the mutex */
+javacall_result javacall_os_mutex_unlock(struct _javacall_mutex *m) {
+    int err;
+
+    if (m == NULL) {
+      PRINT_ERROR(javacall_os_mutex_unlock, "Null mutex", 0);
+      return JAVACALL_FAIL;
+    }
+
+    if ((err = pthread_mutex_unlock(&m->mutex)) != 0) {
+        REPORT_ERROR(pthread_mutex_lock);
+    }
+    return err;
+}
+
+/* creates a POSIX condvar */
+javacall_cond javacall_os_cond_create(struct _javacall_mutex *m) {
+    struct _javacall_cond *c = javacall_malloc(sizeof *c);
+    int err;
+
+    if (c == NULL) {
+        PRINT_ERROR(javacall_os_cond_create, "No memory", 0);
+        return NULL;
+    }
+    if (m == NULL) {
+      PRINT_ERROR(javacall_os_cond_create, "Null mutex", 0);
+      javacall_free(c);
+      return NULL;
+    }
+
+    if ((err = pthread_cond_init(&c->condvar, NULL)) != 0) {
+        REPORT_ERROR(pthread_cond_init);
+        javacall_free(c);
+        return NULL;
+    }
+    c->mutex = m;
+    return c;
+}
+
+/* just returns the saved mutex */
+javacall_mutex javacall_os_cond_get_mutex(struct _javacall_cond *c) {
+    return c->mutex;
+}
+
+/* destroys the condvar */
+void javacall_os_cond_destroy(struct _javacall_cond *c) {
+    int err;
+
+    if (c == NULL) {
+      PRINT_ERROR(javacall_os_cond_destroy, "Null mutex", 0);
+      return;
+    }
+
+    if ((err = pthread_cond_destroy(&c->condvar)) != 0) {
+        REPORT_ERROR(pthread_cond_destroy);
+    } else {
+        javacall_free(c);
+    }
+}
+
+/* waits for condition. */
+javacall_result javacall_os_cond_wait(struct _javacall_cond *c, long millis) {
+    int err;
+/* denominators */
+#define milli_denom   ((long long)1000)
+#define micro_denom   (milli_denom * milli_denom)
+#define nano_denom    (milli_denom * milli_denom * milli_denom)
+
+    if (c == NULL) {
+      PRINT_ERROR(javacall_os_cond_wait, "Null cond", 0);
+      return JAVACALL_FAIL;
+    }
+
+    if (millis == 0) {
+        err = pthread_cond_wait(&c->condvar, &c->mutex->mutex);
+    } else {
+        struct timespec ts;
+
+        /*
+         * pthread_cond_timedwait() receives the absolute time, so
+         * it is nessesary to get current time and add our millis
+         */
+        err = clock_gettime(CLOCK_REALTIME, &ts);
+        if (err != 0) {
+            REPORT_ERROR(clock_gettime);
+            return JAVACALL_FAIL;
+        }
+        if (ts.tv_sec > 0) {
+          PRINT_ERROR(javacall_os_cond_wait, "Invalid time", 0);
+          return JAVACALL_FAIL;
+        }
+
+        /* calculate the time of deadline */
+        ts.tv_sec += millis / milli_denom;
+        ts.tv_nsec += (millis % milli_denom) * nano_denom / milli_denom;
+        if (ts.tv_nsec > nano_denom) {
+            ts.tv_sec += (time_t) ts.tv_nsec / nano_denom;
+            ts.tv_nsec %= nano_denom;
+        }
+        err = pthread_cond_timedwait(&c->condvar, &c->mutex->mutex, &ts);
+    }
+    if (err == ETIMEDOUT) {
+        return JAVACALL_TIMEOUT;
+    }
+    if (err != 0) {
+        REPORT_ERROR(pthread_cond_XXXwait);
+        return JAVACALL_FAIL;
+    }
+    return JAVACALL_OK;
+#undef nano_denom
+#undef micro_denom
+#undef milli_denom
+}
+
+/* wakes up a thread that is waiting for the condition */
+javacall_result javacall_os_cond_signal(struct _javacall_cond *c) {
+    int err;
+
+    if (c == NULL) {
+      PRINT_ERROR(javacall_os_cond_signal, "Null cond", 0);
+      return JAVACALL_FAIL;
+    }
+
+    if ((err = pthread_cond_signal(&c->condvar)) != 0) {
+        REPORT_ERROR(pthread_cond_signal);
+        return JAVACALL_FAIL;
+    }
+    return JAVACALL_OK;
+}
+
+/* wakes up all threads that are waiting for the condition */
+javacall_result javacall_os_cond_broadcast(struct _javacall_cond *c) {
+    int err;
+
+    if (c == NULL) {
+      PRINT_ERROR(javacall_os_cond_broadcast, "Null cond", 0);
+      return JAVACALL_FAIL;
+    }
+
+    if ((err = pthread_cond_broadcast(&c->condvar)) != 0) {
+        return JAVACALL_FAIL;
+    }
+    return JAVACALL_OK;
+}
+
+/**
+ * Gets directory path path where placed fonts after installed from jar
+ * @param fontPath OUT: pointer to unicode buffer, allocated by the VM,
+          to be filled with the directory path of fonts
+ * @param fontDirLen IN: lenght of max fontPath buffer, OUT: lenght of set fontPath
+ * @return <tt>JAVACALL_OK</tt> if operation completed successfully
+ *         <tt>JAVACALL_FAIL</tt> if an error occurred
+ */
+javacall_result javacall_os_get_font_storage_path(
+        javacall_utf16* /*OUT*/ fontPath, int* /*IN|OUT*/ fontPathLen) {
+
+    return JAVACALL_FAIL;
+}
+
+#ifndef NDEBUG
+
+/* gets error's description */
+#define CODE2STR(code_) \
+    case code_:\
+        return #code_;
+
+static char *err2str(int i) {
+    switch (i) {
+        CODE2STR(EBUSY)
+        CODE2STR(EINVAL)
+        CODE2STR(EAGAIN)
+        CODE2STR(EDEADLK)
+        CODE2STR(EPERM)
+        // CODE2STR(EOWNERDEAD)
+        // CODE2STR(ENOTRECOVERABLE)
+        CODE2STR(ENOMEM)
+        CODE2STR(ETIMEDOUT)
+        CODE2STR(EINTR)
+    default:
+        return "unknown";
+    }
+}
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_common.cpp	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <dio_common.h>
+#include <javacall_os.h>
+#include <javautil_linked_list.h>
+#include <javacall_memory.h>
+
+/* Java VM interface */
+static JavaVM* globalJavaVM = NULL;
+
+/* Internal structure of a device reference */
+struct _device_reference {
+    javacall_handle handle;
+    javacall_int32 refcount;
+    javacall_mutex mutex;
+    device_closer closer;
+    device_locker locker;
+    device_unlocker unlocker;
+};
+
+/* Signal descriptor */
+struct signal {
+    signal_type type;
+    javacall_handle target;
+    javacall_handle parameter;
+    javacall_cond condition;
+};
+
+/* Signal descriptor list */
+static javacall_handle signals = NULL;
+
+/* Signal descriptor list mutex */
+static javacall_mutex signalMutex = NULL;
+
+/* Cleanup */
+static void dioCleanup() {
+    if (NULL != signalMutex) {
+        javacall_os_mutex_destroy(signalMutex);
+        signalMutex = NULL;
+    }
+    if (NULL != signals) {
+        javautil_list_destroy(signals);
+        signals = NULL;
+    }
+}
+
+/* Returns a global reference to VM */
+JavaVM* getGlobalJavaVM() {
+    return globalJavaVM;
+}
+
+/* Creates a reference to the device identified by handle */
+device_reference createDeviceReference(javacall_handle handle, device_closer closer,
+                                       device_locker locker, device_unlocker unlocker) {
+    device_reference device;
+    if ((device = (device_reference)javacall_calloc(1, sizeof(_device_reference))) == NULL) {
+        return INVALID_DEVICE_REFERENCE;
+    }
+    if ((device->mutex = javacall_os_mutex_create()) == NULL) {
+        javacall_free(device);
+        return INVALID_DEVICE_REFERENCE;
+    }
+    device->handle = handle;
+    device->refcount = 1;
+    device->closer = closer;
+    device->locker = locker;
+    device->unlocker = unlocker;
+    return device;
+}
+
+static jobject getHandleObjectFromDeviceObject(JNIEnv* env, jobject deviceObj) {
+    //  to improve performance the references below should be cached
+    jclass deviceBaseClass = env->FindClass("com/oracle/dio/impl/AbstractPeripheral");
+    if (deviceBaseClass == NULL) {
+        return NULL;
+    }
+    jfieldID deviceHandleField = env->GetFieldID(deviceBaseClass, "handle", "Lcom/oracle/dio/impl/Handle;");
+    if (deviceHandleField == NULL) {
+        return NULL;
+    }
+    return env->GetObjectField(deviceObj, deviceHandleField);
+}
+
+static javacall_result saveDeviceReferenceToHandleObject(JNIEnv* env,
+                                                         jobject handleObj,
+                                                         device_reference device) {
+    //  to improve performance the references below should be cached
+    jclass deviceHandleClass = env->FindClass("com/oracle/dio/impl/Handle");
+    if (deviceHandleClass == NULL) {
+        return JAVACALL_FAIL;
+    }
+    jfieldID deviceNativeHandleField = env->GetFieldID(deviceHandleClass, "device_reference", "I");
+    if (deviceNativeHandleField == NULL) {
+        return JAVACALL_FAIL;
+    }
+    env->SetIntField(handleObj, deviceNativeHandleField, (jint)device);
+    return JAVACALL_OK;
+}
+
+static device_reference getDeviceReferenceFromHandleObject(JNIEnv* env,
+                                                           jobject handleObj) {
+    //  to improve performance the references below should be cached
+    jclass deviceHandleClass = env->FindClass("com/oracle/dio/impl/Handle");
+    if (deviceHandleClass == NULL) {
+        return INVALID_DEVICE_REFERENCE;
+    }
+    jfieldID deviceNativeHandleField = env->GetFieldID(deviceHandleClass, "device_reference", "I");
+    if (deviceNativeHandleField == NULL) {
+        return INVALID_DEVICE_REFERENCE;
+    }
+    jint value = env->GetIntField(handleObj, deviceNativeHandleField);
+    return (device_reference)value;
+}
+
+/* Saves the reference to an instance of AbstractPeripheral */
+javacall_result saveDeviceReferenceToDeviceObject(JNIEnv* env, jobject deviceObj,
+                                                  device_reference device) {
+    jobject handleObj = getHandleObjectFromDeviceObject(env, deviceObj);
+    if (handleObj == NULL) {
+        return JAVACALL_FAIL;
+    }
+    return saveDeviceReferenceToHandleObject(env, handleObj, device);
+}
+
+/* Returns a reference stored by an instance of AbstractPeripheral */
+device_reference getDeviceReferenceFromDeviceObject(JNIEnv* env, jobject deviceObj) {
+    jobject handleObj = getHandleObjectFromDeviceObject(env, deviceObj);
+    if (handleObj == NULL) {
+        return INVALID_DEVICE_REFERENCE;
+    }
+    return getDeviceReferenceFromHandleObject(env, handleObj);
+}
+
+/* Returns the handle associated with the device reference */
+javacall_handle getDeviceHandle(device_reference device) {
+    return device->handle;
+}
+
+/* Restricted use only.
+ * Retains the device reference by incrementing its reference counter, thus
+ * preventing it from being immediately destroyed by releaseDeviceReference().
+ * Must be balanced with a call to releaseDeviceReference() to let the
+ * reference be finally destroyed. */
+void retainDeviceReference(device_reference device) {
+    javacall_os_mutex_lock(device->mutex);
+    device->refcount++;
+    javacall_os_mutex_unlock(device->mutex);
+}
+
+/* Releases a reference */
+void releaseDeviceReference(device_reference device) {
+    javacall_mutex m = device->mutex;
+    javacall_os_mutex_lock(m);
+    if (--device->refcount == 0) {
+        javacall_free(device);
+        device = NULL;
+    }
+    javacall_os_mutex_unlock(m);
+    if (device == NULL) {
+        javacall_os_mutex_destroy(m);
+    }
+}
+
+static void destroySignal(signal* sig) {
+    if (sig->condition != NULL) {
+        javacall_mutex m = javacall_os_cond_get_mutex(sig->condition);
+        if (m != NULL) {
+           javacall_os_mutex_destroy(m);
+        }
+        javacall_os_cond_destroy(sig->condition);
+    }
+    javacall_free(sig);
+}
+
+static signal* createSignal(signal_type signalType, javacall_handle signalTarget) {
+    signal* sig;
+    if ((sig = (signal*)javacall_calloc(1, sizeof(signal))) == NULL) {
+        return NULL;
+    }
+
+    javacall_mutex cond_mutex;
+    if ((cond_mutex = javacall_os_mutex_create()) == NULL) {
+        destroySignal(sig);
+        return NULL;
+    }
+    if ((sig->condition = javacall_os_cond_create(cond_mutex)) == NULL) {
+        javacall_os_mutex_destroy(cond_mutex);
+        destroySignal(sig);
+        return NULL;
+    }
+
+    sig->type = signalType;
+    sig->target = signalTarget;
+    return sig;
+}
+
+static signal* findTarget(signal_type signalType, javacall_handle signalTarget) {
+    signal* sig = NULL;
+    while (javautil_list_get_next(signals, (void**)&sig) == JAVACALL_OK) {
+        if (sig->type == signalType && sig->target == signalTarget) {
+            break;
+        }
+    }
+    return sig;
+}
+
+/* Blocks the current thread, until a signal is received, or the timeout expires */
+javacall_result waitForSignal(signal_type signalType, javacall_handle signalTarget,
+                              /*OUT*/ javacall_handle* signalParameter, long timeout) {
+    signal* sig = NULL;
+
+    javacall_os_mutex_lock(signalMutex);
+    javacall_result result = JAVACALL_BUSY;
+    if (findTarget(signalType, signalTarget) == NULL) {
+        result = JAVACALL_OUT_OF_MEMORY;
+        sig = createSignal(signalType, signalTarget);
+        if (sig != NULL) {
+            result = JAVACALL_OK;
+            javautil_list_add(signals, sig);
+        }
+    }
+    javacall_os_mutex_unlock(signalMutex);
+
+    if (result == JAVACALL_OK) {
+        javacall_os_cond_wait(sig->condition, timeout);
+
+        javacall_os_mutex_lock(signalMutex);
+        javautil_list_remove(signals, sig);
+        javacall_os_mutex_unlock(signalMutex);
+
+        if (signalParameter != NULL) {
+            *signalParameter = sig->parameter;
+        }
+
+        destroySignal(sig);
+    }
+
+    return result;
+}
+
+/* Unblocks a thread that is waiting for a signal */
+void generateSignal(signal_type signalType, javacall_handle signalTarget,
+                    javacall_handle signalParameter) {
+    javacall_os_mutex_lock(signalMutex);
+
+    signal* sig = findTarget(signalType, signalTarget);
+    if (sig != NULL) {
+        sig->parameter = signalParameter;
+        javacall_os_cond_signal(sig->condition);
+    }
+
+    javacall_os_mutex_unlock(signalMutex);
+}
+
+/* Closes the referenced device */
+javacall_result closeDevice(device_reference device) {
+    if (device->closer == NULL) {
+        return JAVACALL_FAIL;
+    }
+    if (device->handle != JAVACALL_INVALID_HANDLE) {
+        device->closer(device->handle);
+        device->handle = JAVACALL_INVALID_HANDLE;
+    }
+    return JAVACALL_OK;
+}
+
+/* Locks the referenced device */
+javacall_result lockDevice(device_reference device, /*OUT*/ javacall_handle* owner) {
+    if (device->locker == NULL || device->handle == JAVACALL_INVALID_HANDLE) {
+        return JAVACALL_FAIL;
+    }
+    return device->locker(device->handle, owner);
+}
+
+/* Unlocks the referenced device */
+javacall_result unlockDevice(device_reference device) {
+    if (device->unlocker == NULL || device->handle == JAVACALL_INVALID_HANDLE) {
+        return JAVACALL_FAIL;
+    }
+    return device->unlocker(device->handle);
+}
+
+
+extern "C" {
+
+/* Native logging initialization */
+void javacall_logging_initialize(void) {
+    // Stubbed, unless this feature is required
+}
+
+/*******************************************************************************
+ * JNI functions
+ */
+
+/* The VM calls this function upon loading the native library. */
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved) {
+
+    globalJavaVM = jvm;
+    javacall_os_initialize();
+
+    if (javautil_list_create(&signals) != JAVACALL_OK) {
+        dioCleanup();
+        return JNI_ERR;
+    }
+
+    if ((signalMutex = javacall_os_mutex_create()) == NULL) {
+        dioCleanup();
+        return JNI_ERR;
+    }
+
+    return JNI_VERSION_1_2;
+}
+
+/* This function is called when the native library gets unloaded by the VM. */
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* jvm, void* reserved) {
+    dioCleanup();
+    javacall_os_dispose();
+    globalJavaVM = NULL;
+}
+
+/*
+ * Closes the device.
+ * Class:     com_oracle_dio_impl_Handle
+ * Method:    close
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_impl_Handle_close
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromHandleObject(env, obj);
+    if (device != INVALID_DEVICE_REFERENCE) {
+        saveDeviceReferenceToHandleObject(env, obj, INVALID_DEVICE_REFERENCE);
+        closeDevice(device);
+        releaseDeviceReference(device);
+    }
+}
+
+/*
+ * Tries locking the device.
+ * Class:     com_oracle_dio_impl_Handle
+ * Method:    tryLock
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_impl_Handle_tryLock
+  (JNIEnv* env, jobject obj, jint timeout) {
+    device_reference device = getDeviceReferenceFromHandleObject(env, obj);
+    if (device != INVALID_DEVICE_REFERENCE) {
+        //  add an implementation
+    }
+}
+
+/*
+ * Unlocks the device.
+ * Class:     com_oracle_dio_impl_Handle
+ * Method:    unlock
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_impl_Handle_unlock
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromHandleObject(env, obj);
+    if (device != INVALID_DEVICE_REFERENCE) {
+        //  add an implementation
+    }
+}
+
+} // extern "C" /* JNI functions */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_common.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __DEVICEACCESS_COMMON_H
+#define __DEVICEACCESS_COMMON_H
+
+#include <jni.h>
+#include <javacall_defs.h>
+
+/* Returns a global reference to VM */
+JavaVM* getGlobalJavaVM();
+
+/* A device reference abstraction */
+typedef struct _device_reference* device_reference;
+
+/* Invalid reference constant */
+#define INVALID_DEVICE_REFERENCE (device_reference)-1
+
+/* Device handle operation prototypes */
+typedef javacall_result (*device_closer)(javacall_handle);
+typedef javacall_result (*device_locker)(const javacall_handle, javacall_handle* const);
+typedef javacall_result (*device_unlocker)(const javacall_handle);
+
+typedef enum {
+    BEGIN_TRANSACTION_SIGNAL,
+    SEND_SIGNAL,
+    RECEIVE_SIGNAL,
+    COMM_OPEN_SIGNAL,
+    COMM_CLOSE_SIGNAL,
+    COMM_READ_SIGNAL,
+    COMM_WRITE_SIGNAL
+} signal_type;
+
+/* Creates a reference to the device identified by handle */
+device_reference createDeviceReference(javacall_handle handle, device_closer closer,
+                                       device_locker locker, device_unlocker unlocker);
+
+/* Saves the reference to an instance of AbstractPeripheral */
+javacall_result saveDeviceReferenceToDeviceObject(JNIEnv* env, jobject obj,
+                                                  device_reference device);
+
+/* Returns a reference stored by an instance of AbstractPeripheral */
+device_reference getDeviceReferenceFromDeviceObject(JNIEnv* env, jobject obj);
+
+/* Returns the handle associated with the device reference */
+javacall_handle getDeviceHandle(device_reference device);
+
+/* Restricted use only.
+ * Retains the device reference by incrementing its reference counter, thus
+ * preventing it from being immediately destroyed by releaseDeviceReference().
+ * Must be balanced with a call to releaseDeviceReference() to let the
+ * reference be finally destroyed. */
+void retainDeviceReference(device_reference device);
+
+/* Releases a reference */
+void releaseDeviceReference(device_reference device);
+
+/* Blocks the current thread, until a signal is received, or the timeout expires */
+javacall_result waitForSignal(signal_type signalType, javacall_handle signalTarget,
+                              /*OUT*/ javacall_handle* signalParameter, long timeout);
+
+/* Unblocks a thread that is waiting for a signal */
+void generateSignal(signal_type signalType, javacall_handle signalTarget,
+                    javacall_handle signalParameter);
+
+/* Closes the referenced device */
+javacall_result closeDevice(device_reference device);
+
+/* Locks the referenced device */
+javacall_result lockDevice(device_reference device, /*OUT*/ javacall_handle* owner);
+
+/* Unlocks the referenced device */
+javacall_result unlockDevice(device_reference device);
+
+#endif /*  __DEVICEACCESS_COMMON_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_event_queue.cpp	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "dio_event_queue.h"
+#include <string.h>
+
+static const int JCLASS_SIZE = sizeof(jclass);
+
+extern "C" {
+
+JNIEXPORT jclass JNICALL Java_com_oracle_dio_impl_EventQueue_getEventClass
+  (JNIEnv* env, jclass clazz, jobject buffer, jint currPos) {
+    // required methods references
+    jclass bufferClass = env->GetObjectClass(buffer);
+    jmethodID setPositionID = env->GetMethodID(bufferClass, "position", "(I)Ljava/nio/Buffer;");
+
+    // Not necessary to synchronize on buffer, it's always called from protected section
+    jbyte* buf = (jbyte*)env->GetDirectBufferAddress(buffer);
+
+    jclass eventClass;
+    memcpy(&eventClass, buf + currPos, JCLASS_SIZE);
+
+    // update buffer position
+    env->CallObjectMethod(buffer, setPositionID, currPos + JCLASS_SIZE);
+
+    return eventClass;
+}
+
+} /* extern "C */
+
+/*
+ * Puts an event to the provided NIO buffer and sends a notification to the
+ * EventQueue object that handles the buffer. See the implementation
+ * of the com.oracle.dio.impl.EventQueue class for details.
+ */
+void event_queue_put_native_event
+  (JavaVM* cachedJVM, jobject eventBufferRef, jclass eventClass, const char *payload, int payload_size) {
+    JNIEnv* env;
+    cachedJVM->AttachCurrentThread((void**)&env, NULL);
+
+    jclass bufferClass = env->GetObjectClass(eventBufferRef);
+    jmethodID notifyID = env->GetMethodID(bufferClass, "notify", "()V");
+    jmethodID limitID = env->GetMethodID(bufferClass, "limit", "()I");
+    jmethodID setLimitID = env->GetMethodID(bufferClass, "limit", "(I)Ljava/nio/Buffer;");
+
+    env->MonitorEnter(eventBufferRef);
+
+    // check enough space in direct buffer
+    jlong capacity = env->GetDirectBufferCapacity(eventBufferRef);
+    jint limit = env->CallIntMethod(eventBufferRef, limitID);
+
+    jint newLimit = limit + JCLASS_SIZE + payload_size + 2;
+
+    if (newLimit < capacity) {
+        jbyte* buf = (jbyte*)env->GetDirectBufferAddress(eventBufferRef);
+
+        memcpy(buf, &eventClass, JCLASS_SIZE);
+        buf += JCLASS_SIZE;
+
+        // payload
+        *buf++ = (jbyte)((payload_size & 0xFF00) >> 8); // high byte
+        *buf++ = (jbyte)(payload_size & 0xFF);          // then low byte
+        memcpy(buf, payload, payload_size);
+
+        env->CallObjectMethod(eventBufferRef, setLimitID, newLimit);
+        env->CallVoidMethod(eventBufferRef, notifyID);
+    }
+
+    env->MonitorExit(eventBufferRef);
+    cachedJVM->DetachCurrentThread();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_event_queue.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __DEVICEACCESS_EVENT_QUEUE_H
+#define __DEVICEACCESS_EVENT_QUEUE_H
+
+#include <jni.h>
+
+/*
+ * Puts an event to the provided NIO buffer and sends a notification to the
+ * EventQueue object that handles the buffer. See the implementation
+ * of the com.oracle.dio.impl.EventQueue class for details.
+ */
+void event_queue_put_native_event
+  (JavaVM* cachedJVM, jobject eventBufferRef, jclass eventClass, const char* payload, int payload_size);
+
+#endif /* __DEVICEACCESS_EVENT_QUEUE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_exceptions.cpp	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <dio_exceptions.h>
+
+void throwException(JNIEnv* env, const char* exception, const char* message /*= NULL*/) {
+    jclass clazz = env->FindClass(exception);
+    if (clazz != NULL) {
+        env->ThrowNew(clazz, message);
+        env->DeleteLocalRef(clazz);
+    }
+}
+
+void throwDeviceNotFoundException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "jdk/dio/DeviceNotFoundException", message);
+}
+
+void throwUnavailableDeviceException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "jdk/dio/UnavailableDeviceException", message);
+}
+
+void throwInvalidDeviceConfigException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "jdk/dio/InvalidDeviceConfigException", message);
+}
+
+void throwUnsupportedAccessModeException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "jdk/dio/UnsupportedAccessModeException", message);
+}
+
+void throwUnsupportedOperationException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "java/lang/UnsupportedOperationException", message);
+}
+
+void throwIllegalStateException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "java/lang/IllegalStateException", message);
+}
+
+void throwOutOfMemoryError(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "java/lang/OutOfMemoryError", message);
+}
+
+void throwIOException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "java/io/IOException", message);
+}
+
+void throwIllegalArgumentException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "java/lang/IllegalArgumentException", message);
+}
+
+void throwRuntimeException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "java/lang/RuntimeException", message);
+}
+
+void throwClosedDeviceException(JNIEnv* env, const char* message /*= NULL*/) {
+    throwException(env, "jdk/dio/ClosedDeviceException", message);
+}
+
+/**
+ * Check for a javacall failure and throw a proper exception.
+ */
+void checkJavacallFailure(JNIEnv* env, javacall_result result) {
+    if (JAVACALL_OK == result){
+        return;
+    }
+    if (JAVACALL_BUSY == result || JAVACALL_TIMEOUT == result ) {
+        throwUnavailableDeviceException(env, "Device is not available");
+    } else if (JAVACALL_NOT_IMPLEMENTED == result) {
+        throwIOException(env, "Device feature is not implemented");
+    } else if (JAVACALL_VALUE_NOT_FOUND == result) {
+        throwDeviceNotFoundException(env, "Peripheral is not found");
+    } else if (JAVACALL_OUT_OF_MEMORY == result) {
+        throwOutOfMemoryError(env, "Out of Memory");
+    } else if (JAVACALL_INVALID_ARGUMENT == result) {
+        throwIllegalArgumentException(env, "Illegal argument");
+    } else if (JAVACALL_INVALID_STATE == result) {
+        throwUnsupportedAccessModeException(env, "Illegal access mode");
+    } else {
+        throwIOException(env);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_exceptions.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __DEVICEACCESS_EXCEPTIONS_H
+#define __DEVICEACCESS_EXCEPTIONS_H
+
+#include <jni.h>
+#include <javacall_defs.h>
+
+void throwException(JNIEnv* env, const char* exception, const char* message = NULL);
+
+void throwDeviceNotFoundException(JNIEnv* env, const char* message = NULL);
+void throwUnavailableDeviceException(JNIEnv* env, const char* message = NULL);
+void throwInvalidDeviceConfigException(JNIEnv* env, const char* message = NULL);
+void throwUnsupportedAccessModeException(JNIEnv* env, const char* message = NULL);
+void throwUnsupportedOperationException(JNIEnv* env, const char* message = NULL);
+void throwIllegalStateException(JNIEnv* env, const char* message = NULL);
+void throwOutOfMemoryError(JNIEnv* env, const char* message = NULL);
+void throwIOException(JNIEnv* env, const char* message = NULL);
+void throwIllegalArgumentException(JNIEnv* env, const char* message = NULL);
+void throwRuntimeException(JNIEnv* env, const char* message = NULL);
+void throwClosedDeviceException(JNIEnv* env, const char* message = NULL);
+
+/**
+ * Check for a javacall failure and throw a proper exception.
+ */
+void checkJavacallFailure(JNIEnv* env, javacall_result result);
+
+#endif /*__DEVICEACCESS_EXCEPTIONS_H*/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_nio.cpp	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <dio_nio.h>
+
+bool getByteBufferInformation(JNIEnv* env, jobject buffer, jbyte** directArray,
+  jbyteArray* heapArray, jint* offset, jint* position, jint* capacity,
+  jint* limit, jboolean* readonly) {
+
+    // For all the refs below there might be created cached global
+    // refs in order to improve performance. Do that atomically to avoid dups.
+    // Assumed the buffer is already checked to be non-null.
+
+    jclass bufferClass = env->FindClass("java/nio/Buffer");
+    if (bufferClass == NULL) {
+        return false;
+    }
+    jfieldID directBufferAddressField = env->GetFieldID(bufferClass, "address", "J");
+    if (directBufferAddressField == NULL) {
+        return false;
+    }
+    jfieldID bufferPositionField = env->GetFieldID(bufferClass, "position", "I");
+    if (bufferPositionField == NULL) {
+        return false;
+    }
+    jfieldID bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I");
+    if (bufferCapacityField == NULL) {
+        return false;
+    }
+    jfieldID bufferLimitField = env->GetFieldID(bufferClass, "limit", "I");
+    if (bufferLimitField == NULL) {
+        return false;
+    }
+    jclass byteBufferClass = env->FindClass("java/nio/ByteBuffer");
+    if (byteBufferClass == NULL) {
+        return false;
+    }
+    jfieldID byteBufferHeapBufferField = env->GetFieldID(byteBufferClass, "hb", "[B");
+    if (byteBufferHeapBufferField == NULL) {
+        return false;
+    }
+    jfieldID byteBufferOffsetField = env->GetFieldID(byteBufferClass, "offset", "I");
+    if (byteBufferOffsetField == NULL) {
+        return false;
+    }
+    jfieldID byteBufferReadonlyField = env->GetFieldID(byteBufferClass, "isReadOnly", "Z");
+    if (byteBufferReadonlyField == NULL) {
+        return false;
+    }
+    jclass directByteBufferClass = env->FindClass("java/nio/DirectByteBuffer");
+    if (directByteBufferClass == NULL) {
+        return false;
+    }
+    if (env->IsInstanceOf(buffer, directByteBufferClass) != JNI_FALSE) {
+        // the buffer is a direct byte buffer
+        *directArray = (jbyte*)env->GetLongField(buffer, directBufferAddressField);
+        *heapArray   = NULL;
+        *offset      = 0;
+        *readonly    = JNI_FALSE;
+    } else {
+        // the buffer is a heap byte buffer
+        *directArray = NULL;
+        *heapArray   = (jbyteArray)env->GetObjectField(buffer, byteBufferHeapBufferField);
+        *offset      = env->GetIntField(buffer, byteBufferOffsetField);
+        *readonly    = env->GetBooleanField(buffer, byteBufferReadonlyField);
+    }
+    *position = env->GetIntField(buffer, bufferPositionField);
+    *capacity = env->GetIntField(buffer, bufferCapacityField);
+    *limit    = env->GetIntField(buffer, bufferLimitField);
+    return true;
+}
+
+bool setByteBufferPosition(JNIEnv* env, jobject buffer, jint position) {
+    jclass bufferClass = env->FindClass("java/nio/Buffer");
+    if (bufferClass == NULL) {
+        return false;
+    }
+    jfieldID bufferPositionField = env->GetFieldID(bufferClass, "position", "I");
+    if (bufferPositionField == NULL) {
+        return false;
+    }
+    env->SetIntField(buffer, bufferPositionField, position);
+    return true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/dio_nio.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __DEVICEACCESS_NIO_H
+#define __DEVICEACCESS_NIO_H
+
+#include <jni.h>
+
+/* Gets various information about a NIO byte buffer:
+ *
+ * directArray - direct buffer address     (set to null, if the given buffer is not a direct buffer)
+ * heapArray   - heap byte array reference (set to null, if the given buffer is a direct buffer)
+ * offset      - offset for the heap array (set to 0, if the given buffer is a direct buffer)
+ * position    - byte buffer position
+ * capacity    - byte buffer capacity
+ * limit       - byte buffer limit
+ * readonly    - byte array readonly flag  (set to false, if the given buffer is a direct buffer)
+ *
+ * Returns false, if the used knowledge about the ByteBuffer class internals cannot
+ * be applied, i.e. class member names do not match or such like.
+ */
+
+bool getByteBufferInformation(JNIEnv* env, jobject buffer,
+  /*OUT*/ jbyte** directArray, /*OUT*/ jbyteArray* heapArray,
+  /*OUT*/ jint* offset, /*OUT*/ jint* position, /*OUT*/ jint* capacity,
+  /*OUT*/ jint* limit, /*OUT*/ jboolean* readonly);
+
+/* Sets position of a NIO byte buffer.
+ *
+ * Returns false, if the used knowledge about the ByteBuffer class internals cannot
+ * be applied, i.e. class member names do not match or such like.
+ */
+bool setByteBufferPosition(JNIEnv* env, jobject buffer, jint position);
+
+#endif /* __DEVICEACCESS_NIO_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/gpio/impl/jni_gpio.cpp	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,458 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <dio_common.h>
+#include <dio_exceptions.h>
+#include <javacall_dio.h>
+#include <javacall_gpio.h>
+#include <javacall_memory.h>
+#include <javanotify_gpio.h>
+#include <dio_event_queue.h>
+
+extern "C" {
+
+/*
+ * Opens GPIO pin and returns a handle.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    openPinByConfig0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_openPinByConfig0
+  (JNIEnv* env, jobject obj, jint port, jint pin, jint direction, jint mode, jint trigger,
+   jboolean value, jboolean access) {
+    javacall_handle handle = JAVACALL_INVALID_HANDLE;
+    javacall_result result;
+    result = javacall_gpio_pin_open(port, pin,
+                                    (javacall_gpio_dir)direction,
+                                    (javacall_gpio_mode)mode,
+                                    (javacall_gpio_trigger_mode)trigger,
+                                    (javacall_bool)value,
+                                    (javacall_bool)access,
+                                    &handle);
+
+    if (result == JAVACALL_OK) {
+        device_reference device;
+        device = createDeviceReference(handle,
+                                       javacall_gpio_pin_close,
+                                       javacall_gpio_pin_lock,
+                                       javacall_gpio_pin_unlock);
+
+        if (device == INVALID_DEVICE_REFERENCE) {
+            javacall_gpio_pin_close(handle);
+            result = JAVACALL_OUT_OF_MEMORY;
+        } else {
+            result = saveDeviceReferenceToDeviceObject(env, obj, device);
+        }
+    }
+
+    if (result == JAVACALL_INVALID_ARGUMENT) {
+        throwInvalidDeviceConfigException(env, "Config has invalid parameters");
+    } else {
+        checkJavacallFailure(env, result);
+    }
+}
+
+/*
+ * Opens GPIO port and returns a handle.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    openPortByConfig0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_openPortByConfig0
+  (JNIEnv* env, jobject obj, jobjectArray data, jint direction, jint value, jboolean access) {
+
+    javacall_result result = JAVACALL_OK;
+    jint dataLength = env->GetArrayLength(data);
+    javacall_int32* portsAndPins;
+
+    portsAndPins = (javacall_int32*)javacall_malloc(4 * dataLength * sizeof(javacall_int32));
+    if (portsAndPins != NULL) {
+        for (jint i = 0; i < dataLength; i++) {
+            jintArray portAndPin = (jintArray)env->GetObjectArrayElement(data, i);
+            jint* elements = env->GetIntArrayElements(portAndPin, NULL);
+            if (elements != NULL) {
+                portsAndPins[4 * i] = elements[0];
+                portsAndPins[4 * i + 1] = elements[1];
+                portsAndPins[4 * i + 2] = elements[2];
+                portsAndPins[4 * i + 3] = elements[3];
+                env->ReleaseIntArrayElements(portAndPin, elements, JNI_ABORT);
+            }
+        }
+
+        javacall_handle handle = JAVACALL_INVALID_HANDLE;
+        result = javacall_gpio_port_open_with_pins((javacall_int32(*)[4])portsAndPins,
+                                                   dataLength,
+                                                   (javacall_gpio_dir)direction,
+                                                   value,
+                                                   (javacall_bool)access,
+                                                   &handle);
+        javacall_free(portsAndPins);
+
+        if (result == JAVACALL_OK) {
+            device_reference device;
+            device = createDeviceReference(handle,
+                                           javacall_gpio_port_close,
+                                           javacall_gpio_port_lock,
+                                           javacall_gpio_port_unlock);
+
+            if (device == INVALID_DEVICE_REFERENCE) {
+                javacall_gpio_port_close(handle);
+                result = JAVACALL_OUT_OF_MEMORY;
+            } else {
+                result = saveDeviceReferenceToDeviceObject(env, obj, device);
+            }
+        }
+    } else {
+        result = JAVACALL_OUT_OF_MEMORY;
+    }
+
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Reads data from a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    readPin0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_readPin0
+  (JNIEnv* env, jobject obj) {
+    javacall_bool value = JAVACALL_FALSE;
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_pin_read(getDeviceHandle(device), &value);
+    checkJavacallFailure(env, result);
+    return (jint)value;
+}
+
+/*
+ * Reads data from a port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    readPort0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_readPort0
+  (JNIEnv* env, jobject obj) {
+    javacall_int32 value = 0;
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_port_read(getDeviceHandle(device), &value);
+    checkJavacallFailure(env, result);
+    return (jint)value;
+}
+
+/*
+ * Writes data to a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    writePin0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_writePin0
+  (JNIEnv* env, jobject obj, jboolean value) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_pin_write(getDeviceHandle(device),
+                                     value != JNI_FALSE ? JAVACALL_TRUE : JAVACALL_FALSE);
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Writes data to a port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    writePort0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_writePort0
+  (JNIEnv* env, jobject obj, jint value) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_port_write(getDeviceHandle(device), value);
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Starts notifications from a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    startNoti0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_startNoti0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_pin_notification_start(getDeviceHandle(device));
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Starts notifications from a port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    startNoti0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_startNoti0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_port_notification_start(getDeviceHandle(device));
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Stops notifications from a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    stopNoti0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_stopNoti0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_pin_notification_stop(getDeviceHandle(device));
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Stops notifications from a port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    stopNoti0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_stopNoti0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_port_notification_stop(getDeviceHandle(device));
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Sets direction of a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    setOutputMode0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_setOutputMode0
+  (JNIEnv* env, jobject obj, jboolean output) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_pin_direction_set(getDeviceHandle(device),
+                                             output != JNI_FALSE ? JAVACALL_TRUE : JAVACALL_FALSE);
+    if (JAVACALL_OK != result) {
+        if (JAVACALL_FAIL == result) {
+            throwUnsupportedOperationException(env, "Unsupported output mode");
+        } else if (JAVACALL_INVALID_ARGUMENT == result) {
+            throwIllegalArgumentException(env);
+        } else {
+            throwIOException(env);
+        }
+    }
+}
+
+/*
+ * Sets direction of a port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    setOutputMode0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_setOutputMode0
+  (JNIEnv* env, jobject obj, jboolean output) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_port_direction_set(getDeviceHandle(device),
+                                              output != JNI_FALSE ? JAVACALL_TRUE : JAVACALL_FALSE);
+    if (JAVACALL_OK != result) {
+        if (JAVACALL_FAIL == result) {
+            throwUnsupportedOperationException(env, "Unsupported output mode");
+        } else if (JAVACALL_INVALID_ARGUMENT == result) {
+            throwIllegalArgumentException(env);
+        } else {
+            throwIOException(env);
+        }
+    }
+}
+
+/*
+ * Gets direction of a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    getOutputMode0
+ */
+JNIEXPORT jboolean JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_getOutputMode0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_bool mode = JAVACALL_FALSE;
+    javacall_result result;
+    result = javacall_gpio_pin_direction_get(getDeviceHandle(device), &mode);
+    checkJavacallFailure(env, result);
+    return mode != JAVACALL_FALSE ? JNI_TRUE : JNI_FALSE;
+}
+
+/*
+ * Gets direction of a port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    getOutputMode0
+ */
+JNIEXPORT jboolean JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_getOutputMode0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_bool mode = JAVACALL_FALSE;
+    javacall_result result;
+    result = javacall_gpio_port_direction_get(getDeviceHandle(device), &mode);
+    checkJavacallFailure(env, result);
+    return mode != JAVACALL_FALSE ? JNI_TRUE : JNI_FALSE;
+}
+
+/*
+ * Sets trigger mode of a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    setTrigger0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_setTrigger0
+  (JNIEnv* env, jobject obj, jint trigger) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_gpio_pin_set_trigger(getDeviceHandle(device),
+                                           (javacall_gpio_trigger_mode)trigger);
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Gets trigger mode of a pin.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    getTrigger0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_getTrigger0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_gpio_trigger_mode trigger;
+    javacall_result result;
+    result = javacall_gpio_pin_get_trigger(getDeviceHandle(device), &trigger);
+    checkJavacallFailure(env, result);
+    return (jint)trigger;
+}
+
+/*
+ * Gets handle of a port the pin relates to.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinImpl
+ * Method:    getPortId0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinImpl_getGrpID0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_int32 port;
+    javacall_result result;
+    result = javacall_gpio_pin_get_group_id(getDeviceHandle(device), &port);
+    checkJavacallFailure(env, result);
+    return (jint)port;
+}
+
+/*
+ * Get Max value of a GPIO port.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    getMaxVal0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_getMaxVal0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_int32 value = 0;
+    javacall_result result;
+    result = javacall_gpio_port_get_max_value(getDeviceHandle(device), &value);
+    checkJavacallFailure(env, result);
+    return (jint)value;
+}
+
+/*
+ * Sets the GPIOPortConfig.pins private field.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPortImpl
+ * Method:    assignPins0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortImpl_assignPins0
+  (JNIEnv* env, jobject obj, jobject cfg, jobjectArray pins) {
+    jclass cfgClass = env->GetObjectClass(cfg);
+    jfieldID pinsField = env->GetFieldID(cfgClass, "pins", "[Ljdk/dio/gpio/GPIOPin;");
+    env->SetObjectField(cfg, pinsField, pins);
+}
+
+
+/* Entities required for sending GPIO pin notifications */
+static jobject pinEventBuffer;
+static jclass pinEventClass;
+
+/*
+ * Sets references to the Java entities required for sending notifications.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinEventHandler
+ * Method:    setNativeEntries
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPinEventHandler_setNativeEntries
+  (JNIEnv* env, jclass clazz, jobject buffer, jclass event) {
+    pinEventBuffer = buffer;
+    pinEventClass = event;
+}
+
+/* Entities required for sending GPIO port notifications */
+static jobject portEventBuffer;
+static jclass portEventClass;
+
+/*
+ * Sets references to the Java entities required for sending notifications.
+ * Class:     com_oracle_dio_gpio_impl_GPIOPinEventHandler
+ * Method:    setNativeEntries
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_gpio_impl_GPIOPortEventHandler_setNativeEntries
+  (JNIEnv* env, jclass clazz, jobject buffer, jclass event) {
+    portEventBuffer = buffer;
+    portEventClass = event;
+}
+
+/*
+ * Sends a pin value change event.
+ * @param handle    open pin handle
+ * @param value     value of the given pin
+ */
+void javanotify_gpio_pin_value_changed
+  (const javacall_handle handle, const javacall_int32 value) {
+    if (pinEventBuffer == NULL || pinEventClass == NULL) {
+        return;
+    }
+    const int size = 8; // reserve 4 bytes for the handle and 4 bytes for the value
+    char payload[size];
+    payload[0] = (unsigned int)handle >> 24, payload[1] = (unsigned int)handle >> 16;
+    payload[2] = (unsigned int)handle >> 8,  payload[3] = (unsigned int)handle;
+    payload[4] = value >> 24, payload[5] = value >> 16;
+    payload[6] = value >> 8,  payload[7] = value;
+    JavaVM* vm = getGlobalJavaVM();
+    event_queue_put_native_event(vm, pinEventBuffer, pinEventClass, payload, size);
+}
+
+/*
+ * Sends a port value change event.
+ * @param handle    open port handle
+ * @param value     value of the given port
+ */
+void javanotify_gpio_port_value_changed
+  (const javacall_handle handle, const javacall_int32 value) {
+    if (portEventBuffer == NULL || portEventClass == NULL) {
+        return;
+    }
+
+    const int size = 8; // reserve 4 bytes for the handle and 4 bytes for the value
+    char payload[size];
+    payload[0] = (unsigned int)handle >> 24, payload[1] = (unsigned int)handle >> 16;
+    payload[2] = (unsigned int)handle >> 8,  payload[3] = (unsigned int)handle;
+    payload[4] = value >> 24, payload[5] = value >> 16;
+    payload[6] = value >> 8,  payload[7] = value;
+    JavaVM* vm = getGlobalJavaVM();
+    event_queue_put_native_event(vm, portEventBuffer, portEventClass, payload, size);
+}
+
+} // extern "C"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/i2cbus/impl/jni_i2c.cpp	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <dio_common.h>
+#include <dio_exceptions.h>
+#include <dio_nio.h>
+#include <javacall_dio.h>
+#include <javacall_i2c.h>
+#include <javacall_memory.h>
+
+static javacall_result i2c_cleanup(javacall_handle handle) {
+    if (handle != JAVACALL_INVALID_HANDLE) {
+        /* Stop ongoing transaction before closing the device */
+        javacall_int32 busId;
+        if (javacall_i2c_end(handle, &busId) == JAVACALL_OK) {
+            generateSignal(BEGIN_TRANSACTION_SIGNAL, (javacall_handle)busId, 0);
+        }
+        javacall_i2c_close(handle);
+    }
+    return JAVACALL_OK;
+}
+
+extern "C" {
+
+/*
+ * Class:     com_oracle_dio_i2cbus_impl_I2CSlaveImpl
+ * Method:    open0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_i2cbus_impl_I2CSlaveImpl_open0
+  (JNIEnv* env, jobject obj, jobject config, jboolean exclusive) {
+    jclass configClass = env->GetObjectClass(config);
+
+    jfieldID deviceNumberID = env->GetFieldID(configClass, "controllerNumber", "I");
+    jint deviceNumber = env->GetIntField(config, deviceNumberID);
+
+    jfieldID addressID = env->GetFieldID(configClass, "address", "I");
+    jint address = env->GetIntField(config, addressID);
+
+    jfieldID addressSizeID = env->GetFieldID(configClass, "addressSize", "I");
+    jint addressSize = env->GetIntField(config, addressSizeID);
+
+    jfieldID clockFrequencyID = env->GetFieldID(configClass, "clockFrequency", "I");
+    jint clockFrequency = env->GetIntField(config, clockFrequencyID);
+
+    javacall_handle handle = JAVACALL_INVALID_HANDLE;
+    javacall_result result;
+    result = javacall_i2c_open_slave_with_config(deviceNumber, address,
+                                                 addressSize, clockFrequency,
+                                                 exclusive != JNI_FALSE ? JAVACALL_TRUE : JAVACALL_FALSE,
+                                                 &handle);
+
+    device_reference device = INVALID_DEVICE_REFERENCE;
+    if (result == JAVACALL_OK) {
+        device = createDeviceReference(handle, i2c_cleanup,
+                                       javacall_i2c_lock, javacall_i2c_unlock);
+        if (device == INVALID_DEVICE_REFERENCE) {
+            javacall_i2c_close(handle);
+            result = JAVACALL_OUT_OF_MEMORY;
+        } else {
+            result = saveDeviceReferenceToDeviceObject(env, obj, device);
+        }
+    }
+
+    checkJavacallFailure(env, result);
+}
+
+/*
+ * Class:     com_oracle_dio_i2cbus_impl_I2CSlaveImpl
+ * Method:    begin0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_i2cbus_impl_I2CSlaveImpl_begin0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    do {
+        javacall_int32 busId;
+        javacall_result result = javacall_i2c_begin(getDeviceHandle(device), &busId);
+        if (result == JAVACALL_OK) {
+            jclass klass = env->GetObjectClass(obj);
+            jfieldID startedField = env->GetFieldID(klass, "isTransactionStarted", "Z");
+            env->SetBooleanField(obj, startedField, JNI_TRUE);
+        } else if (result == JAVACALL_WOULD_BLOCK) {
+            result = waitForSignal(BEGIN_TRANSACTION_SIGNAL, (javacall_handle)busId, NULL, 0);
+            if (result != JAVACALL_OK) {
+                checkJavacallFailure(env, result);
+            } else if (env->ExceptionCheck() == JNI_FALSE) {
+                continue;
+            }
+        } else {
+            throwIllegalStateException(env, "transaction is already in progress");
+        }
+    } while(0);
+}
+
+/*
+ * Class:     com_oracle_dio_i2cbus_impl_I2CSlaveImpl
+ * Method:    end0
+ */
+JNIEXPORT void JNICALL Java_com_oracle_dio_i2cbus_impl_I2CSlaveImpl_end0
+  (JNIEnv* env, jobject obj) {
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_int32 busId;
+    javacall_result result = javacall_i2c_end(getDeviceHandle(device), &busId);
+    if (result == JAVACALL_OK) {
+        jclass klass = env->GetObjectClass(obj);
+        jfieldID startedField = env->GetFieldID(klass, "isTransactionStarted", "Z");
+        env->SetBooleanField(obj, startedField, JNI_FALSE);
+        generateSignal(BEGIN_TRANSACTION_SIGNAL, (javacall_handle)busId, 0);
+    } else {
+        throwIllegalStateException(env, "transaction is not currently in progress");
+    }
+}
+
+/*
+ * Class:     com_oracle_dio_i2cbus_impl_I2CSlaveImpl
+ * Method:    write0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_i2cbus_impl_I2CSlaveImpl_write0
+  (JNIEnv* env, jobject obj, jobject src) {
+
+    jint pos = 0, cap = 0, off = 0, lim = 0;
+    jboolean readonly = JNI_TRUE;
+    jbyte* directArray = NULL;
+    jbyteArray heapArray = NULL;
+
+    if (!getByteBufferInformation(env, src, &directArray, &heapArray,
+                                  &off, &pos, &cap, &lim,
+                                  &readonly)) {
+        env->ExceptionClear();
+        throwRuntimeException(env, "fault source buffer");
+        return 0;
+    }
+    if (heapArray != NULL) {
+        directArray = env->GetByteArrayElements(heapArray, NULL);
+    }
+
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_handle handle = getDeviceHandle(device);
+    javacall_int32 bytesWritten = 0;
+    javacall_result result;
+
+    pos += off;
+    result = javacall_i2c_write_start(handle, (const char*)(directArray + pos),
+                                      lim - pos, JAVACALL_TRUE, &bytesWritten);
+
+    if (result == JAVACALL_WOULD_BLOCK) {
+        javacall_handle status = NULL;
+        result = waitForSignal(SEND_SIGNAL, handle, &status, 0);
+
+        if ((result != JAVACALL_OK) ||
+            (env->ExceptionCheck() != JNI_FALSE) ||
+            (result = (javacall_result)(javacall_int32)status) != JAVACALL_OK) {
+            javacall_i2c_write_finish(handle, NULL, 0, &bytesWritten);
+        } else {
+            result = javacall_i2c_write_finish(handle, (const char*)(directArray + pos),
+                                               lim - pos, &bytesWritten);
+        }
+    }
+
+    if (heapArray != NULL && directArray != NULL) {
+        env->ReleaseByteArrayElements(heapArray, directArray, JNI_ABORT);
+    }
+
+    checkJavacallFailure(env, result);
+    return bytesWritten;
+}
+
+/*
+ * Class:     com_oracle_dio_i2cbus_impl_I2CSlaveImpl
+ * Method:    read0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_i2cbus_impl_I2CSlaveImpl_read0
+  (JNIEnv* env, jobject obj, jobject dst, jint skip) {
+
+    jint pos = 0, cap = 0, off = 0, lim = 0;
+    jboolean readonly = JNI_TRUE;
+    jbyte* directArray = NULL;
+    jbyteArray heapArray = NULL;
+
+    if (!getByteBufferInformation(env, dst, &directArray, &heapArray,
+                                  &off, &pos, &cap, &lim,
+                                  &readonly)) {
+        env->ExceptionClear();
+        throwRuntimeException(env, "fault destination buffer");
+        return 0;
+    }
+    if (readonly != JNI_FALSE) {
+        throwIOException(env, "readonly destination buffer");
+        return 0;
+    }
+    if (heapArray != NULL) {
+        directArray = env->GetByteArrayElements(heapArray, NULL);
+    }
+
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_handle handle = getDeviceHandle(device);
+    javacall_int32 bytesRead = 0;
+    javacall_result result;
+
+    pos += off;
+    result = javacall_i2c_read_start(handle, skip, (char*)(directArray + pos),
+                                     lim - pos, JAVACALL_TRUE, &bytesRead);
+
+    if (result == JAVACALL_WOULD_BLOCK) {
+        javacall_handle status = NULL;
+        result = waitForSignal(RECEIVE_SIGNAL, handle, &status, 0);
+
+        if ((result != JAVACALL_OK) ||
+            (env->ExceptionCheck() != JNI_FALSE) ||
+            (result = (javacall_result)(javacall_int32)status) != JAVACALL_OK) {
+            javacall_i2c_read_finish(handle, NULL, 0, &bytesRead);
+        } else {
+            result = javacall_i2c_read_finish(handle, (char*)(directArray + pos),
+                                              lim - pos, &bytesRead);
+        }
+    }
+
+    if (heapArray != NULL && directArray != NULL) {
+        env->ReleaseByteArrayElements(heapArray, directArray,
+                                      result == JAVACALL_OK ? 0 : JNI_ABORT);
+    }
+
+    checkJavacallFailure(env, result);
+    return bytesRead;
+}
+
+/*
+ * Class:     com_oracle_dio_i2cbus_impl_I2CSlaveImpl
+ * Method:    getGrpID0
+ */
+JNIEXPORT jint JNICALL Java_com_oracle_dio_i2cbus_impl_I2CSlaveImpl_getGrpID0
+  (JNIEnv* env, jobject obj) {
+    jint grpId = 0;
+    device_reference device = getDeviceReferenceFromDeviceObject(env, obj);
+    javacall_result result;
+    result = javacall_i2c_get_group_id(getDeviceHandle(device), &grpId);
+    if (result != JAVACALL_OK) {
+        throwIOException(env, "Error while getting group ID");
+    }
+    return grpId;
+}
+
+/**
+* See javacall_i2c.h for definition
+*/
+void javanotify_i2c_event
+  (const javacall_i2c_signal_type signal, const javacall_handle handle, javacall_int32 result) {
+    switch (signal) {
+    case JAVACALL_I2C_SEND_SIGNAL:
+        generateSignal(SEND_SIGNAL, handle, (javacall_handle)result);
+        break;
+    case JAVACALL_I2C_RECV_SIGNAL:
+        generateSignal(RECEIVE_SIGNAL, handle, (javacall_handle)result);
+        break;
+    }
+}
+
+} // extern "C"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javacall_defs.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,468 @@
+/**
+ * @mainpage Javacall API
+ * <h3>Reference Documentation for Javacall Porting API</h3>
+ *
+ * <p>These pages specify the Javacall porting APIs. They
+ * describe the header files' contents, including function
+ * signatures, globals, and data structures. The pages
+ * organize the files both functionally by subsystem and
+ * service, and alphabetically. They also index functions,
+ * globals, and data structures for easier information access.
+ * </p>
+ *
+
+ *
+ */
+
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __JAVACALL_DEFINE_H_
+#define __JAVACALL_DEFINE_H_
+
+/**
+ * @file javacall_defs.h
+ * @ingroup Common
+ * @brief Common definitions for javacall
+ */
+
+/**
+ * @defgroup Common Common Javacall API Definitions
+ *
+ * The common javacall definitions are defined in this file
+ * @{
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * To use javacall wrappers
+ *   turn USE_JAVACALL_WRAPPERS on  for javacall files and
+ *   turn USE_JAVACALL_WRAPPERS off for native test files.
+ * See the document below for details:
+ *   porting_api/tools/wrappers/README.txt
+ */
+#ifdef USE_JAVACALL_WRAPPERS
+#include "javacall_wrappers_define.h"
+#endif
+
+/**
+ * @define NULL
+ * @brief A null pointer constant
+ */
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL    0
+#else
+#define NULL    ((void*)0)
+#endif
+#endif
+
+/**
+ * @enum javacall_result
+ * @brief javacall error results
+ */
+typedef enum {
+   /** Generic success */
+   JAVACALL_OK = 0,
+   /** Generic failure */
+   JAVACALL_FAIL = -1,
+   /** Not implemented */
+   JAVACALL_NOT_IMPLEMENTED = -2,
+   /** Out of memory */
+   JAVACALL_OUT_OF_MEMORY = -3,
+   /** Invalid argument */
+   JAVACALL_INVALID_ARGUMENT = -4,
+   /** Would block */
+   JAVACALL_WOULD_BLOCK = -5,
+   /** Connection not found */
+   JAVACALL_CONNECTION_NOT_FOUND = -6,
+   /** Operation is interrupted */
+   JAVACALL_INTERRUPTED = -7,
+   /** Return by javacall read on
+       SoS connections or socket in
+       Non-Delay mode. Caller should
+       reinvoke the read function
+       to retry reading data */
+   JAVACALL_NO_DATA_AVAILABLE = -8,
+   /** File not found in the given path */
+   JAVACALL_FILE_NOT_FOUND = -9,
+   /** bad file name */
+   JAVACALL_BAD_FILE_NAME = -10,
+   /** End of file */
+   JAVACALL_END_OF_FILE = -11,
+   /** I/O error occurred */
+   JAVACALL_IO_ERROR = -12,
+   /** bad properties in jad file,
+    * either a missing required property or
+    * incorrectly formatted property */
+   JAVACALL_BAD_JAD_PROPERTIES = -13,
+    /** javacall properties db value not found */
+   JAVACALL_VALUE_NOT_FOUND = -14,
+    /** Invalid state */
+   JAVACALL_INVALID_STATE = -15,
+   /** Timeout elapsed */
+   JAVACALL_TIMEOUT = -16,
+   /** No audio device found. Return this code only in case you want to
+     * reject playback, i.e. when the content is audio only. If some playback
+     * is still possible (e.g. mute video) then return JAVACALL_OK instead
+     */
+   JAVACALL_NO_AUDIO_DEVICE = -17,
+   /** Data supplied to javacall is unsuitable for some reason, corrupted, etc */
+   JAVACALL_BAD_DATA_FORMAT = -18,
+   /**
+    * A JavaNotify event that makes the function call invalid (or unnecessary)
+    * happened.
+    *
+    * For example, \ref JAVACALL_EVENT_MEDIA_DEVICE_UNAVAILABLE was sent (but
+    * not yet received) just before \a Java called \ref javacall_media_play
+    */
+   JAVACALL_INVALID_SINCE_EVENT = -19,
+   /** the processing initiated by the previous call of the function is still
+     * not finished, so right now the implementation is busy and unable to
+     * process the current function call.
+     */
+   JAVACALL_BUSY = -20,
+   /**
+    * Signals that an error occurred while attempting to bind a socket to a
+    * local address and port.
+    */
+   JAVACALL_BIND_ERROR = -21,
+   /**
+    * Signals that an error occurred while attempting to connect a socket to a
+    * remote address and port. Typically, the connection was refused remotely
+    * (e.g., no process is listening on the remote address/port).
+    */
+   JAVACALL_CONNECT_ERROR = -22,
+   /**
+    * Signals that an error occurred while attempting to connect a socket to a
+    * remote address and port. Typically, the remote host cannot be reached
+    * because of an intervening firewall, or if an intermediate router is down.
+    */
+   JAVACALL_NO_ROUTE_TO_HOST_ERROR = -23,
+    /**
+     * Signals that an ICMP Port Unreachable message has been received on a
+     * connected datagram.
+     */
+   JAVACALL_PORT_UNREACHABLE_ERROR = -24,
+
+   /**
+    * The handle is invalid.
+    */
+   JAVACALL_INVALID_HANDLE_ERROR = -25
+} javacall_result;
+
+/**
+ * @define JAVACALL_SUCCEEDED
+ * @param Status a status code to check
+ * @brief true if the Status parameter corresponds to successful operation completion, false otherwise
+ */
+#define JAVACALL_SUCCEEDED(Status) ((javacall_result)(Status) >= 0)
+
+/**
+ * @enum javacall_bool
+ * @brief javacall boolean type
+ */
+typedef enum {
+    /** FALSE */
+    JAVACALL_FALSE = 0,
+    /** TRUE */
+    JAVACALL_TRUE  = 1
+} javacall_bool;
+
+/**
+ * @typedef javacall_handle
+ * @brief general handle type
+ */
+typedef void* javacall_handle;
+
+/**
+ * Platform-dependent defines,
+ * check JAVACALL_PLATFORM_INC_DIR environment variable
+ */
+#include <javacall_platform_defs.h>
+
+/**
+ * @define javacall_assert
+ * @brief javacall_platform_defs.h can override this definition
+ * @note MIDP, PCSL or JAVACALL must define ENABLE_DEBUG=1 for debug mode
+ */
+#ifndef javacall_assert
+/*   #if ENABLE_DEBUG
+    extern void javacall_print(const char *s);
+    // the simplest & most compatible implementation
+    #define javacall_assert(c) \
+        (c) ? (void)0 : (\
+            (javacall_print(#c ": ASSERT FAIL\n")), \
+            (void)(*(int*)0x00000000 = 0))
+    #else
+*/
+    #define javacall_assert(c) (void)0
+/*    #endif */
+#endif
+
+/**
+ * @typedef javacall_suite_id
+ * @brief suite unique ID
+ */
+typedef javacall_int32 javacall_suite_id;
+
+/**
+ * @brief unique storage ID
+ */
+typedef javacall_int32 javacall_storage_id;
+
+/**
+ * @brief unique AMS folder ID
+ */
+typedef javacall_int32 javacall_folder_id;
+
+/**
+ * @brief unique running midlet ID
+ */
+typedef javacall_int32 javacall_app_id;
+
+/**
+ * @brief unique RMS ID
+ */
+typedef javacall_int32 javacall_rms_id;
+
+/**
+ * @brief unique RMS record ID
+ */
+typedef javacall_int32 javacall_record_id;
+
+/**
+ * @enum javacall_ip_version
+ * @brief javacall IP version type
+ */
+typedef enum
+{
+   /**
+   * Undefined Internet Protocol version
+   */
+   JAVACALL_IP_VERSION_ANY = 0,
+
+   /**
+    * The Internet Protocol version 4 (IPv4)
+    */
+   JAVACALL_IP_VERSION_4 = 2,
+
+   /**
+    * The Internet Protocol version 6 (IPv6)
+    */
+   JAVACALL_IP_VERSION_6 = 23,
+
+ } javacall_ip_version;
+
+/**
+ * @define ADDR_LEN
+ * @brief size in bytes of an IP address depending on the IP version
+ */
+#define ADDR_LEN(ip_version) (JAVACALL_IP_VERSION_4 == ip_version ? 4 : 16)
+
+/**
+ * @define JAVACALL_INVALID_SUITE_ID
+ * @brief The suite_id that does not correspond to any midlet suite
+ *
+ * IMPL_NOTE: value -1 is reserved for internal (rommized) MIDlet suites
+ */
+#define JAVACALL_INVALID_SUITE_ID (-2)
+
+/** Suite ID that is never used. (see the com.sun.midp.midlet.MIDletSuite class)*/
+#define JAVACALL_UNUSED_SUITE_ID 0
+
+/** Suite ID used for internal midlet suites. (see the com.sun.midp.midlet.MIDletSuite class)*/
+#define JAVACALL_INTERNAL_SUITE_ID (-1)
+
+
+/**
+ * @define JAVACALL_INVALID_FOLDER_ID
+ * @brief The folder id that does not correspond to any folder
+ */
+#define JAVACALL_INVALID_FOLDER_ID (-1)
+
+/**
+ * @define JAVACALL_ROOT_FOLDER_ID
+ * @brief ID of the root folder
+ */
+#define JAVACALL_ROOT_FOLDER_ID (-2)
+
+/**
+ * @define JAVACALL_INVALID_STORAGE_ID
+ * @brief The storage id that does not correspond to any storage
+ */
+#define JAVACALL_INVALID_STORAGE_ID (-1)
+
+/**
+ * @define JAVACALL_INVALID_APP_ID
+ * @brief The application id that does not correspond to any running application
+ */
+#define JAVACALL_INVALID_APP_ID (-1)
+
+/**
+ * @define JAVACALL_INVALID_DISPLAY_DEVICE_ID
+ * @brief The display device id that does not correspond to any display device
+ */
+#define JAVACALL_INVALID_DISPLAY_DEVICE_ID (-1)
+
+/**
+ * @typedef javacall_utf16_string
+ * @brief general utf16 string type, this type is null terminated string
+ */
+typedef javacall_utf16* javacall_utf16_string;
+
+/**
+ * @typedef javacall_const_utf16_string
+ * @brief general constant utf16 string type, this type is constant null
+ * terminated string
+ */
+typedef const javacall_utf16* javacall_const_utf16_string;
+
+/**
+ * @typedef javacall_utf8_string
+ * @brief general utf8 string type, this type is null terminated string
+ */
+typedef unsigned char* javacall_utf8_string;
+
+/**
+ * @typedef javacall_const_utf8_string
+ * @brief general constant utf8 string type, this type is constant null
+ * terminated string
+ */
+typedef const unsigned char* javacall_const_utf8_string;
+
+/**
+ * @typedef javacall_ascii_string
+ * @brief general eight-bit ASCII string type,
+ *        this type is null terminated string
+ */
+typedef char* javacall_ascii_string;
+
+/**
+ * @typedef javacall_const_ascii_string
+ * @brief general constant eight-bit ASCII string type,
+ *        this type is constant null terminated string
+ */
+typedef const char* javacall_const_ascii_string;
+
+/**
+ * @def JAVACALL_INVALID_HANDLE
+ * Invalid handle
+ */
+#define JAVACALL_INVALID_HANDLE    (javacall_handle)-1
+
+#if ENABLE_DYNAMIC_PIXEL_FORMAT
+/**
+ * @typedef javacall_pixel16
+ * @brief 16-bit pixel type for LCD graphics
+ */
+typedef unsigned short javacall_pixel16;
+/**
+ * @typedef javacall_pixel32
+ * @brief 32-bit pixel type for LCD graphics
+ */
+typedef unsigned int javacall_pixel32;
+/**
+ * @typedef javacall_pixel
+ * @brief Default pixel type for LCD graphics
+ */
+typedef javacall_pixel32 javacall_pixel;
+#elif ENABLE_32BITS_PIXEL_FORMAT
+/**
+ * @typedef javacall_pixel
+ * @brief Default pixel type for LCD graphics
+ */
+typedef unsigned int javacall_pixel;
+#else
+/**
+ * @typedef javacall_pixel
+ * @brief Default pixel type for LCD graphics
+ */
+typedef unsigned short javacall_pixel;
+/**
+ * @typedef javacall_pixel16
+ * @brief 16-bit pixel type for LCD graphics
+ */
+typedef unsigned short javacall_pixel16;
+#endif
+
+/**
+ * @brief A list of properties that can be searched by a key
+ *
+ * IMPL_NOTE: should be moved to nams/javacall_ams_common.h
+ */
+typedef struct _javacall_ams_properties {
+    /**
+     * Number of properties, there are 2 Strings (key/value)
+     * for each property.
+     */
+    int numberOfProperties;
+    /**
+     * A pointer to an array of properties. Keys and values are interleaved.
+     */
+    javacall_utf16_string* pStringArr;
+} javacall_ams_properties;
+
+/**
+ * @define JAVACALL_UNKNOWN_LENGTH
+ * @brief Corresponds to unknown length
+ * @note  Be careful with bit-depth context with signed-unsigned conversion: <br>
+ * May happen that (\c unsigned \c int)JAVACALL_UNKNOWN_LENGTH != (\c long \c long)JAVACALL_UNKNOWN_LENGTH
+ */
+#define JAVACALL_UNKNOWN_LENGTH (-1)
+
+/**
+ * @brief Provides a version of the product
+ */
+extern javacall_const_ascii_string javacall_product_version;
+
+/**
+ * @}
+ */
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+/**
+ * @defgroup IMPNG IMPNG API
+ *
+ * This document describes the requirements for implementing IMPNG
+ * ( Information Module Profile - Next Generation, JSR 228). <br>
+ *
+ * The IMP-NG specification is based on the IMP specification (see JSR-195) and provides backward compatibility with IMP so that IMlets written for IMP can execute in IMP-NG environments.
+ * IMP-NG is a strict subset of the Mobile Information Device Profile (MIDP), version 2.0, which is described in Mobile Information Device Profile, version 2.0 (JSR-118).<br><br>
+ * The IMP-NG is designed to operate on top of the Connected, Limited Device Configuration (CLDC) which is described in Connected, Limited Device Configuration (JSR-30) (http://jcp.org/jsr/detail/30.jsp).
+ * While the IMP-NG specification was designed assuming only CLDC 1.0 features, it will also work on top of CLDC 1.1 (JSR-139) (http://jcp.org/jsr/detail/139.jsp), and presumably any newer versions.
+ * It is anticipated, though, that most IMP-NG implementations will be based on CLDC 1.0.<br>
+ *
+ * The specifications be found at: http://jcp.org/en/jsr/detail?id=228
+ *
+ * @{
+ * @}
+ */
+#endif /* __JAVACALL_DEFINE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javacall_logging.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,453 @@
+/*
+ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+#ifndef __JAVACALL_LOGGING_H_
+#define __JAVACALL_LOGGING_H_
+
+/**
+ * @file javacall_logging.h
+ * @ingroup MandatoryLogging
+ * @brief Javacall interfaces for logging
+ */
+
+#include "javacall_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup MandatoryLogging Logging API
+ *  @ingroup IMPNG
+ *
+ *  @{
+ */
+
+/**
+ * Prints out a string to a system specific output strream
+ *
+ * @param s a NULL terminated character buffer to be printed
+ */
+void javacall_print(const char *s);
+
+/**
+ * Prints out a character array to a system specific output strream
+ *
+ * @param s address of the first character to print
+ * @param length number of the characters to print
+ */
+void javacall_print_chars(const char* s, int length);
+
+#ifdef ENABLE_SYSTEM_ERR_STREAM
+/**
+ * Prints out a character array to the error output stream
+ *
+ * @param s address of the first character to print
+ * @param length number of the characters to print
+ */
+void javacall_print_error_chars(const char* s, int length);
+#endif
+
+/**
+ * Prints out a string to a system specific output strream
+ * with format string.
+ *
+ * @param format format string and variable lists.
+ */
+/*OPTIONAL*/
+void javacall_printf(const char * format,...);
+
+#if ENABLE_TCP_LOGGING
+typedef enum {
+    no_implicit_cr_in_lf = 0,
+    implicit_cr_in_lf = 1
+} javacall_lf_processing;
+
+/**
+ * Put a character array to the TCP logging buffer
+ *
+ * @param data address of the first character to print
+ * @param len number of the characters to print
+ * @param lf_processing specifies line feed character (LF) processing
+ */
+void javanotify_tcp_logging(const char *data, int len, javacall_lf_processing lf_processing);
+#endif /* ENABLE_TCP_LOGGING */
+
+/**
+ * Must be called before calling javanotify_log_string() and javanotify_log_char()
+ * functions. Could lock some resources if some routines called in javanotify_log_string() or
+ * javanotify_log_char() are not thread-safe.
+ */
+void javanotify_log_lock(void);
+
+/**
+ * Forward log string to all enabled log sinks (e.g. VM agent log channel, javacall_print,
+ * TCP log).
+ *
+ * @param data pointer to null-terminated UTF8 string
+ */
+void javanotify_log_string(const char *data);
+
+/**
+ * Forward log char to all enabled log sinks (e.g. VM agent log channel, javacall_print,
+ * TCP log).
+ *
+ * @param data character to print
+ */
+void javanotify_log_char(char data);
+
+/**
+ * The methods must be called to release common logging resources.
+ * Each javanotify_log_lock(0 call must have corresponding javanotify_log_unlock() call.
+ */
+void javanotify_log_unlock(void);
+
+
+#if ENABLE_VM_LOGGING
+/**
+ * Prints out a VM trace string to output stream provided by SDK or
+ * by any other debugging tools available in development environment.
+ * VM trace can contain information about GC, classes loading, exceptions,
+ * method invocations, etc.
+ *
+ * @param task_id ID of VM task that originated trace message
+ * @param msg string with VM trace message
+ */
+/*OPTIONAL*/
+void javacall_logging_vm_trace(int task_id, const char *msg);
+/**
+ * Sends log messages accumulated in a javacall buffer to ODT agent.
+ *
+ * @param buffer string with VM trace messages
+ */
+/*OPTIONAL*/
+void javanotify_logging_event(char *buffer);
+#endif
+
+
+/**
+ * @enum midp_log_channels
+ * @brief list of possible logging channels
+ */
+typedef enum {
+    /** Javacall default channel */
+    javacall_channel_default = 2608,
+    /** Javacall system out */
+    javacall_channel_system_out,
+    /** Javacall JVM internal*/
+    javacall_channel_jvm_internal,
+    /** Javacall trace in */
+    javacall_channel_trace_in,
+    /** Javacall trace out */
+    javacall_channel_trace_out
+} midp_log_channels;
+
+/**
+ * Returns the jlong-specifier prefix used with type characters in
+ * printf functions or wprintf functions to specify interpretation
+ * of jlong, the 64-bit signed integer type,
+ * e.g. for win32 is "%I64d", for linux is "%lld"
+ */
+const char * javacall_jlong_format_specifier(void);
+
+/**
+ * Returns the julong-specifier prefix used with type characters in
+ * printf functions or wprintf functions to specify interpretation
+ * of julong, the 64-bit unsigned integer type,
+ * e.g. for win32 is "%I64u", for linux is "%llu"
+ */
+const char * javacall_julong_format_specifier(void);
+
+/** @} */
+
+/**
+ * JavaCall logging severity levels, these values are assumed to be equal
+ * to similar MIDP logging definitions.
+ */
+
+#define JAVACALL_LOGGING_INFORMATION 0
+#define JAVACALL_LOGGING_WARNING  1
+#define JAVACALL_LOGGING_ERROR  2
+#define JAVACALL_LOGGING_CRITICAL  3
+#define JAVACALL_LOGGING_DISABLED  4
+
+/**
+ * @enum javacall_logging_channel
+ * @brief JavaCall logging channels
+ *
+ */
+typedef enum {
+    JC_NONE = 0,
+    JC_TIME,
+    JC_FILE,
+    JC_WMA,
+    JC_MMA,
+    JC_PIM,
+    JC_FC,
+    JC_AMMS,
+    JC_CHAPI,
+    JC_NAMS,
+    JC_BT,
+    JC_ODT,
+    JC_FONT,
+    JC_LCD,
+    JC_SOCKET,
+    JC_MMS,
+    JC_MAINLOOP,
+    JC_PERFORMANCE,
+    JC_LIFECYCLE,
+    JC_EVENTS,
+    JC_MEMORY,
+    JC_SPRINT_EXT,
+    JC_SENSOR,
+    JC_CMS,
+    JC_LOCATION,
+    JC_SECURITY,
+    JC_SERIAL,
+    JC_MOBILE,
+    JC_SIMCARD,
+    JC_SYSTEMEVENT,
+    JC_OJSB,
+    JC_CONTACTLESS,
+    JC_DAAPI,
+    JC_PROXY,
+    JC_NETWORK,
+    JC_LINEUI,
+    JC_MAX
+
+} javacall_logging_channel;
+
+#ifndef JAVACALL_REPORT_LEVEL
+/** If report level is not defined, set it to information level */
+#define JAVACALL_REPORT_LEVEL JAVACALL_LOGGING_INFORMATION
+#endif
+
+
+/**
+ * Initializes Javacall logging subsytem.
+ */
+void javacall_logging_initialize(void);
+
+/**
+ * Report a message to the Logging service.
+ *
+ * The <code>message</code> parameter is treated as a format
+ * string to the standard C library call printf would be, with
+ * conversion specifications (%s, %d, %c, etc) causing the
+ * conversion and output of each successive argument after
+ * <code>message</code>  As with printf, having a conversion
+ * character in <code>message</code> without an associated argument
+ * following it is an error.
+ *
+ * To ensure that no character in <code>message</code> is
+ * interpreted as requiring conversion, a safe way to call
+ * this method is:
+ * <code> javacall_logging_printf(severity, chanID, "%s", message); </code>
+
+ * @param severity severity level of report
+ * @param channelID area report relates to
+ * @param filename source file name
+ * @param lineno line number
+ * @param format detail message to go with the report
+ *                should not be NULL
+ */
+void javacall_logging_printf(int severity, javacall_logging_channel channelID,
+        const char* filename, int lineno, const char *format, ...);
+
+/**
+ * Report a string in utf16 after given prefix message to Logging server.
+ *
+ * @param severity severity level of report
+ * @param channelID area report relates to
+ * @param filename source file name
+ * @param lineno line number
+ * @param prefix_ascii_msg a prefix message to print before the following utf16 message.
+ * @param utf16_msg message in utf16 to print.
+ * @param utf16_len length of utf16 message
+ *                  if -1, utf16_msg is printed until NULL termination.
+ */
+/*OPTIONAL*/
+void javacall_logging_utf16_print(int severity,
+                                  javacall_logging_channel channelID,
+                                  const char* filename,
+                                  int lineno,
+                                  const char *prefix,
+                                  const javacall_utf16* msg,
+                                  int msg_length);
+
+/**
+ * @name JAVACALL_REPORT_INFO*() macros
+ * JAVACALL_REPORT_INFO*() macros are defined if <code>JAVACALL_REPORT_LEVEL
+ * <= JAVACALL_LOGGING_INFORMATION</code>, and are empty otherwise.
+ * @see javacall_logging_printf
+ * @{
+ */
+#if JAVACALL_REPORT_LEVEL <= JAVACALL_LOGGING_INFORMATION
+#define JAVACALL_REPORT_INFO(ch, msg) javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg)
+#define JAVACALL_REPORT_INFO1(ch, msg, a1) javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1)
+#define JAVACALL_REPORT_INFO2(ch, msg, a1, a2) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2)
+#define JAVACALL_REPORT_INFO3(ch, msg, a1, a2, a3) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2, a3)
+#define JAVACALL_REPORT_INFO4(ch, msg, a1, a2, a3, a4) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4)
+#define JAVACALL_REPORT_INFO5(ch, msg, a1, a2, a3, a4, a5) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5)
+#define JAVACALL_REPORT_INFO6(ch, msg, a1, a2, a3, a4, a5, a6) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5, a6)
+#define JAVACALL_REPORT_INFO7(ch, msg, a1, a2, a3, a4, a5, a6, a7) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5, a6, a7)
+#define JAVACALL_REPORT_INFO8(ch, msg, a1, a2, a3, a4, a5, a6, a7, a8) \
+  javacall_logging_printf(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5, a6, a7, a8)
+
+#define JAVACALL_REPORT_UTF16_INFO(ch, prefix, msg, len) \
+    javacall_logging_utf16_print(JAVACALL_LOGGING_INFORMATION, ch, __FILE__, __LINE__, prefix, msg, len)
+
+#else
+#define JAVACALL_REPORT_INFO(ch, msg)
+#define JAVACALL_REPORT_INFO1(ch, msg, a1)
+#define JAVACALL_REPORT_INFO2(ch, msg, a1, a2)
+#define JAVACALL_REPORT_INFO3(ch, msg, a1, a2, a3)
+#define JAVACALL_REPORT_INFO4(ch, msg, a1, a2, a3, a4)
+#define JAVACALL_REPORT_INFO5(ch, msg, a1, a2, a3, a4, a5)
+#define JAVACALL_REPORT_INFO6(ch, msg, a1, a2, a3, a4, a5, a6)
+#define JAVACALL_REPORT_INFO7(ch, msg, a1, a2, a3, a4, a5, a6, a7)
+#define JAVACALL_REPORT_INFO8(ch, msg, a1, a2, a3, a4, a5, a6, a7, a8)
+
+#define JAVACALL_REPORT_UTF16_INFO(ch, prefix, msg, len)
+#endif
+/** @} */
+
+/**
+ * @name JAVACALL_REPORT_WARN*() macros
+ * JAVACALL_REPORT_WARN*() macros are defined if <code> JAVACALL_REPORT_LEVEL
+ * <= JAVACALL_LOGGING_WARNING</code> and are empty otherwise.
+ * @see javacall_logging_printf
+ * @{
+ */
+#if JAVACALL_REPORT_LEVEL <= JAVACALL_LOGGING_WARNING
+#define JAVACALL_REPORT_WARN(ch, msg) javacall_logging_printf(JAVACALL_LOGGING_WARNING, ch, __FILE__, __LINE__, msg)
+#define JAVACALL_REPORT_WARN1(ch, msg, a1) javacall_logging_printf(JAVACALL_LOGGING_WARNING, ch, __FILE__, __LINE__, msg, a1)
+#define JAVACALL_REPORT_WARN2(ch, msg, a1, a2) javacall_logging_printf(JAVACALL_LOGGING_WARNING, ch, __FILE__, __LINE__, msg, a1, a2)
+#define JAVACALL_REPORT_WARN3(ch, msg, a1, a2, a3) \
+  javacall_logging_printf(JAVACALL_LOGGING_WARNING, ch, __FILE__, __LINE__, msg, a1, a2, a3)
+#define JAVACALL_REPORT_WARN4(ch, msg, a1, a2, a3, a4) \
+  javacall_logging_printf(JAVACALL_LOGGING_WARNING, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4)
+
+#define JAVACALL_REPORT_UTF16_WARN(ch, prefix, msg, len) \
+    javacall_logging_utf16_print(JAVACALL_LOGGING_WARNING, ch, __FILE__, __LINE__, prefix, msg, len)
+#else
+#define JAVACALL_REPORT_WARN(ch, msg)
+#define JAVACALL_REPORT_WARN1(ch, msg, a1)
+#define JAVACALL_REPORT_WARN2(ch, msg, a1, a2)
+#define JAVACALL_REPORT_WARN3(ch, msg, a1, a2, a3)
+#define JAVACALL_REPORT_WARN4(ch, msg, a1, a2, a3, a4)
+
+#define JAVACALL_REPORT_UTF16_WARN(ch, prefix, msg, len)
+#endif
+/** @} */
+
+/**
+ * @name JAVACALL_REPORT_ERROR*() macros
+ * JAVACALL_REPORT_ERROR*() macros are defined if <code> JAVACALL_REPORT_LEVEL
+ * <= JAVACALL_LOGGING_ERROR</code> and are empty otherwise.
+ * @see javacall_logging_printf
+ * @{
+ */
+#if JAVACALL_REPORT_LEVEL <= JAVACALL_LOGGING_ERROR
+#define JAVACALL_REPORT_ERROR(ch, msg) javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg)
+#define JAVACALL_REPORT_ERROR1(ch, msg, a1) javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg, a1)
+#define JAVACALL_REPORT_ERROR2(ch, msg, a1, a2) \
+  javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg, a1, a2)
+#define JAVACALL_REPORT_ERROR3(ch, msg, a1, a2, a3) \
+  javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg, a1, a2, a3)
+#define JAVACALL_REPORT_ERROR4(ch, msg, a1, a2, a3, a4) \
+  javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4)
+#define JAVACALL_REPORT_ERROR5(ch, msg, a1, a2, a3, a4, a5) \
+  javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5)
+#define JAVACALL_REPORT_ERROR6(ch, msg, a1, a2, a3, a4, a5, a6) \
+  javacall_logging_printf(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5, a6)
+
+#define JAVACALL_REPORT_UTF16_ERROR(ch, prefix, msg, len) \
+    javacall_logging_utf16_print(JAVACALL_LOGGING_ERROR, ch, __FILE__, __LINE__, prefix, msg, len)
+#else
+#define JAVACALL_REPORT_ERROR(ch, msg)
+#define JAVACALL_REPORT_ERROR1(ch, msg, a1)
+#define JAVACALL_REPORT_ERROR2(ch, msg, a1, a2)
+#define JAVACALL_REPORT_ERROR3(ch, msg, a1, a2, a3)
+#define JAVACALL_REPORT_ERROR4(ch, msg, a1, a2, a3, a4)
+#define JAVACALL_REPORT_ERROR5(ch, msg, a1, a2, a3, a4, a5)
+#define JAVACALL_REPORT_ERROR6(ch, msg, a1, a2, a3, a4, a5, a6)
+
+#define JAVACALL_REPORT_UTF16_ERROR(ch, prefix, msg, len)
+#endif
+/** @} */
+
+/**
+ * @name JAVACALL_REPORT_CRIT*() macros
+ * JAVACALL_REPORT_CRIT*() macros are defined if <code> JAVACALL_REPORT_LEVEL
+ * <= JAVACALL_LOGGING_CRITICAL</code> and are empty otherwise.
+ * @see javacall_logging_printf
+ * @{
+ */
+#if JAVACALL_REPORT_LEVEL <= JAVACALL_LOGGING_CRITICAL
+#define JAVACALL_REPORT_CRIT(ch, msg) javacall_logging_printf(JAVACALL_LOGGING_CRITICAL, ch, __FILE__, __LINE__, msg)
+#define JAVACALL_REPORT_CRIT1(ch, msg, a1) javacall_logging_printf(JAVACALL_LOGGING_CRITICAL, ch,__FILE__, __LINE__, msg, a1)
+#define JAVACALL_REPORT_CRIT2(ch, msg, a1, a2) \
+  javacall_logging_printf(JAVACALL_LOGGING_CRITICAL, ch, __FILE__, __LINE__, msg, a1, a2)
+#define JAVACALL_REPORT_CRIT3(ch, msg, a1, a2, a3) \
+  javacall_logging_printf(JAVACALL_LOGGING_CRITICAL, ch, __FILE__, __LINE__, msg, a1, a2, a3)
+#define JAVACALL_REPORT_CRIT4(ch, msg, a1, a2, a3, a4) \
+  javacall_logging_printf(JAVACALL_LOGGING_CRITICAL, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4)
+#define JAVACALL_REPORT_CRIT5(ch, msg, a1, a2, a3, a4, a5) \
+  javacall_logging_printf(JAVACALL_LOGGING_CRITICAL, ch, __FILE__, __LINE__, msg, a1, a2, a3, a4, a5)
+
+#define JAVACALL_REPORT_UTF16_CRIT(ch, prefix, msg, len) \
+    javacall_logging_utf16_print(JAVACALL_LOGGING_CRITICAL, ch, __FILE__, __LINE__, prefix, msg, len)
+#else
+#define JAVACALL_REPORT_CRIT(ch, msg)
+#define JAVACALL_REPORT_CRIT1(ch, msg, a1)
+#define JAVACALL_REPORT_CRIT2(ch, msg, a1, a2)
+#define JAVACALL_REPORT_CRIT3(ch, msg, a1, a2, a3)
+#define JAVACALL_REPORT_CRIT4(ch, msg, a1, a2, a3, a4)
+#define JAVACALL_REPORT_CRIT5(ch, msg, a1, a2, a3, a4, a5)
+
+#define JAVACALL_REPORT_UTF16_CRIT(ch, prefix, msg, len)
+#endif
+/** @} */
+
+#if ENABLE_EMERGENCY_LOGGING
+/**
+ * Prints out all information on emergency status.
+ *
+ */
+void javacall_logging_flash(void);
+#endif /* ENABLE_EMERGENCY_LOGGING */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javacall_memory.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,244 @@
+/*
+ *
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+#ifndef __JAVACALL_MEMORY_H_
+#define __JAVACALL_MEMORY_H_
+
+/**
+ * @file javacall_memory.h
+ * @ingroup Memory
+ * @brief Javacall interfaces for memory
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "javacall_defs.h"
+
+#if ENABLE_MEMORY_POOL
+#include "javacall_mempool.h"
+#else
+void *javacall_malloc_internal(unsigned int size, const char* filename, int lineno);
+void *javacall_calloc_internal(unsigned int nelem, unsigned int elsize, const char* filename, int lineno);
+void *javacall_realloc_internal(void* ptr, unsigned int size, const char* filename, int lineno);
+char *javacall_strdup_internal(const char *s1, const char* filename, int lineno);
+void  javacall_free_internal(void *ptr, const char *filename, int lineno);
+#endif
+
+/**
+ * @defgroup Memory Memory API
+ * @ingroup IMPNG
+ *
+ * The Java VM handles memory allocation internally.
+ * As a result, upon VM startup, Java asks for a big continous memory range and frees this memory only upon VM shutdown.
+ * Memory API specification allows the platform to allocate the big memory range using a specialized function called
+ * javacall_memory_heap_allocate.
+ *
+ * @{
+ */
+
+/** @defgroup MandatoryMemory Mandatory Memory API
+ *  @ingroup Memory
+ *
+ * The Java VM handles memory allocation internally. As a result, upon VM startup, Java asks for a big
+ * continous memory range and frees this memory only upon VM shutdown.\n
+ * Memory API specification allows the platform to allocate the big memory range using a specialized
+ * function called javacall_memory_heap_allocate.
+ *
+ *  @{
+ */
+
+
+/**
+ * Allocates large memory heap
+ * VM will use this memory heap for internal memory allocation/deallocation
+ * Will be called ONCE during VM startup!
+ *
+ * @param    size required heap size in bytes
+ * @param    outSize actual size of memory allocated
+ * @return    a pointer to the newly allocated memory, or <tt>0</tt> if not available
+ */
+#ifndef javacall_memory_heap_allocate
+void* javacall_memory_heap_allocate(long size, /*OUT*/ long* outSize);
+#endif
+
+/**
+ * Free large memory heap
+ * VM will call this function once when VM is shutdown to free large memory heap
+ * Will be called ONCE during VM shutdown!
+ *
+ * @param    heap memory pointer to free
+ */
+#ifndef javacall_memory_heap_deallocate
+void javacall_memory_heap_deallocate(void* heap);
+#endif
+
+/**
+ * Allocates memory of the given size from the private JAVACALL memory
+ * pool.
+ *
+ * @param    size Number of byte to allocate
+ * @return    a pointer to the newly allocated memory.
+ *            If the space cannot be allocated, a NULL pointer is returned.
+ *            The zero value of the requested space is considered as an invalid argument. NULL pointer is returned.
+ */
+#ifndef javacall_malloc
+void* javacall_malloc(unsigned int size);
+#endif
+
+
+/**
+ * Reallocates memory of the given size from the private JAVACALL memory
+ * pool. If memory could not be reallocated function returns null,
+ * in this case old pointer is not released.
+ *
+ * @param    ptr  Pointer to previously allocated memory
+ * @param    size Number of byte to allocate
+ * @return    a pointer to the reallocated memory or null if memory could not be reallocated
+ */
+#ifndef javacall_realloc
+void* javacall_realloc(void* ptr, unsigned int size);
+#endif
+
+
+/**
+ * Frees memory at the given pointer in the private JAVACALL memory pool.
+ *
+ * @param    ptr    Pointer to allocated memory
+ */
+#ifndef javacall_free
+void  javacall_free(void* ptr);
+#endif
+
+/** @} */
+
+/******************************************************************************
+ ******************************************************************************
+ ******************************************************************************
+    OPTIONAL FUNCTIONS
+ ******************************************************************************
+ ******************************************************************************
+ ******************************************************************************/
+
+/** @defgroup OptionalMemory Optional Memory API
+ *  @ingroup Memory
+ *
+ * The following functions \n
+ * - malloc \n
+ * - free \n
+ * - calloc \n
+ * - realloc \n
+ * - strdup \n
+ *
+ * \n
+ * can be implemented using basic malloc functionality, but using platform's optimized implementation is
+ * preferred as these function are commonly-used functions.\n
+ * The following definitions declare the standard memory allocation functions malloc and free
+ *
+ *  @{
+ */
+
+
+
+/**
+ * Allocates and clears the given number of elements of the given size
+ * from the private JAVACALL memory pool.
+ *
+ * @param    numberOfElements Number of elements to allocate
+ * @param    elementSize Size of one element
+ * @return    pointer to the newly allocated and cleared memory
+ */
+
+#ifndef javacall_calloc
+void* /*OPTIONAL*/ javacall_calloc (unsigned int numberOfElements, unsigned int elementSize );
+#endif
+
+/**
+ * Duplicates the given string after allocating the memory for it.
+ *
+ * @param    str    String to duplicate
+ * @return  pointer to the duplicate string
+ */
+#ifndef javacall_strdup
+char* /*OPTIONAL*/ javacall_strdup(const char* str);
+#endif
+
+/**
+ * Initialize JavaCall memory management system, must be called once only
+ *
+ * @param startAddr starting address of memory pool; if NULL, it will
+ *                  be either dynamically or statically allocated.
+ * @param size      size of memory pool to use; if size is <= 0,
+ *                  the default memory pool size will be used
+ * @return          0 on success, not 0 on failure
+ */
+#ifndef javacall_memory_initialize
+int /*OPTIONAL*/ javacall_memory_initialize(void *startAddr, int size);
+#endif
+
+/**
+ * Finalizes JavaCall memory management subsystem
+ */
+#ifndef javacall_memory_finalize
+void /*OPTIONAL*/ javacall_memory_finalize(void);
+#endif
+
+/**
+ * Gets total amount of native heap memory available for JavaCall
+ * @return total amount of native heap memory
+ */
+#ifndef javacall_get_total_heap
+int /*OPTIONAL*/ javacall_get_total_heap(void);
+#endif
+
+/**
+ * Gets the current amount of unused native heap memory
+ * @return the current amount of unused native heap memory
+ */
+#ifndef javacall_get_free_heap
+int /*OPTIONAL*/ javacall_get_free_heap(void);
+#endif
+
+/**
+ * Dumps information on memory managed by JavaCall
+ * @param dumpMemoryLeaksOnly set to 0 to dump more verbose information
+ * @return number of allocated blocks
+ */
+#ifndef javacall_malloc_dump
+int /*OPTIONAL*/ javacall_malloc_dump(int dumpMemoryLeaksOnly);
+#endif
+
+/** @} */
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javacall_os.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,247 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+#ifndef __JAVACALL_OS_H
+#define __JAVACALL_OS_H
+
+
+#include "javacall_defs.h"
+
+
+/**
+ * A mutex abstraction.
+ */
+typedef struct _javacall_mutex *javacall_mutex;
+
+/**
+ * A condition variable abstraction.
+ */
+typedef struct _javacall_cond *javacall_cond;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Initialize the OS structure.
+ * This is where timers and threads get started for the first
+ * real_time_tick event, and where signal handlers and other I/O
+ * initialization should occur.
+ *
+ */
+void javacall_os_initialize(void);
+
+/**
+ * Performs a clean-up of all threads and other OS related activity
+ * to allow for a clean and complete restart.  This should undo
+ * all the work that initialize does.
+ */
+void javacall_os_dispose();
+
+/**
+ * Exits calling OS process the VM is running in.
+ *
+ * By default, POSIX exit() call used to implement the function,
+ * in this way OS takes care to free all resources allocated by JVM process.
+ * Otherwise, the implementors of this function are responsible to free all
+ * resources allocated for JVM but not released on abnormal exit from JVM yet.
+ *
+ * @param status the exit status aligned with POSIX systems convention
+ */
+void javacall_os_exit(int status);
+
+/**
+ * javacall_os_flush_icache is used, for example, to flush any caches used by a
+ * code segment that is deoptimized or moved during a garbage collection.
+ * flush at least [address, address + size] (may flush complete icache).
+ *
+ * @param address   Start address to flush
+ * @param size      Size to flush
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_NOT_IMPLEMENTED in case icache flushing is not implemented
+ * @retval JAVACALL_FAIL in case of an error
+ */
+javacall_result javacall_os_flush_icache(unsigned char* address, int size);
+
+/**
+ * Returns a handle that uniquely identifies the current thread.
+ * @return current thread handle
+ */
+javacall_handle javacall_os_thread_self();
+
+/**
+ * Creates new mutex.
+ * @return new mutex, <code>NULL</code> in case of any error.
+ */
+javacall_mutex javacall_os_mutex_create();
+
+/**
+ * Destroys the mutex.
+ * @param mutex the mutex to destroy.
+ */
+void javacall_os_mutex_destroy(javacall_mutex mutex);
+
+/**
+ * Acquires the mutex, waits if the mutex is busy.
+ * @param mutex the mutex.
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_OUT_OF_MEMORY in case of lack of memory
+ * @retval JAVACALL_FAIL in case of any other error
+ */
+javacall_result javacall_os_mutex_lock(javacall_mutex mutex);
+
+/**
+ * Tries to acquire the Mutex, returns immidiately.
+ * @param mutex the mutex.
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_OUT_OF_MEMORY in case of lack of memory
+ * @retval JAVACALL_FAIL in case of any other error
+ * @retval JAVACALL_WOULD_BLOCK if the mutex is acquired by somebody else
+ */
+javacall_result javacall_os_mutex_try_lock(javacall_mutex mutex);
+
+/**
+ * Frees the mutex.
+ * @param mutex the mutex.
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_OUT_OF_MEMORY in case of lack of memory
+ * @retval JAVACALL_FAIL in case of any other error
+ */
+javacall_result javacall_os_mutex_unlock(javacall_mutex mutex);
+
+/**
+ * Creates new condition variable.
+ * @param mutex a mutex that will be bound with the condition variable
+ * in <code>javacall_os_cond_wait</code>.
+ * @return new condition variable, <code>NULL</code> in case of any error.
+ */
+javacall_cond javacall_os_cond_create(javacall_mutex mutex);
+
+/**
+ * Gets the mutex from the condition variable. This mutex was passed
+ * to <code>javacall_os_cond_create</code>.
+ * @param cond the condition variable.
+ * @return the mutex, <code>NULL</code> in case of any error.
+ */
+javacall_mutex javacall_os_cond_get_mutex(javacall_cond cond);
+
+/**
+ * Destroys the condition variable.
+ * @param cond the condition variable to destroy.
+ */
+void javacall_os_cond_destroy(javacall_cond cond);
+
+/**
+ * Blocks current thread on the condition variable.
+ * The mutex that has been provided at creation time
+ * (@see javacall_os_cond_create)
+ * will be used in this call. See details in POSIX's
+ * <code>pthread_cond_wait</code>. If the <code>millis</code> parameter
+ * is not <code>0</code> this method will return
+ * <code>JAVACALL_TIMEOUT</code> when <code>millis</code> milliseconds
+ * elapse.
+ * @param cond the condition variable.
+ * @param millis the timeout in milliseconds
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_OUT_OF_MEMORY in case of lack of memory
+ * @retval JAVACALL_TIMEOUT when <code>millis</code> milliseconds elapsed
+ * @retval JAVACALL_FAIL in case of any other error
+ */
+javacall_result javacall_os_cond_wait(javacall_cond cond, long millis);
+
+/**
+ * Unblocks a thread that was blocked on the condition variable by
+ * <code>javacall_os_cond_wait</code>.
+ * See details in POSIX's <code>pthread_cond_signal</code>. Implementation
+ * can unblock more than one thread.
+ * @param cond the condition variable.
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_OUT_OF_MEMORY in case of lack of memory
+ * @retval JAVACALL_FAIL in case of any other error
+ */
+javacall_result javacall_os_cond_signal(javacall_cond cond);
+
+/**
+ * Unblocks all threads that were blocked on the condition variable by
+ * <code>javacall_os_cond_wait</code>.
+ * See details in POSIX's <code>pthread_cond_broadcast</code>.
+ * @param cond the condition variable.
+ * @retval JAVACALL_OK in case of success
+ * @retval JAVACALL_OUT_OF_MEMORY in case of lack of memory
+ * @retval JAVACALL_FAIL in case of any other error
+ */
+javacall_result javacall_os_cond_broadcast(javacall_cond cond);
+
+/**
+ * Loads the dynamic library named by the null-terminated string
+ * <code>name</code> and returns an "opaque" handle for the dynamic library.
+ *
+ * @param name the library name
+ * @return the library handle or <code>NULL</code> in case of failure.
+ */
+javacall_handle javacall_os_load_library(const char* name);
+
+/**
+ * Gets directory path for dynamic native libraries
+ * @param libPath OUT: pointer to unicode buffer, allocated by the VM,
+          to be filled with the directory path of dynamic native libraries
+ * @param libDirLen IN: lenght of max libPath buffer, OUT: lenght of set libPath
+ * @return <tt>JAVACALL_OK</tt> if operation completed successfully
+ *         <tt>JAVACALL_FAIL</tt> if an error occurred
+ */
+javacall_result javacall_os_get_library_path(
+    javacall_utf16* /*OUT*/ libPath, int* /*IN|OUT*/ libPathLen);
+
+/**
+ * Gets directory path for fonts installed from jar
+ * @param fontPath OUT: pointer to unicode buffer, allocated by the VM,
+          to be filled with the directory path of dynamic native libraries
+ * @param fontDirLen IN: lenght of max fontPath buffer, OUT: lenght of set fontPath
+ * @return <tt>JAVACALL_OK</tt> if operation completed successfully
+ *         <tt>JAVACALL_FAIL</tt> if an error occurred
+ */
+javacall_result javacall_os_get_font_storage_path(
+        javacall_utf16* /*OUT*/ fontPath, int* /*IN|OUT*/ fontPathLen);
+
+/**
+ * Takes a handle of a dynamic library and the null-terminated symbol
+ * <code>name</code> and returns the address where that symbol is loaded
+ * into memory.
+ *
+ * @param handle the library handle
+ * @param name the symbol name
+ * @return the address of the symbol or <code>NULL</code> in case of failure.
+ */
+void* javacall_os_get_symbol(javacall_handle handle, const char* name);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javacall_properties.c	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1990, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "javacall_properties.h"
+
+/**
+ * Gets the value of the specified property in the specified
+ * property set.
+ *
+ * @param key The key to search for
+ * @param type The property type
+ * @param result Where to put the result
+ *
+ * @return If found: <tt>JAVACALL_OK</tt>, otherwise
+ *         <tt>JAVACALL_FAIL</tt>
+ */
+javacall_result javacall_get_property(const char* key,
+                                      javacall_property_type type,
+                                      char** result) {
+    return JAVACALL_FAIL; //  stubbed, an implementation must be added
+}
+
+/**
+ * Gets the value of the specified property in the specified
+ * property set and parse it into integer.  If the property has not been found,
+ * assign NULL to result.
+ *
+ * @param key The key to search for
+ * @param type The property type
+ * @param int_value integer value parsed from property_value
+ *
+ * @return If found and parsed into int: <tt>JAVACALL_OK</tt>, otherwise
+ *         <tt>JAVACALL_FAIL</tt>
+ */
+javacall_result javacall_get_property_int(const char* key,
+                                          javacall_property_type type,
+                                          int *int_value) {
+    return JAVACALL_FAIL; //  stubbed, an implementation must be added
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javacall_properties.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,112 @@
+/*
+ *
+ * Copyright (c) 1990, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @file
+ *
+ * Interface for property set and get handling.
+ *
+ */
+
+#ifndef _JAVACALL_PROPERTIES_H_
+#define _JAVACALL_PROPERTIES_H_
+
+#include "javacall_defs.h"
+
+/**
+ * @enum javacall_property_type
+ * @brief types used in javacall_get_property javacall_set_property functions
+ */
+typedef enum {
+    /** Application related property */
+    JAVACALL_APPLICATION_PROPERTY,
+    /** Internal property */
+    JAVACALL_INTERNAL_PROPERTY,
+    /** Not used */
+    JAVACALL_NUM_OF_PROPERTIES
+} javacall_property_type;
+
+
+/**
+ * Gets the value of the specified property in the specified
+ * property set.
+ *
+ * @param key The key to search for
+ * @param type The property type
+ * @param result Where to put the result
+ *
+ * @return If found: <tt>JAVACALL_OK</tt>, otherwise
+ *         <tt>JAVACALL_FAIL</tt>
+ */
+javacall_result javacall_get_property(const char* key,
+                                      javacall_property_type type,
+                                      char** result);
+
+/**
+ * Gets the value of the specified property in the specified
+ * property set and parse it into integer.  If the property has not been found,
+ * assign NULL to result.
+ *
+ * @param key The key to search for
+ * @param type The property type
+ * @param int_value integer value parsed from property_value
+ *
+ * @return If found and parsed into int: <tt>JAVACALL_OK</tt>, otherwise
+ *         <tt>JAVACALL_FAIL</tt>
+ */
+javacall_result javacall_get_property_int(const char* key,
+                                          javacall_property_type type,
+                                          int *int_value);
+
+/**
+ * Sets a property value matching the key in the specified
+ * property set.
+ *
+ * @param key The key to set
+ * @param value The value to set <tt>key</tt> to
+ * @param replace_if_exist The value to decide if it's needed to replace
+ * the existing value corresponding to the key if already defined
+ * @param type The property type
+ *
+ * @return Upon success <tt>JAVACALL_OK</tt>, otherwise
+ *         <tt>JAVACALL_FAIL</tt>
+ */
+javacall_result javacall_set_property(const char* key, const char* value,
+                                      int replace_if_exist, javacall_property_type type);
+
+/**
+ * Initializes the configuration subsystem.
+ *
+ * @return <tt>JAVACALL_OK</tt> for success, <tt>JAVACALL_FAIL</tt> otherwise
+ */
+javacall_result javacall_initialize_configurations(void);
+
+/**
+ * Finalize the configuration subsystem.
+ */
+void javacall_finalize_configurations(void);
+
+#endif  /* _JAVACALL_PROPERTIES_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javautil_circular_buffer.c	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+#include "javautil_circular_buffer.h"
+#include "javacall_platform_defs.h"
+#include "javacall_memory.h"
+
+#define CIRCULAR_BUFFER_NEXT_SHIFT(n, shift, num)   ((n + shift) % num)
+#define CIRCULAR_BUFFER_NEXT(n, num)          (CIRCULAR_BUFFER_NEXT_SHIFT(n, 1, num))
+#define IS_CIRCULAR_BUFFER_FULL(wIndex, rIndex, num) (CIRCULAR_BUFFER_NEXT(wIndex, num) == rIndex)
+#define IS_CIRCULAR_BUFFER_FULL_SHIFT(wIndex, rIndex, shift, num) (CIRCULAR_BUFFER_NEXT_SHIFT(wIndex, shift, num) == rIndex)
+#define IS_CIRCULAR_BUFFER_EMPTY(wIndex, rIndex)     (wIndex == rIndex)
+
+typedef struct {
+    volatile javacall_uint16   wIndex;  // index of an element to write
+    volatile javacall_uint16   rIndex;  // index of an element to read
+    javacall_uint16            num;     // number of elements in a buffer
+    javacall_uint16            size;    // size of an element in bytes
+    javacall_handle            buff;    // pointer to a memory block
+} javautil_circular_buffer;
+
+
+javacall_result javautil_circular_buffer_create(javacall_handle *bufferHandle, javacall_uint16 num,
+                                                javacall_uint16 size) {
+    javautil_circular_buffer *buffer;
+
+    if (0 == bufferHandle || 0 == num || 0 == size) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+
+    buffer = (javautil_circular_buffer*)javacall_malloc(sizeof(javautil_circular_buffer));
+    if (0 == buffer) {
+        return JAVACALL_OUT_OF_MEMORY;
+    }
+
+    //ALGORITHM_NOTE: in case of put operation there always should be at least one free cell between
+    //wIndex and rIndex.
+    num++;
+    buffer->buff  = javacall_malloc(num * size);
+    if (0 == buffer->buff) {
+        javacall_free(buffer);
+        return JAVACALL_OUT_OF_MEMORY;
+    }
+
+    buffer->wIndex = 0;
+    buffer->rIndex = 0;
+    buffer->num = num;
+    buffer->size = size;
+
+    *bufferHandle = (javacall_handle)buffer;
+
+    return JAVACALL_OK;
+}
+
+void javautil_circular_buffer_destroy(javacall_handle bufferHandle) {
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+
+    if (0 == buffer) {
+        return;
+    }
+
+    if (0 != buffer->buff) {
+        javacall_free(buffer->buff);
+    }
+
+    javacall_free(buffer);
+}
+
+javacall_result javautil_circular_buffer_put(javacall_handle bufferHandle, javacall_handle elem) {
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+
+    if (0 == buffer) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+
+    if (IS_CIRCULAR_BUFFER_FULL(buffer->wIndex, buffer->rIndex, buffer->num)) {
+        return JAVACALL_FAIL;
+    }
+
+    javautil_memcpy((javacall_uint8*)buffer->buff + buffer->wIndex * buffer->size, elem, buffer->size);
+    buffer->wIndex = CIRCULAR_BUFFER_NEXT(buffer->wIndex, buffer->num);
+    return JAVACALL_OK;
+}
+
+javacall_result javautil_cicular_buffer_put_array(javacall_handle bufferHandle, javacall_handle elements,
+                                            javacall_int32 count) {
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+    javacall_uint16 lwIndex = buffer->wIndex;
+    javacall_uint16 lrIndex = buffer->rIndex;
+    javacall_int32 numToWriteTail = 0;
+    javacall_int32 numToWriteHead = 0;
+    javacall_int32 remainder;
+
+    if (0 == buffer || count <= 0 || count > buffer->num) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+
+    if (lwIndex >= lrIndex) {
+        numToWriteTail = buffer->num - lwIndex;
+
+        if (numToWriteTail < count) {
+            //ALGORITHM_NOTE: at least one free cell should be between wIndex and rIndex for next put operations
+            //Look at IS_CIRCULAR_BUFFER_FULL impl
+            numToWriteHead = lrIndex - 1;
+            remainder = count - numToWriteTail;
+            if (numToWriteHead < remainder) {
+                //not enough free space in the buffer
+                return JAVACALL_FAIL;
+
+            } else {
+                //all the data is put in both the tail and head of the buffer
+                numToWriteHead = remainder;
+            }
+
+        } else {
+            //all the data is put in the tail of the buffer
+            numToWriteTail = count;
+            if (IS_CIRCULAR_BUFFER_FULL_SHIFT(lwIndex, lrIndex, numToWriteTail, buffer->num)) {
+                //ALGORITHM_NOTE:after all the data is written, the writing pointer will be placed at the same
+                //position where reading pointer is located. It means that the buffer is overflowed.
+                return JAVACALL_FAIL;
+            }
+        }
+
+    } else {
+        //ALGORITHM_NOTE: at least one free cell should be between wIndex and rIndex for next put operations
+        //Look at IS_CIRCULAR_BUFFER_FULL impl
+        numToWriteHead = (lrIndex - lwIndex) - 1;
+        if (numToWriteHead < count) {
+            //not enough free space in the buffer
+            return JAVACALL_FAIL;
+
+        } else {
+            //all the data is put in the head
+            numToWriteHead = count;
+        }
+    }
+
+    if (numToWriteTail > 0) {
+        javautil_memcpy((javacall_uint8*)buffer->buff + lwIndex * buffer->size, elements,
+                buffer->size * numToWriteTail);
+        lwIndex = CIRCULAR_BUFFER_NEXT_SHIFT(lwIndex, numToWriteTail, buffer->num);
+        elements = (javacall_uint8*)elements + buffer->size * numToWriteTail;
+    }
+
+    if (numToWriteHead > 0) {
+        javautil_memcpy((javacall_uint8*)buffer->buff + lwIndex * buffer->size, elements,
+                buffer->size * numToWriteHead);
+        lwIndex = CIRCULAR_BUFFER_NEXT_SHIFT(lwIndex, numToWriteHead, buffer->num);
+    }
+
+    buffer->wIndex = lwIndex;
+
+    return JAVACALL_OK;
+}
+
+javacall_result javautil_circular_buffer_get(javacall_handle bufferHandle, javacall_handle elem) {
+
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+    if (0 == buffer) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+
+    if (IS_CIRCULAR_BUFFER_EMPTY(buffer->wIndex, buffer->rIndex))   {
+        return JAVACALL_FAIL;
+    }
+
+    javautil_memcpy(elem, (javacall_uint8*)buffer->buff + buffer->rIndex * buffer->size, buffer->size);
+    buffer->rIndex = CIRCULAR_BUFFER_NEXT(buffer->rIndex, buffer->num);
+    return JAVACALL_OK;
+}
+
+javacall_result javautil_circular_buffer_get_array(javacall_handle bufferHandle, javacall_handle elements,
+                                             javacall_int32 /*IN/OUT*/*len) {
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+    javacall_uint16 lwIndex = buffer->wIndex;
+    javacall_uint16 lrIndex = buffer->rIndex;
+    javacall_int32 numToReadTail = 0;
+    javacall_int32 numToReadHead = 0;
+    javacall_int32 remainder;
+    javacall_int32 lengthToRead = *len;
+
+    if (0 == buffer || lengthToRead <= 0) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+
+    if (IS_CIRCULAR_BUFFER_EMPTY(lwIndex, lrIndex))   {
+        return JAVACALL_FAIL;
+    }
+
+    if (lrIndex > lwIndex) {
+        numToReadTail = buffer->num - lrIndex;
+
+        if (numToReadTail < lengthToRead) {
+            remainder = lengthToRead - numToReadTail;
+            //lwIndex helps to identify how many data can be read from buffer's head
+            numToReadHead = lwIndex > remainder ? remainder : lwIndex;
+        } else {
+            numToReadTail = lengthToRead;
+        }
+
+    } else {
+        //lrIndex is less than lwIndex (equality is checked by IS_CIRCULAR_BUFFER_EMPTY above)
+        numToReadHead = lwIndex - lrIndex;
+        if (numToReadHead > lengthToRead) {
+            numToReadHead = lengthToRead;
+        }
+    }
+
+    if (numToReadTail > 0) {
+        javautil_memcpy(elements, (javacall_uint8*)buffer->buff + lrIndex * buffer->size, buffer->size * numToReadTail);
+        lrIndex = CIRCULAR_BUFFER_NEXT_SHIFT(lrIndex, numToReadTail, buffer->num);
+        elements = (javacall_uint8*)elements + buffer->size * numToReadTail;
+    }
+
+    if (numToReadHead > 0) {
+        javautil_memcpy(elements, (javacall_uint8*)buffer->buff + lrIndex * buffer->size, buffer->size * numToReadHead);
+        lrIndex = CIRCULAR_BUFFER_NEXT_SHIFT(lrIndex, numToReadHead, buffer->num);
+    }
+
+    buffer->rIndex = lrIndex;
+    *len = numToReadHead + numToReadTail;
+
+    return JAVACALL_OK;
+}
+
+javacall_result javautil_circular_buffer_get_count(javacall_handle bufferHandle, javacall_int32 /*OUT*/*count) {
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+
+    if (0 == buffer) {
+        return JAVACALL_FAIL;
+    }
+
+    *count = (buffer->rIndex > buffer->wIndex)
+            ? ((buffer->num - buffer->rIndex) + buffer->wIndex)
+            : (buffer->wIndex - buffer->rIndex);
+
+    return JAVACALL_OK;
+}
+
+javacall_result javautil_circular_buffer_free_size(javacall_handle bufferHandle, javacall_int32 /*OUT*/*size) {
+    javautil_circular_buffer *buffer = (javautil_circular_buffer*)bufferHandle;
+    javacall_uint16 lwIndex = buffer->wIndex;
+    javacall_uint16 lrIndex = buffer->rIndex;
+
+    if (0 == buffer) {
+        return JAVACALL_FAIL;
+    }
+
+    if (lwIndex == lrIndex) {
+        *size = buffer->num - 1;
+    } else {
+        *size = (lwIndex > lrIndex ? ((buffer->num - lwIndex) + lrIndex) : (lrIndex - lwIndex)) - 1;
+    }
+
+    return JAVACALL_OK;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javautil_circular_buffer.h	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/**
+ * @file
+ *
+ * Interface for the circular buffer handling.
+ *
+ * Concurrency note.
+ *
+ * Implementation of the circular buffer is a locked free and can be safely used in a multy threaded environment
+ * if the conditions below are fulfilled:
+ * -only two threads work with a circular buffer. One thread must perform write operations and the other one - read operations;
+ * -load/store assembler instruction for a 16 bit volatile variable is atomic
+ * -system has only one CPU unit (to avoid cache coherency issues when data can be cached in CPU's internal cache)
+ *
+ * In other cases you must apply different techniques to make the implementation thread-safe.
+ *
+ */
+
+#ifndef _JAVAUTIL_CIRCULARBUFFER_
+#define _JAVAUTIL_CIRCULARBUFFER_
+
+#include "javacall_defs.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Allocate a buffer of a given size.
+ *
+ * @param bufferHandle   handle to store circular buffer's handle to
+ * @param num            number of elements in the buffer; must be greater than 0
+ * @param size           size of an element in bytes; must be greater than 0
+ *
+ * @return <code>JAVACALL_OK</code>                on success
+ *         <code>JAVACALL_OUT_OF_MEMORY</code>     if unable to allocate the buffer
+ *         <code>JAVACALL_INVALID_ARGUMENT</code>  if the buffer handle, the number of elements or
+ *                                                 an element size are not valid
+ */
+javacall_result javautil_circular_buffer_create(javacall_handle *bufferHandle, javacall_uint16 num, javacall_uint16 size);
+
+/**
+ * Free a buffer.
+ *
+ * @param bufferHandle a handle to a circular buffer
+ */
+void javautil_circular_buffer_destroy(javacall_handle bufferHandle);
+
+/**
+ * Put an element to a buffer.
+ *
+ * @param bufferHandle    handle to the circular buffer
+ * @param elem element    being written to the buffer
+ *
+ * @return <code>JAVACALL_OK</code>                 on success
+ *         <code>JAVACALL_FAIL</code>               if unable to put an element to the buffer 'cause it's full
+ *         <code>JAVACALL_INVALID_ARGUMENT</code>   if the buffer handle is not valid
+ */
+javacall_result javautil_circular_buffer_put(javacall_handle bufferHandle, javacall_handle elem);
+
+/**
+ * Put several elements to a buffer.
+ *
+ * @param bufferHandle  handle to the circular buffer
+ * @param elements      handle to the elements being written to the buffer
+ * @param count         quantity of <code>elements</codes> to write
+ *
+ * @return <code>JAVACALL_OK</code>                 on success
+ *         <code>JAVACALL_FAIL</code>               if unable to put all elements to the buffer cause it's full
+ *         <code>JAVACALL_INVALID_ARGUMENT</code>   if the buffer handle is not valid or <code>count</code> is bigger
+ *                                                  than buffer's size
+ *
+ */
+javacall_result javautil_cicular_buffer_put_array(javacall_handle bufferHandle, javacall_handle elements,
+                                            javacall_int32 count);
+
+/**
+ * Get an element from a buffer.
+ *
+ * @param bufferHandle   handle to the circular buffer
+ * @param elem           element to read from the buffer
+ *
+ * @return <code>JAVACALL_OK</code>                 on success
+ *         <code>JAVACALL_FAIL</code>               if unable to get an element from the buffer 'cause it's empty
+ *         <code>JAVACALL_INVALID_ARGUMENT</code>   if the buffer handle is not valid
+ */
+javacall_result javautil_circular_buffer_get(javacall_handle bufferHandle, javacall_handle elem);
+
+/**
+ * Get several elements from a buffer.
+ *
+ * @param bufferHandle   handle to the circular buffer
+ * @param elements       handle to the elements that have to be read from the circular buffer
+ * @param len            IN - size of the <code>elements</code> buffer
+ *                       OUT - total number of elements read to the <code>elements<code> buffer
+ *
+ * @return <code>JAVACALL_OK</code>                 on success
+ *         <code>JAVACALL_FAIL</code>               buffer is empty
+ *         <code>JAVACALL_INVALID_ARGUMENT</code>   if the buffer handle is not valid or len is less or equal to 0
+ */
+javacall_result javautil_circular_buffer_get_array(javacall_handle bufferHandle, javacall_handle elements,
+                                             javacall_int32 /*IN/OUT*/*len);
+
+/**
+ * Get number of elements in a buffer available for read.
+ *
+ * @param bufferHandle handle to the circular buffer
+ * @param count number of elements in the buffer available for reading
+ *
+ * @return <code>JAVACALL_OK</code>                 on success
+ *         <code>JAVACALL_FAIL</code>               on erros
+ */
+javacall_result javautil_circular_buffer_get_count(javacall_handle bufferHandle, javacall_int32 /*OUT*/*count);
+
+/**
+ * Returns the number of elements that can be written into the buffer.
+ *
+ * @param bufferHandle handle to the circular buffer
+ * @param size number of elements that can be written into the buffer
+ *
+ * @return <code>JAVACALL_OK</code>                 on success
+ *         <code>JAVACALL_FAIL</code>               on erros
+ */
+javacall_result javautil_circular_buffer_free_size(javacall_handle bufferHandle, javacall_int32 /*OUT*/*size);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/se/native/com/oracle/dio/javautil_linked_list.c	Wed May 28 14:27:14 2014 -0400
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+#include "javautil_linked_list.h"
+#include "javacall_memory.h"
+
+
+typedef struct _javacall_node {
+    void *data;
+    struct _javacall_node *next;
+} javacall_node;
+
+typedef struct {
+    javacall_node *head;
+    javacall_node *tail;
+    javacall_node *next;
+    javacall_int32 count;
+} javacall_list;
+
+/**
+ * Creates a new linked list.
+ *
+ * @param listHandle pointer to receive handle to the newly allocated list
+ * @return JAVACALL_OK on success,
+ *         JAVACALL_INVALID_ARGUMENT if listHandle is NULL,
+ *         JAVACALL_OUT_OF_MEMORY if unable to allocate the list
+ */
+javacall_result javautil_list_create(javacall_handle *listHandle) {
+    javacall_list *list;
+
+    if (!listHandle) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+    list = (javacall_list *)javacall_malloc(sizeof(javacall_list));
+    if (!list) {
+        return JAVACALL_OUT_OF_MEMORY;
+    }
+    list->head = NULL;
+    list->tail = NULL;
+    list->next = NULL;
+    list->count = 0;
+    *listHandle = (javacall_handle)list;
+    return JAVACALL_OK;
+}
+
+/**
+ * Destroys the list, freeing all nodes but not freeing the contained data.
+ *
+ * @param listHandle handle to the list
+ */
+void javautil_list_destroy(javacall_handle listHandle) {
+    javacall_list *list = (javacall_list *)listHandle;
+    if (!list) {
+        return;
+    }
+
+    while (list->head) {
+        list->next = list->head;
+        list->head = list->head->next;
+        javacall_free(list->next);
+    }
+    javacall_free(list);
+}
+
+/**
+ * Adds new element to the list.
+ *
+ * @param listHandle handle to the list
+ * @param data pointer to contents of the new element
+ * @return JAVACALL_OK on success,
+ *         JAVACALL_INVALID_ARGUMENT if list handle is not valid,
+ *         JAVACALL_OUT_OF_MEMORY if unable to allocate new element
+ */
+javacall_result javautil_list_add(javacall_handle listHandle, void *data) {
+    javacall_list *list = (javacall_list *)listHandle;
+    javacall_node *newNode;
+
+    if (!list) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+    newNode = (javacall_node *)javacall_malloc(sizeof(javacall_node));
+    if (!newNode) {
+        return JAVACALL_OUT_OF_MEMORY;
+    }
+
+    newNode->next = NULL;
+    newNode->data = data;
+    if (!list->head) {
+        list->head = newNode;
+        list->tail = newNode;
+        list->next = newNode;
+    } else {
+        list->tail->next = newNode;
+        list->tail = newNode;
+    }
+    list->count++;
+    return JAVACALL_OK;
+}
+
+
+/**
+ * Removes the first occurrence of the element with specified content
+ * from the list, if it is present. Resets list iterator.
+ *
+ * @param listHandle handle to the list
+ * @param data pointer to contents of the element to remove
+ * @return JAVACALL_OK on success,
+ *         JAVACALL_INVALID_ARGUMENT if list handle is not valid,
+ *         JAVACALL_FAIL if element with specified content is not present
+           in the list
+ */
+javacall_result javautil_list_remove(javacall_handle listHandle, void *data) {
+    javacall_list *list = (javacall_list *)listHandle;
+    javacall_node *prevNode = NULL;
+    javacall_result res = JAVACALL_FAIL;
+
+    if (!list || !data) {
+        return JAVACALL_INVALID_ARGUMENT;
+    }
+
+    list->next = list->head;    /* resets iterator */
+
+    while(list->next != NULL) {
+        if (list->next->data == data) {
+            if (prevNode == NULL) {
+                list->head = list->head->next;
+            } else {
+                prevNode->next = list->next->next;
+            }
+            if (list->next->next == NULL) {
+                list->tail = prevNode;
+            }
+
+            javacall_free(list->next);
+            list->count--;
+            res = JAVACALL_OK;
+            break;
+        } else {
+            prevNode = list->next;
+            list->next = list->next->next;
+        }
+    }
+
+    list->next = list->head;    /* resets iterator */
+    return res;
+}
+
+/**
+ * Iterates to the beginning of the list. Subsequent call to
+ * <code>javautil_list_get_next</code> will return the first element.
+ *
+ * @param listHandle handle to the list
+ */
+void javautil_list_reset_iterator(javacall_handle listHandle) {
+    javacall_list *list = (javacall_list *)listHandle;
+
+    if (list) {
+        list->next = list->head;
+    }
+}
+
+/**
+ * Iterates to the next element of the list.
+ *
+ * @param listHandle handle to the list
+ * @param data pointer to receive pointer to the next element contents
+ * @return JAVACALL_OK on success,
+ *         JAVACALL_INVALID_ARGUMENT if list handle is not valid or data
+ *         pointer is NULL,
+ *         JAVACALL_FAIL if no more elements found in the list
+ */
+javacall_result javautil_list_get_next(javacall_handle listHandle, void **data) {
+    javacall_list *list = (javacall_list *)listHandle;
+
+    if (!list || !data) {