This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
deadcode4j v2.1.0: Features
Sebastian Kirsch (@skirsch79) edited this page Feb 11, 2016
·
1 revision
deadcode4j takes several approaches to analyze if a class is still in use or not:
- statical code analysis using Javassist, recognizing class dependencies1
- statical java source file analysis using Java 1.8 parser to counteract type erasure and constants inlining
- parsing Spring XML files: files ending with
.xml
are examined- each
bean
element'sclass
attribute is treated as live code - classes being referenced via static calls made by
org.springframework.beans.factory.config.MethodInvokingFactoryBean
are treated as live code -
CXF endpoint definitions: each
endpoint
element'simplementor
/implementorClass
attribute is treated as live code -
Quartz job definitions: each
property
element'sclass
attribute is treated as live code if it has anname
attribute ofjobClass
-
Spring View resolvers: each
property
element'sclass
attribute is treated as live code if it has anname
attribute ofviewClass
- recognizes Spring XML NamespaceHandlers as live code
- each
- recognizing classes annotated with those Spring annotations as live code:
org.springframework.jmx.export.annotation.ManagedResource
-
org.springframework.stereotype.Component
annotations are examined recursively, thus other annotations like e.g.@Controller
also mark classes as live code
- recognizing Spring Data custom repositories: custom implementations are treated as live code
- recognizes only custom implementations following the default naming convention
RepositoryNameImpl
- recognizes only custom implementations following the default naming convention
- parsing
web.xml
- recognizing listed listeners, filters & servlets (according to the XSD files)
- look for the parameters defined by Spring's ContextLoader and FrameworkServlet:
contextClass
,contextConfigLocation
&contextInitializerClasses
, treating the configured classes as live code - if the
metadata-complete
attribute isn't explicitly set tofalse
:- implementations of
javax.servlet.ServletContainerInitializer
are treated as live code - implementations of
org.springframework.web.WebApplicationInitializer
are treated as live code
- implementations of
- look for the parameter specifying a custom Jersey application; a contribution by stefanbirkner
- parsing
*.tld
files: recognizing custom tags, tag extra infos, listeners, tag library validators & EL functions - parsing
faces-config.xml
files: recognizing those element classes as live code:action-listener
,application-factory
,attribute-class
,base-name
,behavior-class
,client-behavior-renderer-class
,component-class
,converter-class
,converter-for-class
,el-resolver
,exception-handler-factory
,external-context-factory
,facelet-cache-factory
,faces-config-value-classType
,faces-context-factory
,flash-factory
,flow-handler-factory
,key-class
,lifecycle-factory
,managed-bean-class
,navigation-handler
,partial-view-context-factory
,phase-listener
,property-class
,property-resolver
,referenced-bean-class
,render-kit-class
,render-kit-factory
,renderer-class
,resource-handler
,source-class
,state-manager
,system-event-class
,system-event-listener-class
,tag-handler-delegate-factory
,validator-class
,value-class
,variable-resolver
,view-declaration-language-factory
,view-handler
,visit-context-factory
- recognizing classes annotated with JEE annotations as live code:
javax.annotation.ManagedBean
javax.inject.Named
javax.persistence.metamodel.StaticMetamodel
- JAXB annotation
javax.xml.bind.annotation.XmlRegistry
- JAXB annotation
javax.xml.bind.annotation.XmlSchema
-
JSF annotations
javax.faces.component.behavior.FacesBehavior
,javax.faces.convert.FacesConverter
,javax.faces.event.ListenerFor
,javax.faces.event.ListenersFor
,javax.faces.event.NamedEvent
,javax.faces.render.FacesBehaviorRenderer
,javax.faces.render.FacesRenderer
,javax.faces.validator.FacesValidator
,javax.faces.view.facelets.FaceletsResourceResolver
- parsing Spring Web Flow XML: files ending with
.xml
are examined- each
attribute
element'stype
attribute is treated as live code - each
evaluate
element'sresult-type
attribute is treated as live code - each
input
element'stype
attribute is treated as live code - each
output
element'stype
attribute is treated as live code - each
set
element'stype
attribute is treated as live code - each
var
element'sclass
attribute is treated as live code
- each
- parsing Apache Tiles XML definition files: files ending with
.xml
are examined- each
definition
element'spreparer
attribute is treated as live code - each
bean
element'sclasstype
attribute is treated as live code - each
item
element'sclasstype
attribute is treated as live code
- each
- processing Hibernate Annotations
- recognizing the
strategy
value of theorg.hibernate.annotations.GenericGenerator
annotation as live code- issue a warning if a
@GenericGenerator
is defined more than once with the samename
- issue a warning if a
- recognizing classes annotated with
org.hibernate.annotations.GenericGenerator
that are referenced by another class viajavax.persistence.GeneratedValue
annotation'sgenerator
value as live code - recognizing the
type
value of theorg.hibernate.annotations.Type
annotation as live code - recognizing classes annotated with a
org.hibernate.annotations.TypeDef
that are referenced by another class in the project as live code- issue a warning if a
@TypeDef
is defined more than once with the samename
- issue a warning if a
- recognizing the
- recognizing
*Descriptor
classes being generated by Castor as live code - recognizing service classes defined within Axis
.wsdd
files as live code - recognizing aspects defined within
aop.xml
as live code; supports both AspectJ and AspectWerkz - parsing Jetty XML configuration files: recognizing listed
class
andtype
attributes as live code
- recognizing classes annotated with custom specified annotations as live code
- Annotations are processed recursively; i.e. if you list
@Annotation
here and a class is annotated with@SubAnnotation
which is itself annotated with@Annotation
, that class is marked as live code - Annotations marked with
@Inherited
will cause subclasses of a class with such an annotation to be marked as live code as well - issue a warning if an annotation is not found in the class path and thus is likely to not exist
- Annotations are processed recursively; i.e. if you list
- recognizing classes implementing custom specified interfaces as live code
- issue a warning if an interface is not found in the class path and thus is likely to not exist
- recognizing classes extending custom specified classes as live code
- issue a warning if a superclass is not found in the class path and thus is likely to not exist
- custom XML file parsing: treating classes referenced in elements' text or attributes as live code
- issue a warning if a configuration never identifies anything
1 Inner classes are always recognized as being referenced by the outer class and vice versa (even static inner classes). This is not only true for the currently used Javassist, but also for BCEL. This suggests that this is an aspect of the JVM spec.