A trait is a programming language feature which contains acollection of methods that can be reused across class hierarchies.Traits is a relatively new language feature that is beginning to bea part of some of the newest object-oriented programming languages.Traits have been implemented in some languages but it has not becomea part of the Java language yet. In this thesis we apply traits tothe Java 5 language by designing and implementing a traits awarepreprocessor. The preprocessor translates a Java language extendedwith trait syntax into ordinary Java 5. The preprocessor buildsabstract syntax trees of the input files and inserts traits bymanipulating the abstract syntax trees. The preprocessor alsocontains a type-checker which ensures that the trait can safely beapplied to a certain class. This thesis describes the implementation of the traits preprocessorfor Java and compares it to some other implementations of traits instatically typed languages.