Annotations: startup performance impact on a (Servlet 2.5) server

New features added to Servlet 2.5

Annotation performance
Whether or not you use annotations—and especially if you don’t—it’s important to understand the performance impact they can have on a server at startup. In order for the server to discover annotations on classes, it must load the classes, which means that at startup, a server will look through all the classes in WEB-INF/classes and WEB-INF/lib, looking for annotations. (Per the specification, servers don’t have to look outside these two places.) You can avoid this search when you know you don’t have any annotations by specifying a full attribute on the <web-app> root like this:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
version="2.5" full="true">
</web-app>

When you’re not using annotations, this reenables lazy class loading.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s