Skip to content

Commit 3f8c989

Browse files
authored
Make non-static nested classes static (CodeQL java/non-static-nested-class) (#249)
Add static to 12 member nested classes that never reference their enclosing instance, across 10 files, dropping the implicit outer-this reference. Behavior-preserving and self-checked by compilation: adding static to a nested class that actually used the enclosing instance would fail to compile. Verified by compiling every affected Maven module (commons audit, http-framework, util, httpdump, doc-maven-plugin, and persistit core/ui).
1 parent cca1422 commit 3f8c989

10 files changed

Lines changed: 15 additions & 13 deletions

File tree

commons/audit/core/src/main/java/org/forgerock/audit/AuditServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ private enum LifecycleState {
468468
/**
469469
* Substitute {@link AuditEventHandler} to use when no query handler is available.
470470
*/
471-
private final class NullQueryHandler implements AuditEventHandler {
471+
private static final class NullQueryHandler implements AuditEventHandler {
472472

473473
private final String errorMessage;
474474

commons/audit/handler-csv/src/main/java/org/forgerock/audit/handlers/csv/CsvAuditEventHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ private CellProcessor[] createCellProcessors(final String auditEntryType, final
544544
/**
545545
* CellProcessor for parsing JsonValue objects from CSV file.
546546
*/
547-
public class ParseJsonValue implements CellProcessor {
547+
public static class ParseJsonValue implements CellProcessor {
548548

549549
@Override
550550
public Object execute(final Object value, final CsvContext context) {

commons/doc-maven-plugin/src/main/java/org/forgerock/doc/maven/utils/Profiler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* information: "Portions copyright [year] [name of copyright owner]".
1313
*
1414
* Copyright 2015 ForgeRock AS.
15+
* Portions Copyrighted 2026 3A Systems, LLC
1516
*/
1617

1718
package org.forgerock.doc.maven.utils;
@@ -181,7 +182,7 @@ private String getExclusionsMatch(final String attribute, final String[] values)
181182
/**
182183
* Applies an XSL transformation to the matching files.
183184
*/
184-
private class Transformer extends XmlTransformer {
185+
private static class Transformer extends XmlTransformer {
185186
/**
186187
* Constructs an updater to match DocBook XML files.
187188
* <br>

commons/http-framework/binding-test-utils/src/main/java/org/forgerock/http/bindings/BindingTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* information: "Portions copyright [year] [name of copyright owner]".
1313
*
1414
* Copyright 2016 ForgeRock AS.
15+
* Portions Copyrighted 2026 3A Systems, LLC
1516
*/
1617

1718
package org.forgerock.http.bindings;
@@ -314,7 +315,7 @@ public void removeDescriptorListener(Listener listener) {
314315
}
315316
}
316317

317-
private final class TestSessionHandler implements Handler {
318+
private static final class TestSessionHandler implements Handler {
318319
@Override
319320
public Promise<Response, NeverThrowsException> handle(Context context, Request request) {
320321
final Session session = context.asContext(SessionContext.class).getSession();

commons/http-framework/core/src/main/java/org/forgerock/http/io/BranchingStreamWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* Copyright 2010–2011 ApexIdentity Inc.
1515
* Portions Copyright 2011-2016 ForgeRock AS.
16-
* Portions copyright 2026 3A Systems LLC.
16+
* Portions Copyrighted 2026 3A Systems, LLC
1717
*/
1818

1919
package org.forgerock.http.io;
@@ -273,7 +273,7 @@ private void writeBuffer(byte[] b, int off, int len) throws IOException {
273273
}
274274

275275
/** Object shared by all branches. */
276-
private final class Trunk {
276+
private static final class Trunk {
277277
/** Keeps track of all branches on this trunk. */
278278
private final List<BranchingStreamWrapper> branches = new ArrayList<>();
279279

commons/httpdump/src/main/java/ru/org/openam/httpdump/BufferedRequestWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public BufferedReader getReader() throws IOException {
7474
return new BufferedReader(new InputStreamReader(getInputStream(), enc));
7575
}
7676

77-
private class ServletInputStreamImpl extends ServletInputStream {
77+
private static class ServletInputStreamImpl extends ServletInputStream {
7878
private ByteArrayInputStream is;
7979

8080
public ServletInputStreamImpl(ByteArrayInputStream is) {

commons/util/util/src/main/java/org/forgerock/util/thread/ExecutorServiceFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public void shutdown() {
199199
* have its generated number appended to the end of it, in the form -X, where
200200
* X is incremented once for each thread created.
201201
*/
202-
private class NamedThreadFactory implements ThreadFactory {
202+
private static class NamedThreadFactory implements ThreadFactory {
203203

204204
private final AtomicInteger count = new AtomicInteger(0);
205205
private final String name;

persistit/core/src/main/java/com/persistit/JournalManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2837,7 +2837,7 @@ public Persistit getPersistit() {
28372837
}
28382838
}
28392839

2840-
class PruneTransactionPlayer implements TransactionPlayerListener
2840+
static class PruneTransactionPlayer implements TransactionPlayerListener
28412841
{
28422842

28432843
@Override

persistit/ui/src/main/java/com/persistit/ui/ManagementTableModel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public Class getColumnClass(final int col) {
288288
* Default Renderers
289289
**/
290290

291-
class AlignedCellRenderer extends DefaultTableCellRenderer {
291+
static class AlignedCellRenderer extends DefaultTableCellRenderer {
292292
AlignedCellRenderer(final int alignment) {
293293
super();
294294
setHorizontalAlignment(alignment);
@@ -334,7 +334,7 @@ public void setValue(final Object value) {
334334
}
335335
}
336336

337-
class KeyStateRenderer extends AlignedCellRenderer {
337+
static class KeyStateRenderer extends AlignedCellRenderer {
338338
private final Key _key;
339339

340340
public KeyStateRenderer() {
@@ -352,7 +352,7 @@ public void setValue(final Object value) {
352352
}
353353
}
354354

355-
class ValueStateRenderer extends AlignedCellRenderer {
355+
static class ValueStateRenderer extends AlignedCellRenderer {
356356
private final Value _value;
357357

358358
public ValueStateRenderer() {

persistit/ui/src/main/java/com/persistit/ui/ValueInspectorTreeNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ private Field[] getFields(final Class type) {
423423
return array;
424424
}
425425

426-
private class FieldComparator implements Comparator {
426+
private static class FieldComparator implements Comparator {
427427
@Override
428428
public int compare(final Object a, final Object b) {
429429
final Field fieldA = (Field) a;

0 commit comments

Comments
 (0)