Book Image

OpenJDK Cookbook

Book Image

OpenJDK Cookbook

Overview of this book

Table of Contents (20 chapters)
OpenJDK Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 useful for those developers who make frequent changes in OpenJDK or always want to have the build with all the latest changes.

What you need for this book

Generally, you will need nothing except a machine connected to the Internet, preferably to run Linux. If you are going to use a Windows machine, then you will need to install Cygwin.

There may also be additional specific requirements which come with each recipe separately.

Who this book is for

This book is for developers who want a deeper understanding of OpenJDK and want to start making changes. This could be someone who has some cool ideas and wants to contribute or who has found a bug that is tempting to fix. Also it will provide a good starting point to people who want to make changes to the existing VM, for some reason. This could be for research or tailoring VM for specific needs, like special hardware or some very specific requirements.

Overall, it will be useful to anyone who wants to simply have look inside OpenJDK, see what it is, and how it works.

Sections

This book contains the following sections:

Getting ready

This section tells us what to expect in the recipe, and describes how to set up any software or any preliminary settings needed for the recipe.

How to do it…

This section characterizes the steps to be followed for "cooking" the recipe.

How it works…

This section usually consists of a brief and detailed explanation of what happened in the previous section.

There's more…

It consists of additional information about the recipe in order to make the reader more curious about the recipe.

See also

This section may contain references to the recipe.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

private static int doUpdateBytes(int crc, byte[] b, int off, int len) {
    return updateBytes(crc, b, off, len);
}

Any command-line input or output is written as follows:

update-java-alternatives  --list

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Then click on Done."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.