From 09a96bbd4827fddcef12f6ebd06c3495c92cfbac Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 20 Dec 2025 05:50:39 +0000 Subject: [PATCH 1/2] Fix Spotbugs warnings: Add final modifier to constant fields This commit resolves multiple "Field isn't final but should be" warnings identified by Spotbugs. The `final` modifier has been added to the following fields: - `ColorUtil`: `LTGRAY`, `BLUE`, `BLACK`, `WHITE`, `CYAN`, `GREEN`, `YELLOW`, `MAGENTA`, `GRAY` - `Cookie`: `STORAGE_NAME` - `Log`: `REPORTING_NONE`, `REPORTING_DEBUG`, `REPORTING_PRODUCTION` - `JavascriptContext`: `jsLookupTable` - `LocationRequest`: `PRIORITY_HIGH_ACCUARCY`, `PRIORITY_MEDIUM_ACCUARCY`, `PRIORITY_LOW_ACCUARCY` - `DocumentInfo`: `TYPE_HTML`, `TYPE_IMAGE`, `TYPE_CSS` - `PlatformDefaults`: `VISUAL_PADDING_PROPERTY` These fields are intended to be constants (or effectively final in the case of `jsLookupTable`) and enforcing immutability improves thread safety and code clarity. Existing typos in `LocationRequest` field names are preserved for backward compatibility. --- .../com/codename1/charts/util/ColorUtil.java | 18 +++++++++--------- CodenameOne/src/com/codename1/io/Cookie.java | 2 +- CodenameOne/src/com/codename1/io/Log.java | 6 +++--- .../javascript/JavascriptContext.java | 2 +- .../codename1/location/LocationRequest.java | 6 +++--- .../com/codename1/ui/html/DocumentInfo.java | 6 +++--- .../ui/layouts/mig/PlatformDefaults.java | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CodenameOne/src/com/codename1/charts/util/ColorUtil.java b/CodenameOne/src/com/codename1/charts/util/ColorUtil.java index b99fe49485..41a446bef6 100644 --- a/CodenameOne/src/com/codename1/charts/util/ColorUtil.java +++ b/CodenameOne/src/com/codename1/charts/util/ColorUtil.java @@ -27,15 +27,15 @@ * @author shannah */ public class ColorUtil { - public static int LTGRAY = IColor.LightGray.argb; - public static int BLUE = IColor.Blue.argb; - public static int BLACK = IColor.Black.argb; - public static int WHITE = IColor.White.argb; - public static int CYAN = IColor.Cyan.argb; - public static int GREEN = IColor.Green.argb; - public static int YELLOW = IColor.Yellow.argb; - public static int MAGENTA = IColor.Magenta.argb; - public static int GRAY = IColor.Gray.argb; + public static final int LTGRAY = IColor.LightGray.argb; + public static final int BLUE = IColor.Blue.argb; + public static final int BLACK = IColor.Black.argb; + public static final int WHITE = IColor.White.argb; + public static final int CYAN = IColor.Cyan.argb; + public static final int GREEN = IColor.Green.argb; + public static final int YELLOW = IColor.Yellow.argb; + public static final int MAGENTA = IColor.Magenta.argb; + public static final int GRAY = IColor.Gray.argb; public static int argb(int a, int r, int g, int b) { diff --git a/CodenameOne/src/com/codename1/io/Cookie.java b/CodenameOne/src/com/codename1/io/Cookie.java index 93876c6fbd..57a2608b9c 100644 --- a/CodenameOne/src/com/codename1/io/Cookie.java +++ b/CodenameOne/src/com/codename1/io/Cookie.java @@ -34,7 +34,7 @@ * @author Shai Almog */ public class Cookie implements Externalizable { - public static String STORAGE_NAME = "Cookies"; + public static final String STORAGE_NAME = "Cookies"; private static boolean autoStored = true; static { diff --git a/CodenameOne/src/com/codename1/io/Log.java b/CodenameOne/src/com/codename1/io/Log.java index 2945449e8b..e56c46ddca 100644 --- a/CodenameOne/src/com/codename1/io/Log.java +++ b/CodenameOne/src/com/codename1/io/Log.java @@ -76,15 +76,15 @@ public class Log { /** * Indicates that log reporting to the cloud should be disabled */ - public static int REPORTING_NONE = 0; + public static final int REPORTING_NONE = 0; /** * Indicates that log reporting to the cloud should occur regardless of whether an error occurred */ - public static int REPORTING_DEBUG = 1; + public static final int REPORTING_DEBUG = 1; /** * Indicates that log reporting to the cloud should occur only if an error occurred */ - public static int REPORTING_PRODUCTION = 3; + public static final int REPORTING_PRODUCTION = 3; private static boolean crashBound; private static Log instance = new Log(); private static boolean initialized; diff --git a/CodenameOne/src/com/codename1/javascript/JavascriptContext.java b/CodenameOne/src/com/codename1/javascript/JavascriptContext.java index a474108527..b6afe11f2d 100644 --- a/CodenameOne/src/com/codename1/javascript/JavascriptContext.java +++ b/CodenameOne/src/com/codename1/javascript/JavascriptContext.java @@ -104,7 +104,7 @@ public class JavascriptContext { * The name of the Javascript lookup table that is used to store and * look up Javascript objects that have a JSObject proxy. */ - String jsLookupTable; + final String jsLookupTable; /** * A running counter for the next object ID that is to be assigned to diff --git a/CodenameOne/src/com/codename1/location/LocationRequest.java b/CodenameOne/src/com/codename1/location/LocationRequest.java index 7db0aa7bfe..11546bd536 100644 --- a/CodenameOne/src/com/codename1/location/LocationRequest.java +++ b/CodenameOne/src/com/codename1/location/LocationRequest.java @@ -33,17 +33,17 @@ public class LocationRequest { /** * When you need gps location updates */ - public static int PRIORITY_HIGH_ACCUARCY = 0; + public static final int PRIORITY_HIGH_ACCUARCY = 0; /** * When accuracy is not highly important and you want to save battery */ - public static int PRIORITY_MEDIUM_ACCUARCY = 1; + public static final int PRIORITY_MEDIUM_ACCUARCY = 1; /** * When accuracy is not important and you want to save battery */ - public static int PRIORITY_LOW_ACCUARCY = 2; + public static final int PRIORITY_LOW_ACCUARCY = 2; private int priority = PRIORITY_MEDIUM_ACCUARCY; diff --git a/CodenameOne/src/com/codename1/ui/html/DocumentInfo.java b/CodenameOne/src/com/codename1/ui/html/DocumentInfo.java index 57eb86c28a..cab5ffdabe 100644 --- a/CodenameOne/src/com/codename1/ui/html/DocumentInfo.java +++ b/CodenameOne/src/com/codename1/ui/html/DocumentInfo.java @@ -45,17 +45,17 @@ public class DocumentInfo { /** * Indicates that the request is for a page */ - public static int TYPE_HTML = 0; + public static final int TYPE_HTML = 0; /** * Indicates that the request is for an image */ - public static int TYPE_IMAGE = 1; + public static final int TYPE_IMAGE = 1; /** * Indicates that the request is for a CSS file */ - public static int TYPE_CSS = 2; + public static final int TYPE_CSS = 2; private static String DEFAULT_ENCODING = ENCODING_ISO; diff --git a/CodenameOne/src/com/codename1/ui/layouts/mig/PlatformDefaults.java b/CodenameOne/src/com/codename1/ui/layouts/mig/PlatformDefaults.java index b06673a72a..8163677acf 100644 --- a/CodenameOne/src/com/codename1/ui/layouts/mig/PlatformDefaults.java +++ b/CodenameOne/src/com/codename1/ui/layouts/mig/PlatformDefaults.java @@ -118,7 +118,7 @@ public final class PlatformDefaults { * to specify the visual padding. *

*/ - public static String VISUAL_PADDING_PROPERTY = "visualPadding"; + public static final String VISUAL_PADDING_PROPERTY = "visualPadding"; static BoundSize RELATED_X = null, RELATED_Y = null, UNRELATED_X = null, UNRELATED_Y = null; private static int DEF_H_UNIT = UnitValue.LPX; private static int DEF_V_UNIT = UnitValue.LPY; From 22400419c4768137685e1fb7ea6328010b93bdd6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 20 Dec 2025 06:41:03 +0000 Subject: [PATCH 2/2] Fix Spotbugs warnings: Add final modifier to constant fields This commit resolves multiple "Field isn't final but should be" warnings identified by Spotbugs. The `final` modifier has been added to the following fields: - `ColorUtil`: `LTGRAY`, `BLUE`, `BLACK`, `WHITE`, `CYAN`, `GREEN`, `YELLOW`, `MAGENTA`, `GRAY` - `Cookie`: `STORAGE_NAME` - `Log`: `REPORTING_NONE`, `REPORTING_DEBUG`, `REPORTING_PRODUCTION` - `JavascriptContext`: `DEBUG` - `LocationRequest`: `PRIORITY_HIGH_ACCUARCY`, `PRIORITY_MEDIUM_ACCUARCY`, `PRIORITY_LOW_ACCUARCY` - `DocumentInfo`: `TYPE_HTML`, `TYPE_IMAGE`, `TYPE_CSS` - `PlatformDefaults`: `VISUAL_PADDING_PROPERTY` These fields are intended to be constants (or effectively final in the case of `DEBUG`) and enforcing immutability improves thread safety and code clarity. Existing typos in `LocationRequest` field names are preserved for backward compatibility. --- .../src/com/codename1/javascript/JavascriptContext.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CodenameOne/src/com/codename1/javascript/JavascriptContext.java b/CodenameOne/src/com/codename1/javascript/JavascriptContext.java index b6afe11f2d..eca93b55a5 100644 --- a/CodenameOne/src/com/codename1/javascript/JavascriptContext.java +++ b/CodenameOne/src/com/codename1/javascript/JavascriptContext.java @@ -86,7 +86,7 @@ public class JavascriptContext { /** * Flag to enable/disable logging to a debug log. */ - public static boolean DEBUG = false; + public static final boolean DEBUG = false; /** * Running counter to mark the context ID. Each javascript context has its * own lookup table, and this running counter allows us to generate a unique @@ -104,7 +104,7 @@ public class JavascriptContext { * The name of the Javascript lookup table that is used to store and * look up Javascript objects that have a JSObject proxy. */ - final String jsLookupTable; + String jsLookupTable; /** * A running counter for the next object ID that is to be assigned to