3 September 2006

What is in Java 5

Tiger, Tiger Floating LightDid you ever wonder when a particular class was introduced into the JDK? Or did you ever want to get a quick overview of all new classes included in a new release of Java? That is why I maintain my personal list of all public classes together with the JRE's version they were introduced. I started the list in 2002 and have been updating it whenever a new version of Java came out. Now, almost two years after the release of Tiger, it is high time to update my list with Java 5.

Source of Truth
There is only one true source of the contents of a JRE, and that is rt.jar. Getting a plain list of all *.class files inside the archive is not enough because some classes are package accessible and cannot be used in Java code directly. I use a series of shell scripts that generate a text file with all Java classes of rt.jar. After unpacking rt.jar a script iterates all class names and calls javap -public %class% >> access.log for each of them. Stripping all public content from access.log reveals the package accessible classes, e.g.
java.awt.MutableBoolean
java.beans.ReflectionUtils
java.util.JumboEnumSet
java.util.XMLUtils
...
The list of new classes is the list of all classes found in rt.jar minus the package accessible classes, minus all classes of all earlier versions of Java.

Java 5
Tiger adds 172 new public types in the java. name-space. The new classes are
java.awt.datatransfer.FlavorEvent
java.awt.datatransfer.FlavorListener
java.awt.MouseInfo
java.awt.peer.KeyboardFocusManagerPeer
java.awt.peer.MouseInfoPeer
java.awt.PointerInfo
java.beans.IndexedPropertyChangeEvent
java.io.Closeable
java.io.Flushable
java.lang.Appendable
java.lang.Deprecated
java.lang.Enum
java.lang.EnumConstantNotPresentException
java.lang.Iterable
java.lang.Override
java.lang.ProcessBuilder
java.lang.Readable
java.lang.reflect.AnnotatedElement
java.lang.reflect.GenericArrayType
java.lang.reflect.GenericDeclaration
java.lang.reflect.GenericSignatureFormatError
java.lang.reflect.MalformedParameterizedTypeException
java.lang.reflect.ParameterizedType
java.lang.reflect.Type
java.lang.reflect.TypeVariable
java.lang.reflect.WildcardType
java.lang.StringBuilder
java.lang.SuppressWarnings
java.lang.TypeNotPresentException
java.math.MathContext
java.math.RoundingMode
java.net.CacheRequest
java.net.CacheResponse
java.net.CookieHandler
java.net.HttpRetryException
java.net.Proxy
java.net.ProxySelector
java.net.ResponseCache
java.net.SecureCacheResponse
java.rmi.server.RemoteObjectInvocationHandler
java.security.AuthProvider
java.security.CodeSigner
java.security.interfaces.ECKey
java.security.interfaces.ECPrivateKey
java.security.interfaces.ECPublicKey
java.security.KeyRep
java.security.spec.ECField
java.security.spec.ECFieldF2m
java.security.spec.ECFieldFp
java.security.spec.ECGenParameterSpec
java.security.spec.ECParameterSpec
java.security.spec.ECPoint
java.security.spec.ECPrivateKeySpec
java.security.spec.ECPublicKeySpec
java.security.spec.EllipticCurve
java.security.spec.MGF1ParameterSpec
java.security.Timestamp
java.security.UnrecoverableEntryException
java.util.AbstractQueue
java.util.DuplicateFormatFlagsException
java.util.EnumMap
java.util.EnumSet
java.util.FormatFlagsConversionMismatchException
java.util.Formattable
java.util.FormattableFlags
java.util.Formatter
java.util.FormatterClosedException
java.util.IllegalFormatCodePointException
java.util.IllegalFormatConversionException
java.util.IllegalFormatException
java.util.IllegalFormatFlagsException
java.util.IllegalFormatPrecisionException
java.util.IllegalFormatWidthException
java.util.InputMismatchException
java.util.InvalidPropertiesFormatException
java.util.jar.Pack200
java.util.logging.LoggingMXBean
java.util.MissingFormatArgumentException
java.util.MissingFormatWidthException
java.util.PriorityQueue
java.util.Queue
java.util.regex.MatchResult
java.util.Scanner
java.util.UnknownFormatConversionException
java.util.UnknownFormatFlagsException
java.util.UUID
as well as 86 classes of the four completely new packages
java.lang.annotation
java.lang.instrument
java.lang.management
java.util.concurrent
Further there are around 300 new types in javax. packages. The JMX Management Extension 1.2, javax.management, adds more than 170 classes and is a major addition. Further there are several smaller new packages, mainly
javax.jnlp
javax.sql.rowset
javax.xml.datatype
javax.xml.namespace
javax.xml.validation
javax.xml.xpath
i.e. JNLP-Client 1.0 for JavaWebStart, SQL RowSet implementations and several XML functions from JAXP 1.3 like schema mapping, name-spaces, schema validation and XPath.

