Home » Java » Core Java » Page 265

Core Java

A glimpse at Java 7 MethodHandle and its usage

Due to Java’s Reflection API we have been able to inspect and alter program execution at runtime. In particular, we can observe interfaces/classes/methods and fields at runtime without knowing their names at compile time. JDK 7 introduces a new player to this dynamic/runtime inspection, the method handle (i.e. a subclass of the abstract class java.dyn.MethodHandle). Method handles gives us unrestricted ...

Read More »

Understanding and Extending Java ClassLoader

The Java ClassLoader is one of the crucial but rarely used components of Java in Project Development. Personally I have never extended ClassLoader in any of my projects but the idea of having my own ClassLoader that can customize the Java Class Loading thrills me. This article will provide an overview of Java Class Loading and then move forward to ...

Read More »

Doclava: Custom Javadoc Doclet from Google

Doclava is a custom Javadoc Doclet from Google, used by Google Guice (see their slight cooler Javadocs). Doclava uses JSilver as its templating engine, a pure-Java implementation of Clearsilver. I personally like the idea of Federated Documents to allow documentations to link and integrate to each other on open projects. Here are the main differences between Doclava and the standard Doclet: Refreshed ...

Read More »

The dreaded double checked locking idiom in Java

The issue discussed in this article is not new, but still tricky even for seasoned developers. The singleton pattern is a common programming idiom. Nevertheless when used with multiple threads, some type of synchronization must be done in order not to break the code. In a relevant article our JCG partner Manoj Khangaonkar from The Khangaonkar Report examines the double-checked locking idiom in ...

Read More »

Design Patterns in the JDK

Brian Du Preez, our JCG partner from Zen in the art of IT has made a very fine job of collecting the most common design patterns found in the JDK. The pattern list is indeed impressive and long, so let us babble no more and present it to you. I saw an article (well more of a rant) the other day, by ...

Read More »

Using JAXB to generate XML from XSD

This is a post originally published by Mohamed Sanaulla from Experiences Unlimited, our latest JCG partner. Mohamed explains how to use JAXB to generate XML from a given XSD. (NOTE: The original post has been slightly edited to improve readability) We can use JAXB to marshal the Java objects into XML using the given Schema and vice versa- unmarshal XML ...

Read More »

Java Fork/Join for Parallel Programming

The last few years a paradigm shift is taking place in the field of computer processors. For years, processor makers consistently delivered increases in clock rates, so developers enjoyed the fact that their single-threaded software executed faster without any effort from their part. Now, processor makers favor multi-core chip designs, and software has to be written in a multi-threaded or ...

Read More »

Java Memory Model – Quick overview and things to notice

In computing, a Memory model describes how threads interact through memory, or more generally specify what assumptions the compiler is allowed to make when generating code for segmented memory or paged memory platforms. It essentially describes, given a program and an execution trace of that program, whether the execution trace is a legal execution of the program. The Java memory ...

Read More »

Java Best Practices – Char to Byte and Byte to Char conversions

Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to talk about String performance tunning. Especially we will focus on how to handle character to byte and byte to character conversions efficiently when the default encoding is used. This article concludes with a performance comparison between two proposed custom approaches and ...

Read More »