Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

OpenJDK Cookbook
OpenJDK Cookbook
OpenJDK Cookbook
Ebook770 pages3 hours

OpenJDK Cookbook

Rating: 0 out of 5 stars

()

Read preview

About this ebook

About This Book
  • Gain the skills required to harness the power of OpenJDK's Java implementation
  • Extend and adapt Java Platform to develop various types of applications
  • A practical guide to learn how to benefit from AdoptOpenJDK programme, a part of the OpenJDK community
Who This Book Is For

If you are an experienced Java developer using Java 7 platform and want to get your grips on OpenJDK for Java development, this is the book for you. JDK users who wish to migrate to OpenJDK will find this book very useful.

LanguageEnglish
Release dateJan 30, 2015
ISBN9781849698412
OpenJDK Cookbook

Related to OpenJDK Cookbook

Related ebooks

Programming For You

View More

Related articles

Reviews for OpenJDK Cookbook

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    OpenJDK Cookbook - Alex Kasko

    Table of Contents

    OpenJDK Cookbook

    Credits

    About the Authors

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Sections

    Getting ready

    How to do it…

    How it works…

    There's more…

    See also

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Errata

    Piracy

    Questions

    1. Getting Started with OpenJDK

    Introduction

    Distinguishing OpenJDK from Oracle JDK

    Getting ready

    How to do it...

    How it works…

    See also

    Installing OpenJDK on Windows

    Getting ready

    How to do it...

    How it works…

    There's more...

    See also

    Configuring OpenJDK on Windows

    Getting ready

    How to do it...

    How it works…

    There's more...

    Installing OpenJDK on Linux

    Getting ready

    How to do it...

    There's more...

    Configuring OpenJDK on Linux

    Getting ready

    How to do it...

    How it works…

    There's more...

    Navigating through OpenJDK groups and projects

    Getting ready

    How to do it...

    How it works…

    See also

    2. Building OpenJDK 6

    Introduction

    Preparing CA certificates

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 6 on Ubuntu Linux 12.04 LTS

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Setting up the minimum build environment for the most compatible Linux builds

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Installing Cygwin for Windows builds

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building 32-bit FreeType libraries for OpenJDK 6 on Windows

    Getting ready

    How to do it...

    How it works...

    See also

    Building 64-bit FreeType libraries for OpenJDK 6 on Windows

    Getting ready

    How to do it...

    How it works...

    See also

    Building 32-bit OpenJDK 6 on Windows 7 SP1

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building 64-bit OpenJDK 6 on Windows 7 x64 SP1

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    3. Building OpenJDK 7

    Introduction

    Building OpenJDK 7 on Ubuntu Linux 12.04 LTS

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 7 on Mac OS X

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building 32-bit FreeType libraries for OpenJDK 7 on Windows

    Getting ready

    How to do it...

    How it works...

    See also

    Building 64-bit FreeType libraries for OpenJDK 7 on Windows

    Getting ready

    How to do it...

    How it works...

    See also

    Building 32-bit OpenJDK 7 on Windows 7 SP1

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building 64-bit OpenJDK 7 on Windows 7 x64 SP1

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Preparing a standalone toolchain for 32- and 64-bit Windows' builds

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    4. Building OpenJDK 8

    Introduction

    Working with GNU Autoconf

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 8 Ubuntu Linux 12.04 LTS

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using ccache to speed up the OpenJDK 8 build process

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 8 on Mac OS X

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 8 on Windows 7 SP1

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    5. Building IcedTea

    Introduction

    Building IcedTea 6

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building IcedTea 7

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 7 with IcedTea patches

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building IcedTea 7 with the NSS security provider

    Getting ready

    How to do it...

    How it works...

    See also

    Building IcedTea 6 with the SystemTap support

    Getting ready

    How to do it...

    There's more...

    See also

    6. Building IcedTea with Other VM Implementations

    Introduction

    Configuring cross-compilation between ARM and x86

    Getting ready

    How to do it...

    Configuring OpenEmbedded build manually

    Using the Hob utility to configure the OpenEmbedded build

    After the build

    How it works…

    There's more...

    Configure problems – when a header file is not found

    Fetch problems – where your package is not accessible through any mirror available

    Compile problems – where a compile error occurs

    Parsing problems – where your recipes cannot be parsed

    Building IcedTea for ARM with integrated CACAO VM

    Getting ready

    How to do it...

    How it works…

    There's more...

    Porting JamVM to use OpenJDK

    Getting ready

    How to do it...

    There's more

    Configuring Zero-assembler with the Shark compiler to use OpenJDK

    Getting ready

    How to do it...

    How it works…

    There's more

    Building for MIPS and other architectures using OpenEmbedded recipes

    Getting ready

    How to do it...

    How it works…

    There's more...

    7. Working with WebStart and the Browser Plugin

    Introduction

    Building the IcedTea browser plugin on Linux

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Using the IcedTea Java WebStart implementation on Linux

    Getting ready

    How to do it...

    How it works...

    See also

    Preparing the IcedTea Java WebStart implementation for Mac OS X

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Preparing the IcedTea Java WebStart implementation for Windows

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    8. Hacking OpenJDK

    Introduction

    Setting up the development environment with NetBeans

    Getting ready

    How to do it...

    See also

    Working with Mercurial forest

    Getting ready

    How to do it...

    How it works…

    Understanding OpenJDK 6 and 7 incremental builds

    Getting ready

    How to do it...

    How it works…

    There's more…

    Debugging Java code using NetBeans

    Getting ready

    How to do it...

    How it works…

    There's more...

    Debugging C++ code using NetBeans

    Getting ready

    How to do it...

    How it works…

    Using NetBeans to compile HotSpot

    Getting ready

    How to do it...

    How it works…

    Using HotSpot dev parameters

    Getting ready

    How to do it...

    Adding new intrinsic to HotSpot

    Getting ready

    How to do it...

    How it works…

    There's more…

    Building VisualVM from the source code

    Getting ready

    How to do it...

    See also

    Creating a plugin for VisualVM

    Getting ready

    How to do it...

    See also

    Getting benefits from the AdoptOpenJDK project

    Getting ready

    How to do it...

    Visualizing JIT logs

    Securing your javadocs

    How it works…

    There's more...

    9. Testing OpenJDK

    Introduction

    Running tests using the downloaded or the built version of jtreg

    Getting ready

    How to do it...

    How it works…

    See also

    Building jtreg from the source

    Getting ready

    How to do it...

    Running the standard set of OpenJDK tests

    Getting ready

    How to do it...

    There's more...

    Writing your own test for jtreg

    Getting ready

    How to do it...

    How it works…

    See also

    Using jtreg in GUI mode

    Getting ready

    How to do it...

    How it works…

    Writing TestNG tests for jtreg

    Getting ready

    How to do it...

    How it works…

    See also

    Compiling JT Harness from the source code

    Getting ready

    How to do it...

    See also

    Building and running jcstress

    Getting ready

    How to do it…

    There's more...

    Writing tests for jcstress

    Getting ready

    How to do it…

    See also

    Creating a benchmark project using JMH

    Getting ready

    How to do it…

    There's more…

    See also

    Downloading the source and compiling JHM

    Getting ready

    How to do it…

    How it works…

    10. Contributing to OpenJDK

    Introduction

    Becoming a contributor

    Getting ready

    How to do it...

    See also

    Generating a patch with webrev

    Getting ready

    How to do it...

    How it works…

    There's more...

    See also

    Backporting OpenJDK v9 patches to OpenJDK v8

    Getting ready

    How to do it…

    See also

    Understanding OpenJDK groups

    Getting ready

    How to do it…

    See also

    Understanding OpenJDK projects

    How to do it…

    See also

    Suggesting new JSRs

    Getting ready

    How to do it...

    See also

    Suggesting new JEPs

    Getting ready

    How to do it...

    How it works…

    See also

    11. Troubleshooting

    Introduction

    Navigating through the process workflow

    Getting ready

    How to do it...

    How it works…

    Submitting a defect to the OpenJDK bug systems

    How to do it...

    How it works…

    Creating a patch using NetBeans

    Getting ready

    How to do it...

    How it works

    See also...

    Creating a code review

    Getting ready

    How to do it...

    12. Working with Future Technologies

    Introduction

    Building OpenJDK 9 on Mac OS X using Clang

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building OpenJDK 9 on Windows using MSYS

    Getting ready

    How to do it...

    How it works...

    See also

    Running and testing the early access preview of OpenJDK 9

    Getting ready

    How to do it...

    How it works...

    There's more...

    Using Jigsaw

    Getting ready

    How to do it...

    How it works...

    There's more...

    Building OpenJDK 9 with Graal

    Getting ready

    How to do it...

    How it works...

    There's more...

    Building OpenJDK 9 with Sumatra

    Getting ready

    How to do it...

    How it works...

    There's more...

    13. Build Automation

    Introduction

    Installing VirtualBox

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Preparing SSH keys

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Preparing VirtualBox machines with Linux

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Preparing VirtualBox machines with Mac OS X

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Preparing VirtualBox machines with Windows

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Automating builds

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Building cross-platform installers

    Getting ready

    How to do it...

    How it works...

    There's more...

    See also

    Index

    OpenJDK Cookbook


    OpenJDK Cookbook

    Copyright © 2015 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: January 2015

    Production reference: 1240115

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-84969-840-5

    www.packtpub.com

    Cover image by Benoit Benedetti (<benoit.benedetti@gmail.com>)

    Credits

    Authors

    Alex Kasko

    Stanislav Kobylyanskiy

    Alexey Mironchenko

    Reviewers

    Usman Saleem

    Otávio Santana

    Martin Toshev

    Commissioning Editor

    Aarthi Kumaraswamy

    Acquisition Editor

    Vinay Argekar

    Content Development Editor

    Athira Laji

    Technical Editor

    Mrunmayee Patil

    Copy Editors

    Shivangi Chaturvedi

    Pranjali Chury

    Jasmine Nadar

    Merilyn Pereira

    Project Coordinator

    Harshal Ved

    Proofreaders

    Samuel Redman Birch

    Ameesha Green

    Paul Hindle

    Kevin McGowan

    Indexer

    Hemangini Bari

    Graphics

    Disha Haria

    Production Coordinator

    Arvindkumar Gupta

    Cover Work

    Arvindkumar Gupta

    About the Authors

    Alex Kasko is a participant in the OpenJDK project. He maintains unofficial OpenJDK builds on his GitHub account and has 8 years' experience in enterprise and high-performance programming. He works in an OpenJDK development team at Red Hat Inc.

    Stanislav Kobylyanskiy is a software developer with years of Java experience. He started his career with C++ and system programming in the late 90s with the Aelita software (now DELL). After a few years, he switched to Java and then moved to telecom. At that time, he joined T-Mobile, UK, to rebuild their Customer Service Web Portal, which lasted for about 4 years. Currently, he is with an investment bank where he is working on a strategic algorithmic trading platform. He is continuously looking for new challenges and to extend his knowledge of core Java technologies.

    I want to say thank you to my family—my two lovely daughters, Alyssa and Alexandra, and to my beloved wife, Natalia—for all their help and support in everything I do.

    Alexey Mironchenko is a software developer with experience in scalable enterprise projects, involving Java EE, NoSQL databases, and various other frameworks. He has a mathematical background with some COQ and Maxima experience, and his hobby is to test cutting-edge technologies that are open source or in early access.

    About the Reviewers

    Usman Saleem is a seasoned software developer with special focus on Java, JEE, PostgreSQL, and utilizing open source tools in software development in general. He has worked with EnterpriseDB, OpenSCG, Red Hat, and Ventyx, Australia. He has taught object-oriented programming and enterprise software development in several public and private sector universities to undergraduate students. When he is not (re)writing his blog software, he likes trying out various strength training workouts or playing Angry Birds with his son.

    Usman has an MSc (CS) degree and holds RHCSA, SCWCD, SCBCD, SCJD, and SCJP certifications. He maintains his blog at http://www.usmans.info.

    Otávio Santana (@otaviojava) is a developer and enthusiast of open source. He is an evangelist and practitioner of agile philosophy and polyglot development in Brazil. Otávio is a JUG leader of JavaBahia and SouJava and a strong supporter of Java communities in Brazil, where he also leads the BrasilJUGs initiative to incorporate Brazilian JUGs into joint activities. He is a cocreator and is also responsible for the Linguagil Group—a merge of Java, Ruby, Python, and Agile groups that promote agility across language-focused communities. In the open source world, Otávio is a developer in OpenJDK and a creator of Apache Easy-Cassandra. He has also helped in JBoss Weld, Hibernate, Apache Commons, and other open source projects. Otávio is a very active speaker in Brazil, where he has participated in the largest Java events in the country. As an international speaker, Otávio has presented in JavaOne and the Cassandra tour events. Otávio is also a writer and has many articles and even a book on JVM Internals. Otávio Santana actually means make the future Java, working in several Java Specification Request (JSR), JAR, as part of the Java Expert team. Otávio was recently nominated and won JCP's Outstanding Adopt-a-JSR Participant of the Year award for his very active role in several JSRs and OpenJDK.

    Martin Toshev is a software engineer by profession and hobby. He has been working on a number of large enterprise projects for different companies for the past 5 years using mostly the Java technology stack. He has experience in the areas of social networking and J2EE middleware and is a contributor to the OpenJDK platform.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    For support files and downloads related to your book, please visit www.PacktPub.com.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

    https://www2.packtpub.com/books/subscription/packtlib

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print, and bookmark content

    On demand and accessible via a web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

    Preface

    OpenJDK is a unique project that opens numerous and exciting opportunities for people who want to dive into the huge and complicated infrastructure behind the JVM. There is an incredible amount of things to learn and to explore. Almost anyone can find something in it as per their interest, starting from HTTP, Web, software dependency problems, and ending with hardware-specific JIT optimization techniques, and concurrency challenges. Such variety is very unique and it would be true to say that there is no other open source project that can provide something similar. The other factor is that there are not so many other open source projects on that scale; possibly only the Linux core. Such scale requires a non-trivial organizational approach and, to be involved in that process, to see how it works, is a very interesting insight.

    This cookbook will lead you through steps to take you into the world of OpenJDK as smoothly as possible. It starts by explaining how to download the source code and how to build the different versions of OpenJDK, how to set it up on a machine, and what different options are available. Then, you will learn how to set up the development environment (IDE) required for editing and debugging C++ and Java source code, and how to start making changes. It will go through some examples, which you may decide to change in various parts of OpenJDK. Further, it will cover the tools available for testing, benchmarking, and ensuring that the changes you have made are not breaking the existing functionality. As OpenJDK is a big project with its own rules and processes, there will be a part covering the procedures that are involved in making changes or fixing bugs, the lifecycle of projects, JSRs, JEPs, and so on. At the end, there will be a section about future work that is planned to be included in forthcoming releases; that part will be the most interesting section for anyone who is interested in the future direction of OpenJDK and wants to try something new, which is not yet available in the stable product.

    In addition, this book contains many practical examples which should be useful to any developer who is working with OpenJDK or any other Java technology. They are available in simple form, which allows you to quickly copy and use them for your own project.

    What this book covers

    Chapter 1, Getting Started with OpenJDK, provides an overview of OpenJDK, explains what it is, and covers the basic steps required to have OpenJDK running and properly configured on the machine.

    Chapter 2, Building OpenJDK 6, covers the steps required to build OpenJDK Version 6. This build is very different from OpenJDK 7 and OpenJDK 8 and requires more manual work to be done.

    Chapter 3, Building OpenJDK 7, covers the steps required to build OpenJDK Version 7. Building OpenJDK 7 is an easier and more enjoyable process, compared to OpenJDK 6.

    Chapter 4, Building OpenJDK 8, covers the steps required to build OpenJDK Version 8.

    Chapter 5, Building IcedTea, teaches you how to build a set of tools that are developed apart from OpenJDK. These tools are replaced with some proprietary bits that are not available as open source, which include a browser plugin, Java WebStart, and so on.

    Chapter 6, Building IcedTea with Other VM Implementations, covers some interesting VM projects, which also can benefit from the features provided by IcedTea, and how to build that product using these VMs and non-x86 CPUs.

    Chapter 7, Working with WebStart and the Browser Plugin, will cover the configuration and installation of WebStart and browser plugin components, which are the biggest parts of the IcedTea project.

    Chapter 8, Hacking OpenJDK, covers some bits which are required to start digging into the OpenJDK source code. Such things are the installation and setup of IDE, debugging, and updating HotSpot source code. There are also some useful examples of what the developer can do, for example, implementing your own intrinsic details.

    Chapter 9, Testing OpenJDK, will go through an approach used in OpenJDK to test the source code and, since writing code is not enough, we need to write high quality product on which the code has to be tested. This chapter will also show you some examples to use the latest available tools.

    Chapter 10, Contributing to OpenJDK, explains how OpenJDK is changing and evolving, how changes are executed, and what one needs to do to participate or to facilitate changes in OpenJDK. Some of these changes, if they are big enough, can take years to appear in the production version.

    Chapter 11, Troubleshooting, teaches you about one of the most important parts of any project: bug fixing. It is important to understand which tools and processes are involved. In this chapter, we will cover some important steps, from submitting defects, to pushing the fix into the shared repository.

    Chapter 12, Working with Future Technologies, covers some future developments in OpenJDK. As with any big project, OpenJDK has a roadmap with some exciting and promising projects for the next releases. That is exactly what this chapter is about. It lists all the steps required to download sources, build, and run some examples, where possible.

    Chapter 13, Build Automation, provides some useful tips for automating the build process. It will be

    Enjoying the preview?
    Page 1 of 1