# Duplicate Classes

Classes where there are two or more with the same name.
Copyright (c) 2020 IBM Corporation. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/

# Motivation

Sometimes classes can be loaded multiple times.

# Arguments

Argument
Description
None
No arguments are supplied to this query

# Result

A tree showing each class which has been loaded multiple times. Underneath are the class loaders which loaded the class of that name.

A tree view of the duplicate classes and their class loaders">

If a classes has been loaded multiple times then this might indicate a problem. Sometimes it is deliberate, where different class loaders are part of the application. Sometimes a class is replaced on the fly by the application or as part of a deploy/undeploy cycle in an application server and the old class loader and associated classes should be garbage collected. This can only happen once all the instances of classes, the classes themselves and the class loader are no longer accessible from the rest of the application or GC roots.

If there are no or few instances shown in a class loader line then that class loader might not be used anymore, but some spurious refence might be keeping the class loader alive or one of its defined classes or some of the instances alive, and so that class loader alive. The Path to GC Roots query can help tell why a class loader is kept alive.

Java 8 and later virtual machines create some synthetic classes for lambda expressions. These can have names such as java.lang.invoke.LambdaForm$DMH, java.lang.invoke.LambdaForm$MH and java.lang.invoke.LambdaForm$BMH. These classes are unusual in that multiple classes of the same name are loaded by the same class loader. Unless you think you have a particular problem with lambda expressions, either in the code or the way the JVM handles them, then these classes can be ignored.

The Defined Classes and No. of instances columns show figures for the entire class loader.