Skip to content

List of problematic code on non-standard jvms #2551

@riccardobl

Description

@riccardobl

I will use this issue to compile a list of code that requires workarounds when running the engine on non fully-compliant or non fully-reflective jvms.
Some of these instances are legacy reflect code that, with the newer paradigms and changing expectations, could be easily rewritten in non reflective java.

PS. If you know other instances of problematic code, feel free to comment with your findings.

Problematic Reflection: DesktopAssetManager.loadConfigFile()

Loads a predefined list of locators and loaders from a .cfg file.
This could be rewritten by:

  • making JmeSystemDelegate.newAssetManager non-final, so platforms can register the very bare-minimum requirements (bitmap font loader for stats and resource locator).
  • creating a set of helpers classes that the developer can use to load additional stuff (eg. CoreLoaders.load(assetManager) ExtraLoaders.load(assetManager)...)

Problematic Reflection: Method calling Tweens

Might be replaced by a global map of named Runnables

Serialization: readExternal/writeExternal

Quaternions, Vectors and Matrices classes have serialization methods

readExternal(ObjectInput in)
writeExternal(ObjectOutput out)

that use the internal jvm serialization.
Afaik they are not used in the engine, and they cause issues with teavm that does not support the java native serialization.

GltfLoader CustomContentManager

public class CustomContentManager {
static volatile Class<? extends ExtrasLoader> defaultExtraLoaderClass = UserDataLoader.class;
private ExtrasLoader defaultExtraLoaderInstance;
private final static Logger logger = Logger.getLogger(CustomContentManager.class.getName());
private GltfModelKey key;
private GltfLoader gltfLoader;
static final Map<String, Class<? extends ExtensionLoader>> defaultExtensionLoaders = new ConcurrentHashMap<>();
static {
defaultExtensionLoaders.put("KHR_materials_pbrSpecularGlossiness", PBRSpecGlossExtensionLoader.class);
defaultExtensionLoaders.put("KHR_lights_punctual", LightsPunctualExtensionLoader.class);
defaultExtensionLoaders.put("KHR_materials_unlit", UnlitExtensionLoader.class);
defaultExtensionLoaders.put("KHR_texture_transform", TextureTransformExtensionLoader.class);
defaultExtensionLoaders.put("KHR_materials_emissive_strength", PBREmissiveStrengthExtensionLoader.class);
}
private final Map<String, ExtensionLoader> loadedExtensionLoaders = new HashMap<>();
public CustomContentManager() {

All the reflective instantiation of the extensions and extra loader here can be easily replaced with Suppliers.

Json

setParser could accept a parser object instead of a class

* a class that implements JsonParser
*/
public static void setParser(Class<? extends JsonParser> clazz) {
Json.clazz = clazz;
}

...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions