Skip to content

Reduce warning noise#2698

Draft
8Keep wants to merge 4 commits intojMonkeyEngine:masterfrom
8Keep:warning-fixes
Draft

Reduce warning noise#2698
8Keep wants to merge 4 commits intojMonkeyEngine:masterfrom
8Keep:warning-fixes

Conversation

@8Keep
Copy link
Copy Markdown
Contributor

@8Keep 8Keep commented Apr 7, 2026

testing, do not look... did not mean to create a real pr here yet

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modernizes the codebase by updating Gradle build scripts, adding generics to core utilities and rendering pipelines, and transitioning to newer FrameBuffer and Texture APIs. It also addresses compiler warnings and marks legacy methods as deprecated. Feedback focuses on critical API compatibility regressions in the Android modules where newer methods were introduced without version guards, potentially breaking support for older API levels. Additionally, several suggestions were provided to include @SuppressWarnings annotations on new helper methods to fully resolve unchecked cast warnings.

Display disp = wind.getDefaultDisplay();
Log.d("AndroidHarness", "Resolution from Window, width:" + disp.getWidth() + ", height: " + disp.getHeight());
Point displaySize = new Point();
disp.getSize(displaySize);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The method Display.getSize(Point) was introduced in API level 13. Since jme3-android supports down to API level 9 (as specified in OGLESContext), this change will cause a NoSuchMethodError on devices running Android versions older than 3.2. To maintain compatibility, you should use a version check or continue using the deprecated getWidth() and getHeight() methods for older devices.

Comment on lines +416 to +418
Drawable drawable = splashImageView.getContext().getDrawable(splashPicID);
if (drawable instanceof NinePatchDrawable) {
splashImageView.setBackgroundDrawable(drawable);
splashImageView.setBackground(drawable);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

These changes introduce API regressions for older Android devices:

  1. Context.getDrawable(int) (line 416) requires API level 21.
  2. View.setBackground(Drawable) (line 418) requires API level 16.

Since the engine supports API level 9, these calls will crash on older platforms. To fix the deprecation warnings while preserving compatibility, use Build.VERSION.SDK_INT checks to call the appropriate methods based on the platform version.

Comment on lines +48 to +51
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
WeakReference<T>[] refs = (WeakReference<T>[]) new WeakReference<?>[size];
return refs;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cast to WeakReference<T>[] on line 49 is unchecked and will generate a compiler warning. Since the purpose of this PR is to reduce warning noise, this helper method should be annotated with @SuppressWarnings("unchecked").

Suggested change
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
WeakReference<T>[] refs = (WeakReference<T>[]) new WeakReference<?>[size];
return refs;
}
@SuppressWarnings("unchecked")
private static <T> WeakReference<T>[] newWeakReferenceArray(int size) {
return (WeakReference<T>[]) new WeakReference<?>[size];
}

Comment on lines +300 to +303
private static <T> Entry<T>[] newTable(int size) {
Entry<T>[] table = (Entry<T>[]) new Entry<?>[size];
return table;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cast to Entry<T>[] on line 301 will trigger an unchecked cast warning. To fully achieve the goal of reducing warning noise, please add @SuppressWarnings("unchecked") to this helper method.

Suggested change
private static <T> Entry<T>[] newTable(int size) {
Entry<T>[] table = (Entry<T>[]) new Entry<?>[size];
return table;
}
@SuppressWarnings("unchecked")
private static <T> Entry<T>[] newTable(int size) {
return (Entry<T>[]) new Entry<?>[size];
}

public Entry<String, JsonElement>[] entrySet() {
Set<Entry<String, com.google.gson.JsonElement>> entrySet = obj().entrySet();
Entry<String, JsonElement>[] entries = new Entry[entrySet.size()];
Entry<String, JsonElement>[] entries = (Entry<String, JsonElement>[]) new Entry<?, ?>[entrySet.size()];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This generic array creation and cast will result in an unchecked warning. It is recommended to add @SuppressWarnings("unchecked") to the method or the assignment to silence the warning, consistent with the PR's objective.

Suggested change
Entry<String, JsonElement>[] entries = (Entry<String, JsonElement>[]) new Entry<?, ?>[entrySet.size()];
@SuppressWarnings("unchecked")
Entry<String, JsonElement>[] entries = (Entry<String, JsonElement>[]) new Entry<?, ?>[entrySet.size()];

@8Keep 8Keep marked this pull request as draft April 8, 2026 00:06
@8Keep 8Keep force-pushed the warning-fixes branch 2 times, most recently from c7260b8 to 8b7d21a Compare April 8, 2026 00:07
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

🖼️ Screenshot tests have failed.

The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests.

📄 Where to find the report:

  • Go to the (failed run) > Summary > Artifacts > screenshot-test-report
  • Download the zip and open jme3-screenshot-tests/build/reports/ScreenshotDiffReport.html

⚠️ If you didn't expect to change anything visual:
Fix your changes so the screenshot tests pass.

If you did mean to change things:
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.

If you are creating entirely new tests:
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.

Note; it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar".

See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information

Contact @richardTingle (aka richtea) for guidance if required

@8Keep 8Keep changed the title Reduce Gradle and Android warning noise Reduce warning noise Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant