Chapter 4. Autoboxing and Unboxing

Table of Contents

Autoboxing and Unboxing in Java 5
Autoboxing and Join Point matching in AspectJ 5
Inter-type method declarations and method dispatch

Autoboxing and Unboxing in Java 5

Java 5 (and hence AspectJ 1.5) supports automatic conversion of primitive types (int, float, double etc.) to their object equivalents (Integer, Float, Double,...) in assignments and method and constructor invocations. This conversion is know as autoboxing.

Java 5 also supports automatic unboxing, where wrapper types are automatically converted into their primitive equivalents if needed for assignments or method or constructor invocations.

For example:

		int i = 0;
		i = new Integer(5); // auto-unboxing
		Integer i2 = 5;  // autoboxing