Skip to content

Add AssetManager.reloadAsset for development-time asset refresh#2860

Closed
Dingyi189-eng wants to merge 1 commit into
jMonkeyEngine:masterfrom
Dingyi189-eng:feature-asset-reload-api
Closed

Add AssetManager.reloadAsset for development-time asset refresh#2860
Dingyi189-eng wants to merge 1 commit into
jMonkeyEngine:masterfrom
Dingyi189-eng:feature-asset-reload-api

Conversation

@Dingyi189-eng

Copy link
Copy Markdown

No description provided.

Co-authored-by: Cursor <cursoragent@cursor.com>

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

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.

Code Review

This pull request introduces a mechanism to reload assets from locators and notify listeners by adding a reloadAsset method to the AssetManager interface and a corresponding assetReloaded event to AssetEventListener. The review feedback correctly highlights that adding an abstract method to the AssetManager interface breaks backward compatibility for custom implementations, and suggests making it a default method instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

* @throws IllegalArgumentException If the key is null or specifies no cache
* @throws AssetNotFoundException If the asset cannot be located
*/
public <T> T reloadAsset(AssetKey<T> key);

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

Adding a new abstract method to the AssetManager interface will break backward compatibility for any custom implementations of AssetManager (as they will fail to compile until they implement reloadAsset).

To maintain backward compatibility, consider making reloadAsset a default method. You can either:

  1. Provide a default implementation that performs the basic reload (though it won't be able to notify listeners since the interface doesn't expose them):
public default <T> T reloadAsset(AssetKey<T> key) {
    if (key == null) {
        throw new IllegalArgumentException("key cannot be null");
    }
    deleteFromCache(key);
    return loadAsset(key);
}
  1. Or simply throw an UnsupportedOperationException:
public default <T> T reloadAsset(AssetKey<T> key) {
    throw new UnsupportedOperationException("reloadAsset is not supported by this AssetManager implementation");
}

@riccardobl riccardobl added the slop only the finest ai slop label Jun 9, 2026
@riccardobl riccardobl closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

slop only the finest ai slop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants