Problem with Features of Type Class [message #1855268] |
Wed, 05 October 2022 12:09 |
Thomas Kohler Messages: 3 Registered: June 2018 |
Junior Member |
|
|
Hello,
When using the type "Class" (any Java class) for a feature in an ECore Model null will be marshalled to "" for the xmi xml as defined in class org.eclipse.emf.ecore.impl.EcoreFactoryImpl:
public String convertEJavaClassToString(EDataType metaObject, Object instanceValue)
{
return instanceValue == null ? "" : ((Class<?>)instanceValue).getName();
}
The conterpart method:
public Class<?> createEJavaClassFromString(EDataType metaObject, String initialValue)
{
try
{
if (initialValue == null) return null;
else if ("boolean".equals(initialValue)) return boolean.class;
else if ("byte".equals(initialValue)) return byte.class;
else if ("char".equals(initialValue)) return char.class;
else if ("double".equals(initialValue)) return double.class;
else if ("float".equals(initialValue)) return float.class;
else if ("int".equals(initialValue)) return int.class;
else if ("long".equals(initialValue)) return long.class;
else if ("short".equals(initialValue)) return short.class;
else return Class.forName(initialValue);
}
catch (ClassNotFoundException e)
{
throw new WrappedException(e);
}
}
throws an Exception when trying to load a Class for name "". I think null instead of "" would be correct in convertEJavaClassToString.
It seems this is an inconistent implementation, we get an error in a ChangeDescription where a feature of type Class was set, the ChangeDescription stores "" which causes an error when we resume the ChangeRecorder.
Before someone asks: Yes, we store ChangeDescriptions. It works perfectlly, but now we have features of type Class the first time ...
If this is a bug, where is it possible to notify this?
Reagrds,
Tom
[Updated on: Wed, 05 October 2022 12:11] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01964 seconds