JavaOne '02: TS-2558: A Crash Course in Dynamic Class Generation

Dynamically building a Java class file is useful in a surprising number of situations.  It can be quite a daunting task, especially if you generate the bytecode directly, as opposed to generating a .java source file and compiling it.

I gave a crash course at JavaOne '02 providing an introduction to the technologies you can use to build bytecodes dynamically, along with the sorts of problems this can solve.

This page holds the resources from that talk: links, example code & the slides from the presentation.

Bytecode toolkits

When choosing a bytecode toolkit, remember that it is a large investment in time to learn to use one - so you don't want it to not be powerful enough for your needs, nor do you want it to have a restrictive license that might mean you can't use it for everything you might potentially do.  Here are a couple that I recommend:

Examples - systems that use dynamic class generation

Slides from the talk

Available in slides.zip

Example code

I spent a lot of time going over a particular example, that of a very simple RowSet implementation. The example code is available in Rowcache.zip

- Paul McLachlan (pdm@acm.org), April 5, 2002.