Jamaicavm 8.2 User Manual
Total Page:16
File Type:pdf, Size:1020Kb
JamaicaVM 8.2 — User Manual Java Technology for Critical Embedded Systems aicas GmbH 2 JamaicaVM 8.2 — User Manual: Java Technology for Critical Embedded Systems JamaicaVM 8.2, Release 1. Published January 15, 2019. c 2001–2019 aicas GmbH, Karlsruhe. All rights reserved. 3 No licenses, expressed or implied, are granted with respect to any of the technology described in this publication. aicas GmbH retains all intellectual property rights associated with the technology described in this publication. This publication is intended to assist application developers to develop applications only for the Jamaica Virtual Machine. Every effort has been made to ensure that the information in this publication is accurate. aicas GmbH is not responsible for printing or clerical errors. Although the information herein is provided with good faith, the supplier gives neither warranty nor guarantee that the information is correct or that the results described are obtainable under end-user conditions. aicas GmbH phone +49 721 663 968-0 Emmy-Noether-Straße 9 fax +49 721 663 968-99 76131 Karlsruhe email [email protected] Germany web http://www.aicas.com aicas America Limited phone +1 203 359 5705 4023 Kennett Pike, Suite 810 Wilmington, DE 19807 email [email protected] USA web http://www.aicas.com aicas GmbH phone +33 1 49 97 17 62 9 Allee´ de l’Arche fax +33 1 49 97 17 00 92671 Paris La Defense´ email [email protected] France web http://www.aicas.com This product includes software developed by IAIK of Graz University of Technology. This software is based in part on the work of the Independent JPEG Group. This product includes software that is derivative of the work by Markus Kuhn licensed under CC BY 4.0. This product includes the Elliptic Curve Cryptography library, copyright Oracle America, Inc. It is licensed under LGPL v2.1 and GPL v2 with the classpath exception. This product is based in part on the work of the FreeType Project. Java and all Java-based trademarks are registered trademarks of Oracle America, Inc. All other brands or product names are trademarks or registered trademarks of their respective holders. ALL IMPLIED WARRANTIES ON THIS PUBLICATION, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF THE ORIGINAL RETAIL PURCHASE OF THIS PRODUCT. Although aicas GmbH has reviewed this publication, aicas GmbH MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESSED OR IMPLIED, WITH RESPECT TO THIS PUBLICATION, ITS QUALITY, ACCURACY, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS PUBLICATION IS PROVIDED AS IS, AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL aicas GmbH BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS PUBLICATION, even if advised of the possibility of such damages. THE WARRANTIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESSED OR IMPLIED. 4 Contents Preface 15 Intended Audience of This Book . 15 Contacting aicas . 16 What is New in JamaicaVM 8.2 . 16 What is New in JamaicaVM 8.1 . 17 What is New in JamaicaVM 8.0 . 17 I Introduction 19 1 Key Features of JamaicaVM 21 1.1 Hard Realtime Execution Guarantees . 21 1.2 Real-Time Specification for Java support . 22 1.3 Minimal footprint . 22 1.4 ROMable code . 23 1.5 Native code support . 23 1.6 Dynamic Linking . 23 1.7 Supported Platforms . 23 1.7.1 Development platforms . 23 1.7.2 Target platforms . 24 1.8 Fast Execution . 25 1.9 Tools for Realtime and Embedded System Development . 25 2 Getting Started 27 2.1 Installation of JamaicaVM . 27 2.1.1 Linux . 28 2.1.2 Windows . 30 2.2 Installation of License Keys . 30 2.2.1 Using the Standard Edition . 31 2.2.2 Using the Personal Edition . 31 2.3 JamaicaVM Directory Structure . 32 5 6 CONTENTS 2.3.1 API Specification . 32 2.3.2 Target Platforms . 32 2.4 Building and Running a Java Program . 34 2.4.1 Host Platform . 34 2.4.2 Target Platform . 36 2.4.3 Improving Size and Performance . 36 2.4.4 Overview of Further Examples . 37 2.5 Notations and Conventions . 37 2.5.1 Typographic Conventions . 38 2.5.2 Argument Syntax . 38 2.5.3 Jamaica Home and User Home . 39 3 Tools Overview 41 3.1 Jamaica Java Compiler . 41 3.2 Jamaica Virtual Machine . 41 3.3 Creating Target Executables . 42 3.4 Accelerating JAR Files . 43 3.5 Monitoring Realtime Behavior . 43 4 Support for the Eclipse IDE 45 4.1 Plug-in installation . 45 4.1.1 Installation on Eclipse . 45 4.1.2 Installation on Other IDEs . 46 4.2 Setting up JamaicaVM Distributions . 47 4.3 Using JamaicaVM in Java Projects . 47 4.4 Setting Virtual Machine Parameters . 47 4.5 Building applications with Jamaica Builder . 48 4.5.1 Getting started . 48 4.5.2 Jamaica Buildfiles . 48 II Tools Usage and Guidelines 51 5 Performance Optimization 53 5.1 Creating a profile . 53 5.1.1 Using the profiling VM . 54 5.1.2 Creating a profiling application . 54 5.1.3 Dumping a profile via network . 55 5.1.4 Creating a micro profile . 56 5.2 Using a profile with the Builder . 56 5.2.1 Building with a profile . 56 CONTENTS 7 5.2.2 Building with multiple profiles . 57 5.3 Interpreting the profiling output . 57 5.3.1 Format of the profile file . 58 5.3.2 Example . 62 6 Reducing Footprint and Memory Usage 65 6.1 Compilation . 65 6.1.1 Suppressing Compilation . 65 6.1.2 Using Default Compilation . 67 6.1.3 Using a Custom Profile . 68 6.1.4 Code Optimization by the C Compiler . 70 6.1.5 Full Compilation . 71 6.2 Smart Linking . 72 6.3 API Library Classes and Resources . 74 6.4 RAM Usage . 75 6.4.1 Measuring RAM Demand . 75 6.4.2 Memory Required for Threads . 77 6.4.3 Memory Required for Line Numbers . 81 7 Memory Management Configuration 85 7.1 Configuration for soft-realtime applications . 85 7.1.1 Initial heap size . 85 7.1.2 Maximum heap size . 86 7.1.3 Finalizer thread priority . 86 7.1.4 Reference Handler thread priority . 87 7.1.5 Reserved memory . 87 7.1.6 Stop-the-world Garbage Collection . 89 7.1.7 Recommendations . 89 7.2 Configuration for hard-realtime applications . 90 7.2.1 Usage of the Memory Analyzer tool . 90 7.2.2 Measuring an application’s memory requirements . 90 7.2.3 Fine tuning the final executable application . 92 7.2.4 Constant Garbage Collection Work . 94 7.2.5 Comparing dynamic mode and constant GC work mode . 95 7.2.6 Determination of the worst case execution time of an al- location . 96 7.2.7 Examples . 96 8 Debugging Support 99 8.1 Enabling the Debugger Agent . 99 8.2 Connecting to Jamaica from the Command Line . 100 8 CONTENTS 8.2.1 Using sockets as transport layer . 100 8.2.2 Using shared memory as transport layer . 101 8.3 Configuring the IDE to connect to Jamaica . 101 8.4 Reference Information . 103 9 The Real-Time Specification for Java 105 9.1 Realtime programming with the RTSJ . 105 9.1.1 Thread Scheduling . 106 9.1.2 Memory Management . 106 9.1.3 Synchronization . 106 9.1.4 Example . 107 9.2 Realtime Garbage Collection . 108 9.3 Relaxations in JamaicaVM . 108 9.3.1 Use of Memory Areas . 109 9.3.2 Thread Priorities . 109 9.3.3 Runtime checks for NoHeapRealtimeThread . 109 9.3.4 Static Initializers . 109 9.3.5 Class PhysicalMemoryManager . 110 9.4 Limitations of RTSJ Implementation . 110 9.5 Computational Transparency . 111 9.5.1 Efficient Java Statements . 112 9.5.2 Non-Obvious Slightly Inefficient Constructs . 114 9.5.3 Statements Causing Implicit Memory Allocation . 114 9.5.4 Operations Causing Class Initialization . 117 9.5.5 Operations Causing Class Loading . 118 9.6 Supported Standards . 119 9.6.1 Real-Time Specification for Java . 119 9.6.2 Java Native Interface . 121 9.7 Memory Management . 122 9.7.1 Memory Management of RTSJ . 123 9.7.2 Finalizers . 124 9.7.3 Configuring a Realtime Garbage Collector . 125 9.7.4 Programming with the RTSJ and Realtime Garbage Col- lection . 126 9.7.5 Memory Management Guidelines . 127 9.8 Scheduling and Synchronization . 128 9.8.1 Schedulable Entities . 128 9.8.2 Synchronization . 130 9.8.3 Scheduling Policy and Priorities . 133 9.9 Libraries . 136 9.10 Summary . ..