Skip to content

Commit e94f145

Browse files
Fix a bunch of non-final static fields (#119185)
Fixing almost all missing `final` spots, who knows maybe we get a small speedup from some constant folding here and there.
1 parent 3c84517 commit e94f145

File tree

140 files changed

+238
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+238
-242
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/distribution/InternalElasticsearchDistributionTypes.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
import java.util.List;
1515

1616
public class InternalElasticsearchDistributionTypes {
17-
public static ElasticsearchDistributionType DEB = new DebElasticsearchDistributionType();
18-
public static ElasticsearchDistributionType RPM = new RpmElasticsearchDistributionType();
19-
public static ElasticsearchDistributionType DOCKER = new DockerElasticsearchDistributionType();
20-
public static ElasticsearchDistributionType DOCKER_IRONBANK = new DockerIronBankElasticsearchDistributionType();
21-
public static ElasticsearchDistributionType DOCKER_CLOUD_ESS = new DockerCloudEssElasticsearchDistributionType();
22-
public static ElasticsearchDistributionType DOCKER_WOLFI = new DockerWolfiElasticsearchDistributionType();
17+
public static final ElasticsearchDistributionType DEB = new DebElasticsearchDistributionType();
18+
public static final ElasticsearchDistributionType RPM = new RpmElasticsearchDistributionType();
19+
public static final ElasticsearchDistributionType DOCKER = new DockerElasticsearchDistributionType();
20+
public static final ElasticsearchDistributionType DOCKER_IRONBANK = new DockerIronBankElasticsearchDistributionType();
21+
public static final ElasticsearchDistributionType DOCKER_CLOUD_ESS = new DockerCloudEssElasticsearchDistributionType();
22+
public static final ElasticsearchDistributionType DOCKER_WOLFI = new DockerWolfiElasticsearchDistributionType();
2323

24-
public static List<ElasticsearchDistributionType> ALL_INTERNAL = List.of(
24+
public static final List<ElasticsearchDistributionType> ALL_INTERNAL = List.of(
2525
DEB,
2626
RPM,
2727
DOCKER,

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rerun/TestRerunTaskExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class TestRerunTaskExtension {
3030
/**
3131
* The name of the extension added to each test task.
3232
*/
33-
public static String NAME = "rerun";
33+
public static final String NAME = "rerun";
3434

3535
private final Property<Integer> maxReruns;
3636

build-tools/src/main/java/org/elasticsearch/gradle/distribution/ElasticsearchDistributionTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
import org.elasticsearch.gradle.ElasticsearchDistributionType;
1313

1414
public class ElasticsearchDistributionTypes {
15-
public static ElasticsearchDistributionType ARCHIVE = new ArchiveElasticsearchDistributionType();
16-
public static ElasticsearchDistributionType INTEG_TEST_ZIP = new IntegTestZipElasticsearchDistributionType();
15+
public static final ElasticsearchDistributionType ARCHIVE = new ArchiveElasticsearchDistributionType();
16+
public static final ElasticsearchDistributionType INTEG_TEST_ZIP = new IntegTestZipElasticsearchDistributionType();
1717
}

libs/grok/src/main/java/org/elasticsearch/grok/PatternBank.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
public class PatternBank {
2525

26-
public static PatternBank EMPTY = new PatternBank(Map.of());
26+
public static final PatternBank EMPTY = new PatternBank(Map.of());
2727

2828
private final Map<String, String> bank;
2929

libs/h3/src/main/java/org/elasticsearch/h3/Constants.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ final class Constants {
2929
/**
3030
* sqrt(3) / 2.0
3131
*/
32-
public static double M_SQRT3_2 = 0.8660254037844386467637231707529361834714;
32+
public static final double M_SQRT3_2 = 0.8660254037844386467637231707529361834714;
3333
/**
3434
* 2.0 * PI
3535
*/
3636
public static final double M_2PI = 2.0 * Math.PI;
3737
/**
3838
* The number of H3 base cells
3939
*/
40-
public static int NUM_BASE_CELLS = 122;
40+
public static final int NUM_BASE_CELLS = 122;
4141
/**
4242
* The number of vertices in a hexagon
4343
*/
44-
public static int NUM_HEX_VERTS = 6;
44+
public static final int NUM_HEX_VERTS = 6;
4545
/**
4646
* The number of vertices in a pentagon
4747
*/
48-
public static int NUM_PENT_VERTS = 5;
48+
public static final int NUM_PENT_VERTS = 5;
4949
/**
5050
* H3 index modes
5151
*/
52-
public static int H3_CELL_MODE = 1;
52+
public static final int H3_CELL_MODE = 1;
5353
/**
5454
* square root of 7
5555
*/
@@ -64,14 +64,14 @@ final class Constants {
6464
* (or distance between adjacent cell center points
6565
* on the plane) to gnomonic unit length.
6666
*/
67-
public static double RES0_U_GNOMONIC = 0.38196601125010500003;
67+
public static final double RES0_U_GNOMONIC = 0.38196601125010500003;
6868
/**
6969
* rotation angle between Class II and Class III resolution axes
7070
* (asin(sqrt(3.0 / 28.0)))
7171
*/
72-
public static double M_AP7_ROT_RADS = 0.333473172251832115336090755351601070065900389;
72+
public static final double M_AP7_ROT_RADS = 0.333473172251832115336090755351601070065900389;
7373
/**
7474
* threshold epsilon
7575
*/
76-
public static double EPSILON = 0.0000000000000001;
76+
public static final double EPSILON = 0.0000000000000001;
7777
}

libs/h3/src/main/java/org/elasticsearch/h3/H3.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public final class H3 {
3333
/**
3434
* max H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15
3535
*/
36-
public static int MAX_H3_RES = 15;
36+
public static final int MAX_H3_RES = 15;
3737

3838
private static final long[] NORTH = new long[MAX_H3_RES + 1];
3939
private static final long[] SOUTH = new long[MAX_H3_RES + 1];

libs/h3/src/main/java/org/elasticsearch/h3/H3Index.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ public static boolean H3_is_pentagon(long h3) {
4141
return BaseCells.isBaseCellPentagon(H3Index.H3_get_base_cell(h3)) && H3Index.h3LeadingNonZeroDigit(h3) == 0;
4242
}
4343

44-
public static long H3_INIT = 35184372088831L;
44+
public static final long H3_INIT = 35184372088831L;
4545

4646
/**
4747
* The bit offset of the mode in an H3 index.
4848
*/
49-
public static int H3_MODE_OFFSET = 59;
49+
public static final int H3_MODE_OFFSET = 59;
5050

5151
/**
5252
* 1's in the 4 mode bits, 0's everywhere else.
5353
*/
54-
public static long H3_MODE_MASK = 15L << H3_MODE_OFFSET;
54+
public static final long H3_MODE_MASK = 15L << H3_MODE_OFFSET;
5555

5656
/**
5757
* 0's in the 4 mode bits, 1's everywhere else.
5858
*/
59-
public static long H3_MODE_MASK_NEGATIVE = ~H3_MODE_MASK;
59+
public static final long H3_MODE_MASK_NEGATIVE = ~H3_MODE_MASK;
6060

6161
public static long H3_set_mode(long h3, long mode) {
6262
return (h3 & H3_MODE_MASK_NEGATIVE) | (mode << H3_MODE_OFFSET);
@@ -65,16 +65,16 @@ public static long H3_set_mode(long h3, long mode) {
6565
/**
6666
* The bit offset of the base cell in an H3 index.
6767
*/
68-
public static int H3_BC_OFFSET = 45;
68+
public static final int H3_BC_OFFSET = 45;
6969
/**
7070
* 1's in the 7 base cell bits, 0's everywhere else.
7171
*/
72-
public static long H3_BC_MASK = 127L << H3_BC_OFFSET;
72+
public static final long H3_BC_MASK = 127L << H3_BC_OFFSET;
7373

7474
/**
7575
* 0's in the 7 base cell bits, 1's everywhere else.
7676
*/
77-
public static long H3_BC_MASK_NEGATIVE = ~H3_BC_MASK;
77+
public static final long H3_BC_MASK_NEGATIVE = ~H3_BC_MASK;
7878

7979
/**
8080
* Sets the integer base cell of h3 to bc.
@@ -83,26 +83,26 @@ public static long H3_set_base_cell(long h3, long bc) {
8383
return (h3 & H3_BC_MASK_NEGATIVE) | (bc << H3_BC_OFFSET);
8484
}
8585

86-
public static int H3_RES_OFFSET = 52;
86+
public static final int H3_RES_OFFSET = 52;
8787
/**
8888
* 1's in the 4 resolution bits, 0's everywhere else.
8989
*/
90-
public static long H3_RES_MASK = 15L << H3_RES_OFFSET;
90+
public static final long H3_RES_MASK = 15L << H3_RES_OFFSET;
9191

9292
/**
9393
* 0's in the 4 resolution bits, 1's everywhere else.
9494
*/
95-
public static long H3_RES_MASK_NEGATIVE = ~H3_RES_MASK;
95+
public static final long H3_RES_MASK_NEGATIVE = ~H3_RES_MASK;
9696

9797
/**
9898
* The bit offset of the max resolution digit in an H3 index.
9999
*/
100-
public static int H3_MAX_OFFSET = 63;
100+
public static final int H3_MAX_OFFSET = 63;
101101

102102
/**
103103
* 1 in the highest bit, 0's everywhere else.
104104
*/
105-
public static long H3_HIGH_BIT_MASK = (1L << H3_MAX_OFFSET);
105+
public static final long H3_HIGH_BIT_MASK = (1L << H3_MAX_OFFSET);
106106

107107
/**
108108
* Gets the highest bit of the H3 index.
@@ -121,12 +121,12 @@ public static long H3_set_resolution(long h3, long res) {
121121
/**
122122
* The bit offset of the reserved bits in an H3 index.
123123
*/
124-
public static int H3_RESERVED_OFFSET = 56;
124+
public static final int H3_RESERVED_OFFSET = 56;
125125

126126
/**
127127
* 1's in the 3 reserved bits, 0's everywhere else.
128128
*/
129-
public static long H3_RESERVED_MASK = (7L << H3_RESERVED_OFFSET);
129+
public static final long H3_RESERVED_MASK = (7L << H3_RESERVED_OFFSET);
130130

131131
/**
132132
* Gets a value in the reserved space. Should always be zero for valid indexes.
@@ -149,12 +149,12 @@ public static int H3_get_resolution(long h3) {
149149
/**
150150
* The number of bits in a single H3 resolution digit.
151151
*/
152-
public static int H3_PER_DIGIT_OFFSET = 3;
152+
public static final int H3_PER_DIGIT_OFFSET = 3;
153153

154154
/**
155155
* 1's in the 3 bits of res 15 digit bits, 0's everywhere else.
156156
*/
157-
public static long H3_DIGIT_MASK = 7L;
157+
public static final long H3_DIGIT_MASK = 7L;
158158

159159
/**
160160
* Gets the resolution res integer digit (0-7) of h3.

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/ingest/IngestDocumentBridge.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
public class IngestDocumentBridge extends StableBridgeAPI.Proxy<IngestDocument> {
2222

23-
public static String INGEST_KEY = IngestDocument.INGEST_KEY;
24-
2523
public static IngestDocumentBridge wrap(final IngestDocument ingestDocument) {
2624
if (ingestDocument == null) {
2725
return null;

libs/tdigest/src/main/java/org/elasticsearch/tdigest/MergingDigest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public class MergingDigest extends AbstractTDigest {
111111
// based on accumulated k-index. This can be much faster since we
112112
// scale functions are more expensive than the corresponding
113113
// weight limits.
114-
public static boolean useWeightLimit = true;
114+
public static final boolean useWeightLimit = true;
115115

116116
static MergingDigest create(TDigestArrays arrays, double compression) {
117117
arrays.adjustBreaker(SHALLOW_SIZE);

modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintAnalyzerProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
*/
2525
public class FingerprintAnalyzerProvider extends AbstractIndexAnalyzerProvider<Analyzer> {
2626

27-
public static ParseField SEPARATOR = new ParseField("separator");
28-
public static ParseField MAX_OUTPUT_SIZE = new ParseField("max_output_size");
27+
public static final ParseField SEPARATOR = new ParseField("separator");
28+
public static final ParseField MAX_OUTPUT_SIZE = new ParseField("max_output_size");
2929

30-
public static int DEFAULT_MAX_OUTPUT_SIZE = 255;
31-
public static CharArraySet DEFAULT_STOP_WORDS = CharArraySet.EMPTY_SET;
30+
public static final int DEFAULT_MAX_OUTPUT_SIZE = 255;
31+
public static final CharArraySet DEFAULT_STOP_WORDS = CharArraySet.EMPTY_SET;
3232
public static final char DEFAULT_SEPARATOR = ' ';
3333

3434
private final FingerprintAnalyzer analyzer;

0 commit comments

Comments
 (0)