Skip to content

Commit

Permalink
+ final on effective final fields
Browse files Browse the repository at this point in the history
+ Java style array declaration instead of C-style

Signed-off-by: pizzi80 <[email protected]>
  • Loading branch information
pizzi80 committed Jun 19, 2023
1 parent 7841b6b commit 9a972b3
Show file tree
Hide file tree
Showing 96 changed files with 357 additions and 406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ public class ApplicationAssociate {

private final static String FacesComponentJcpNamespace = "http://xmlns.jcp.org/jsf/component";

private ApplicationImpl applicationImpl;
private final ApplicationImpl applicationImpl;

/**
* Overall Map containing <code>from-view-id</code> key and <code>Set</code> of <code>NavigationCase</code> objects for
* that key; The <code>from-view-id</code> strings in this map will be stored as specified in the configuration file -
* some of them will have a trailing asterisk "*" signifying wild card, and some may be specified as an asterisk "*".
*/
private Map<String, Set<NavigationCase>> navigationMap;
private final Map<String, Set<NavigationCase>> navigationMap;

/*
* The FacesComponentTagLibrary uses the information in this map to help it fabricate tag handlers for components
Expand All @@ -139,43 +139,38 @@ public class ApplicationAssociate {

private static final String ASSOCIATE_KEY = RIConstants.FACES_PREFIX + "ApplicationAssociate";

private static ThreadLocal<ApplicationAssociate> instance = new ThreadLocal<>() {
@Override
protected ApplicationAssociate initialValue() {
return null;
}
};
private static final ThreadLocal<ApplicationAssociate> instance = ThreadLocal.withInitial(() -> null);

private List<ELResolver> elResolversFromFacesConfig;
private ExpressionFactory expressionFactory;

private InjectionProvider injectionProvider;
private final InjectionProvider injectionProvider;
private ResourceCache resourceCache;

private String contextName;
private boolean requestServiced;
private boolean errorPagePresent;

private AnnotationManager annotationManager;
private boolean devModeEnabled;
private final AnnotationManager annotationManager;
private final boolean devModeEnabled;
private Compiler compiler;
private DefaultFaceletFactory faceletFactory;
private ResourceManager resourceManager;
private ApplicationStateInfo applicationStateInfo;
private final ApplicationStateInfo applicationStateInfo;

private PropertyEditorHelper propertyEditorHelper;
private final PropertyEditorHelper propertyEditorHelper;

private NamedEventManager namedEventManager;
private final NamedEventManager namedEventManager;

private WebConfiguration webConfig;
private final WebConfiguration webConfig;

private FlowHandler flowHandler;

private SearchExpressionHandler searchExpressionHandler;

private Map<String, String> definingDocumentIdsToTruncatedJarUrls;
private final Map<String, String> definingDocumentIdsToTruncatedJarUrls;

private long timeOfInstantiation;
private final long timeOfInstantiation;

private Map<String, List<String>> resourceLibraryContracts;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class ApplicationStateInfo {

private boolean partialStateSaving;
private final boolean partialStateSaving;
private Set<String> fullStateViewIds;

// ------------------------------------------------------------ Constructors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ByteArrayWebOutputStream extends ServletOutputStream {
// Log instance for this class
private static final Logger LOGGER = FacesLogger.APPLICATION.getLogger();

private DirectByteArrayOutputStream baos;
private final DirectByteArrayOutputStream baos;
private boolean committed;

public ByteArrayWebOutputStream() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.nio.charset.StandardCharsets;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.HashMap;
Expand Down Expand Up @@ -118,7 +119,7 @@ public int compareTo(Utf8InfoReplacement rhs) {

// The source template class on which to base the definition of the new
// PropertyEditor classes.
private Class<? extends ConverterPropertyEditorBase> templateClass;
private final Class<? extends ConverterPropertyEditorBase> templateClass;
// The bytes that define the source template class.
private byte[] templateBytes;
// The constant_pool_count from the template class bytecodes.
Expand Down Expand Up @@ -341,7 +342,7 @@ private byte[] replaceInTemplate(Utf8InfoReplacement... replacements) {
*/
public byte[] generateClassBytesFor(String newClassName, String targetClassName) {
return replaceInTemplate(new Utf8InfoReplacement(classNameConstant, newClassName),
new Utf8InfoReplacement(classNameRefConstant, new StringBuilder(32).append('L').append(newClassName).append(';').toString()),
new Utf8InfoReplacement(classNameRefConstant, 'L' + newClassName + ';'),
new Utf8InfoReplacement(targetClassConstant, targetClassName));
}
}
Expand All @@ -361,9 +362,9 @@ public byte[] generateClassBytesFor(String newClassName, String targetClassName)
*/
private class DisposableClassLoader extends ClassLoader {
// The class loader which loaded the target class.
private ClassLoader targetLoader;
private final ClassLoader targetLoader;
// The class loader which loaded the base class
private ClassLoader myLoader;
private final ClassLoader myLoader;

public DisposableClassLoader(ClassLoader targetLoader) {
super(targetLoader);
Expand Down Expand Up @@ -439,7 +440,7 @@ protected Class<?> findClass(String className) throws ClassNotFoundException {
private static final Pattern MultipleUnderscorePattern = Pattern.compile("_(_+)");
private static ConverterPropertyEditorFactory defaultInstance;
// Template information extracted from the source template class.
private ClassTemplateInfo templateInfo;
private final ClassTemplateInfo templateInfo;
// Cache of DisposableClassLoaders keyed on the class loader of the target.
private Map<ClassLoader, WeakReference<DisposableClassLoader>> classLoaderCache;

Expand Down Expand Up @@ -543,14 +544,7 @@ private static String getVMClassName(Class<?> c) {
*/
private static byte[] getUtf8InfoBytes(String text) {
byte[] utf8;
try {
utf8 = text.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
// The DM_DEFAULT_ENCODING warning is acceptable here
// because we explicitly *want* to use the Java runtime's
// default encoding.
utf8 = text.getBytes();
}
utf8 = text.getBytes(StandardCharsets.UTF_8);
byte[] info = new byte[utf8.length + 3];
info[0] = 1;
info[1] = (byte) (utf8.length >> 8 & 0xff);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
*/
public class NamedEventManager {

private Map<String, Class<? extends SystemEvent>> namedEvents = new ConcurrentHashMap<>();
private Map<String, Set<Class<? extends SystemEvent>>> duplicateNames = new ConcurrentHashMap<>();
private final Map<String, Class<? extends SystemEvent>> namedEvents = new ConcurrentHashMap<>();
private final Map<String, Set<Class<? extends SystemEvent>>> duplicateNames = new ConcurrentHashMap<>();

public NamedEventManager() {
namedEvents.put("jakarta.faces.event.PreRenderComponent", PreRenderComponentEvent.class);
Expand Down Expand Up @@ -81,12 +81,8 @@ public Class<? extends SystemEvent> getNamedEvent(String name) {

public void addDuplicateName(String name, Class<? extends SystemEvent> event) {
Class<? extends SystemEvent> registeredEvent = namedEvents.remove(name);
Set<Class<? extends SystemEvent>> events = duplicateNames.get(name);
Set<Class<? extends SystemEvent>> events = duplicateNames.computeIfAbsent(name, k -> new HashSet<>());

if (events == null) {
events = new HashSet<>();
duplicateNames.put(name, events);
}
events.add(event);

if (registeredEvent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public NoOpWriter() {
}

@Override
public void write(char cbuf[], int off, int len) throws IOException {
public void write(char[] cbuf, int off, int len) throws IOException {
// no-op
}

Expand All @@ -75,7 +75,7 @@ public void write(int c) throws IOException {
}

@Override
public void write(char cbuf[]) throws IOException {
public void write(char[] cbuf) throws IOException {
// no-op
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class WebappLifecycleListener {

private ServletContext servletContext;
private ApplicationAssociate applicationAssociate;
private Set<HttpSession> activeSessions = ConcurrentHashMap.newKeySet();
private final Set<HttpSession> activeSessions = ConcurrentHashMap.newKeySet();


// ------------------------------------------------------------ Constructors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private enum ProcessingTarget {
Renderer(RENDERER_SCANNERS),
SystemEvent(EVENTS_SCANNERS);

private Scanner[] scanners;
private final Scanner[] scanners;

ProcessingTarget(Scanner[] scanners) {
this.scanners = scanners;
Expand All @@ -113,7 +113,7 @@ private enum ProcessingTarget {
/**
* The backing cache for all annotation metadata.
*/
private ConcurrentMap<Class<?>, Future<Map<Class<? extends Annotation>, RuntimeAnnotationHandler>>> cache;
private final ConcurrentMap<Class<?>, Future<Map<Class<? extends Annotation>, RuntimeAnnotationHandler>>> cache;

// ------------------------------------------------------------ Constructors

Expand Down Expand Up @@ -317,8 +317,8 @@ private static final class ProcessAnnotationsTask implements Callable<Map<Class<

@SuppressWarnings({ "unchecked" })
private static final Map<Class<? extends Annotation>, RuntimeAnnotationHandler> EMPTY = Collections.EMPTY_MAP;
private Class<?> clazz;
private Scanner[] scanners;
private final Class<?> clazz;
private final Scanner[] scanners;

// -------------------------------------------------------- Constructors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
class EJBHandler extends JndiHandler implements RuntimeAnnotationHandler {

private static final String JAVA_MODULE = "java:module/";
private Field[] fields;
private EJB[] fieldAnnotations;
private Method[] methods;
private EJB[] methodAnnotations;
private final Field[] fields;
private final EJB[] fieldAnnotations;
private final Method[] methods;
private final EJB[] methodAnnotations;

public EJBHandler(Field[] fields, EJB[] fieldAnnotations, Method[] methods, EJB[] methodAnnotations) {
this.fields = fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import jakarta.faces.component.FacesComponent;

public class FacesComponentUsage {
private Class<?> target;
private FacesComponent annotation;
private final Class<?> target;
private final FacesComponent annotation;

public FacesComponentUsage(Class<?> target, FacesComponent annotation) {
this.target = target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
class ListenerForHandler implements RuntimeAnnotationHandler {

private ListenerFor[] listenersFor;
private final ListenerFor[] listenersFor;

// ------------------------------------------------------------ Constructors

Expand Down Expand Up @@ -57,18 +57,18 @@ public void apply(FacesContext ctx, Object... params) {
}

if (listener instanceof ComponentSystemEventListener) {
for (int i = 0, len = listenersFor.length; i < len; i++) {
target.subscribeToEvent(listenersFor[i].systemEventClass(), (ComponentSystemEventListener) listener);
for (ListenerFor listenerFor : listenersFor) {
target.subscribeToEvent(listenerFor.systemEventClass(), (ComponentSystemEventListener) listener);
}
} else if (listener instanceof SystemEventListener) {
Class<?> sourceClassValue = null;
Application app = ctx.getApplication();
for (int i = 0, len = listenersFor.length; i < len; i++) {
sourceClassValue = listenersFor[i].sourceClass();
for (ListenerFor listenerFor : listenersFor) {
sourceClassValue = listenerFor.sourceClass();
if (sourceClassValue == Void.class) {
app.subscribeToEvent(listenersFor[i].systemEventClass(), (SystemEventListener) listener);
app.subscribeToEvent(listenerFor.systemEventClass(), (SystemEventListener) listener);
} else {
app.subscribeToEvent(listenersFor[i].systemEventClass(), listenersFor[i].sourceClass(), (SystemEventListener) listener);
app.subscribeToEvent(listenerFor.systemEventClass(), listenerFor.sourceClass(), (SystemEventListener) listener);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
*/
class PersistenceContextHandler extends JndiHandler implements RuntimeAnnotationHandler {

private Method[] methods;
private PersistenceContext[] methodAnnotations;
private Field[] fields;
private PersistenceContext[] fieldAnnotations;
private final Method[] methods;
private final PersistenceContext[] methodAnnotations;
private final Field[] fields;
private final PersistenceContext[] fieldAnnotations;

public PersistenceContextHandler(Method[] methods, PersistenceContext[] methodAnnotations, Field[] fields, PersistenceContext[] fieldAnnotations) {
this.methods = methods;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
*/
class PersistenceUnitHandler extends JndiHandler implements RuntimeAnnotationHandler {

private Method[] methods;
private PersistenceUnit[] methodAnnotations;
private Field[] fields;
private PersistenceUnit[] fieldAnnotations;
private final Method[] methods;
private final PersistenceUnit[] methodAnnotations;
private final Field[] fields;
private final PersistenceUnit[] fieldAnnotations;

public PersistenceUnitHandler(Method[] methods, PersistenceUnit[] methodAnnotations, Field[] fields, PersistenceUnit[] fieldAnnotations) {
this.methods = methods;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
*/
class ResourceDependencyHandler implements RuntimeAnnotationHandler {

private ResourceDependency[] dependencies;
private Map<ResourceDependency, Expressions> expressionsMap;
private final ResourceDependency[] dependencies;
private final Map<ResourceDependency, Expressions> expressionsMap;

// ------------------------------------------------------------ Constructors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
*/
class ResourceHandler extends JndiHandler {

private Field[] fields;
private Resource[] fieldAnnotations;
private Method[] methods;
private Resource[] methodAnnotations;
private final Field[] fields;
private final Resource[] fieldAnnotations;
private final Method[] methods;
private final Resource[] methodAnnotations;

public ResourceHandler(Field[] fields, Resource[] fieldAnnotations, Method[] methods, Resource[] methodAnnotations) {
this.fields = fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
*/
class WebServiceRefHandler extends JndiHandler implements RuntimeAnnotationHandler {

private Field[] fields;
private WebServiceRef[] fieldAnnotations;
private Method[] methods;
private WebServiceRef[] methodAnnotations;
private final Field[] fields;
private final WebServiceRef[] fieldAnnotations;
private final Method[] methods;
private final WebServiceRef[] methodAnnotations;

public WebServiceRefHandler(Field[] fields, WebServiceRef[] fieldAnnotations, Method[] methods, WebServiceRef[] methodAnnotations) {
this.fields = fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class Events {
* on a per-FacesContext, per-SystemEvent.class type basis.
*/

private ReentrantLisneterInvocationGuard listenerInvocationGuard = new ReentrantLisneterInvocationGuard();
private final ReentrantLisneterInvocationGuard listenerInvocationGuard = new ReentrantLisneterInvocationGuard();

/*
* @see jakarta.faces.application.Application#publishEvent(FacesContext, Class, Class, Object)
Expand Down Expand Up @@ -259,7 +259,7 @@ private SystemEvent processListenersAccountingForAdds(List<SystemEventListener>
// if original differs from copy, make a new copy.
// The new copy consists of the original list - processed

SystemEventListener listenersCopy[] = new SystemEventListener[listeners.size()];
SystemEventListener[] listenersCopy = new SystemEventListener[listeners.size()];
int i = 0;
for (i = 0; i < listenersCopy.length; i++) {
listenersCopy[i] = listeners.get(i);
Expand Down Expand Up @@ -298,7 +298,7 @@ private SystemEvent processListenersAccountingForAdds(List<SystemEventListener>

}

private boolean originalDiffersFromCopy(Collection<SystemEventListener> original, SystemEventListener copy[]) {
private boolean originalDiffersFromCopy(Collection<SystemEventListener> original, SystemEventListener[] copy) {
boolean foundDifference = false;
int i = 0, originalLen = original.size(), copyLen = copy.length;

Expand Down
Loading

0 comments on commit 9a972b3

Please sign in to comment.