Full Class List
Here is the complete list of all classes from Java 1.0 to 1.5, to be more precise from Sun's JDK 1.02 and 1.1.8_09, J2SE 1.2.2_13, 1.3.1_08 and 1.4.2_03, and the new Java5 1.5.0_07. This list gets more and more valuable because it becomes more and more difficult to get older JDKs.

30 August 2006

Java Bookshelf

On this page you will find what I think are the most valuable resources for Java developers available. First a list of books every Java software developer should know (no excuses). It's amazing how old some of these are and still there are people around not knowing them. Next are my favourite newsletters (electronic journals), which I read regularly. Last I give you a (probably subjective) list of some of the best development tools available, which are all free.

Books
Books on the Java Language
Newsletters and Sites
Tools

11 January 2006

Object Life Time Monitoring

Two years ago, in the dark ages before Java 5 (2004) I needed to do some Java profiling of the Herold website. Recent investigations using commercial profilers like JProbe had failed because their memory and CPU needs made the application virtually unresponsive. So I had to come up with some lightweight profiling solution of my own.

I was only concerned with memory consumption, as performance seemed to be bottle-necked by garbage collection. Based on a method described by Jack Shirazi in his book, I used PhantomReferences and a modified java.lang.Object to track object creation and garbage collection. That's all, very lightweight. Using this (Object) Life Time Monitor (LTM) I got an idea of the number of certain class instances created and active over time. A simple graphical viewer gave an overview of the collected data, the instances' life times, something like that:

Total number of life instances over timeInstallation
Download LTM 1.01 (49 KB), together with source. It's JDK 1.3 compliant and does not depend on any other libraries. To use it with Java 1.4 extract the ltm-*.zip and put the LTM.jar into your bootclasspath. When using other JREs than 1.4, you have to modify your java.lang.Object as shown below and put it before LTM.jar into your bootclasspath.
// --- code added to object ---
public Object() {
if (at.herold.test.objlifetime.MonitoringFlag.monitoring) {
at.herold.test.objlifetime.ObjectLifetimeMonitoring.monitor(this);
}
}
// --- code added to object ---
Usage
Start your application with LTM enabled by
java -Xbootclasspath/p:LTM.jar
-cp <your application's classpath>
at.herold.test.objlifetime.ObjectLifetimeMonitoring
s
<your application's main class>
<your application's parameters if any>
Tell LTM to start collecting data with java -jar LTM.jar start on the same machine running the application. This enables the counting of objects. To stop collecting data run java -jar LTM.jar stop. The application will continue to run normally.

To save the recently collected raw data use java -jar LTM.jar save. This saves the raw data using a constant file name. The file is created in the current folder, depending on your start routines this might be windows/system32 or somewhere else. Now you may stop the application. You can view the saved data with java -jar LTMViewer.jar <raw file>. This loads, analyses and displays the object lifetime statistics. <raw file> is the file saved by LTM earlier. An JPG image is saved as well.

SourceSt. Monans Cemetery
In case you want to add or change something, there are the following Java packages: objlifetime contains the LTM core classes. Monitoring is managed by the AdminThread, which listens to a socket for commands. objlifetime.viewer contains the viewer to analyse the saved data from the LTM. Analysing classes are subclasses of LifeTimeAnalyser. The source is described in detail in the article Überwachung der Anzahl aktiver Objekte in JavaSPEKTRUM, 1/2006. LTM is Open Source under the GPL license.

FAQ
Q: When defining my own java.lang.Object where do I take it's implementation from? A: The original Object shipped with JDK is used. It's source can be found in the src.zip of the JDK. You just have to compile the new Object.java and put in in the bootclasspath before the LTM.jar (because it contains 1.4 Object.class already).

Q: What is all this 'bootclasspath' about? A: See Using the BootClasspath.

Q: Which type of file has to be passed as an argument to LTM? I am running this application by calling the Main.main() method and it's expecting a file name. A: The application is started as usual, LTM just has to sit in its bootclasspath. So <your application> is the qualified class name of the application you want to start for monitoring, e.g. com.company.app.Main. If you want to test a Tomcat web application you need to use the Catalina Bootstrap class here, as found in startup.sh/bat.

Words of Warning
LTM is a simplistic, very specialised kind of profiler. It was written in 2004 targeting J2SE 1.4. Professional profiling tools are much more powerful and reliable. LTM was only developed because we could not suffer the overhead of a full blown memory snapshot algorithm. Note that the newer Java 5 offers better ways to collect the memory information either by using JMX or agents and JVMTI.

References(List of all my publications with abstracts.)

1 January 2006

My Cup of Java

Wrench Rust I like coding. I have always been coding: Basic, 65xx-Assembler, Fortran 77, Turbo Pascal, Intel Assembler, Fortran 90. Since 1999 I have been working as Java Software Engineer. And I like Java. It is a free, high level, object orientated language. (But using it will not buy you much on its own; you can write poor code in any language.) Since then I have created a lot of things in my free time, e.g. small games, APIs, tools, etc.

Bunch of Developed Oddities
These are my Java development "oddities" and here you will find some of my programs together with coding related information.