Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Some elements cause a nullpoint in generated editor
Some elements cause a nullpoint in generated editor [message #479814] Wed, 12 August 2009 15:08 Go to next message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Hello @all,

i've figured out a really weird behavior of the generated editor. I have
some trivial containment references, but when i add some specific
elements, the following stack trace is thrown, which has the effect,
that no combo box will be opened any more. Even the validation dialog
will not be shown. If i remove the error-causing element, everything
works fine.

java.lang.NullPointerException
at
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
at
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
at
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
at
org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
at
org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
at
org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
at
org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
at
org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
at
org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
at
org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)

Strange ... :(

Marc-Florian
Re: Some elements cause a nullpoint in generated editor [message #479815 is a reply to message #479814] Wed, 12 August 2009 15:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Marc-Florian,

Comments below.

Marc-Florian Wendland wrote:
> Hello @all,
>
> i've figured out a really weird behavior of the generated editor. I
> have some trivial containment references, but when i add some specific
> elements, the following stack trace is thrown, which has the effect,
> that no combo box will be opened any more. Even the validation dialog
> will not be shown. If i remove the error-causing element, everything
> works fine.
>
> java.lang.NullPointerException
> at
> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>
I don't see anything interesting, i.e., no code, at this line in the
latest version...
> at
> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>
> at
> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>
> at
> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>
> at
> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>
> at
> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>
> at
> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>
> at
> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>
> at
> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>
> at
> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
>
> Strange ... :(
What does the debugger have to say about the cause?
>
> Marc-Florian


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Some elements cause a nullpoint in generated editor [message #480067 is a reply to message #479815] Thu, 13 August 2009 16:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Ed,

here is the code. I've highlighted the location:

######################
/**
* This will visit all reachable references from object except those
in visited and add them to the queue.
* The queue is processed outside this recursive traversal to avoid
stack overflows.
* It updates visited and adds to result any object with a meta
object that indicates that it is a subtype of type.
*/
static private void collectReachableObjectsOfType
(Collection<EObject> visited, LinkedList<EObject> itemQueue,
Collection<EObject> result, EObject object, EClassifier type)
{
if (visited.add(object))
{
if (type.isInstance(object))
{
result.add(object);
}

EClass eClass = object.eClass(); ==========> NullPointer !!!!
for (EStructuralFeature eStructuralFeature :
eClass.getEAllStructuralFeatures())
{
if (!eStructuralFeature.isDerived())
{
if (eStructuralFeature instanceof EReference)
{
EReference eReference = (EReference)eStructuralFeature;
if (eReference.isMany())
{
@SuppressWarnings("unchecked")
List<EObject> list =
((List<EObject>)object.eGet(eReference));
itemQueue.addAll(list);
}
else
{
EObject eObject = (EObject)object.eGet(eReference);
if (eObject != null)
{
itemQueue.addLast(eObject);
}
}
}
else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
{
for (FeatureMap.Entry entry :
(FeatureMap)object.eGet(eStructuralFeature))
{
if (entry.getEStructuralFeature() instanceof EReference
&& entry.getValue() != null)
{
itemQueue.addLast((EObject)entry.getValue());
}
}
}
}
}
}
}
###################################

Object has to be the model object, for which i tried to open a reference
combo box. But it is null... hope this helps.

Marc-Florian

Ed Merks schrieb:
> Marc-Florian,
>
> Comments below.
>
> Marc-Florian Wendland wrote:
>> Hello @all,
>>
>> i've figured out a really weird behavior of the generated editor. I
>> have some trivial containment references, but when i add some specific
>> elements, the following stack trace is thrown, which has the effect,
>> that no combo box will be opened any more. Even the validation dialog
>> will not be shown. If i remove the error-causing element, everything
>> works fine.
>>
>> java.lang.NullPointerException
>> at
>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>>
> I don't see anything interesting, i.e., no code, at this line in the
> latest version...
>> at
>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>>
>> at
>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>>
>> at
>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>>
>> at
>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>>
>> at
>> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>>
>> at
>> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>>
>> at
>> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>>
>> at
>> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>>
>> at
>> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>>
>> at
>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
>> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>>
>> Strange ... :(
> What does the debugger have to say about the cause?
>>
>> Marc-Florian
Re: Some elements cause a nullpoint in generated editor [message #480071 is a reply to message #480067] Thu, 13 August 2009 16:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Marc-Florian,

Step into it. It shouldn't be possible to return null unless something
is seriously wrong with your EPackage...

Marc-Florian Wendland wrote:
> Ed,
>
> here is the code. I've highlighted the location:
>
> ######################
> /**
> * This will visit all reachable references from object except those
> in visited and add them to the queue.
> * The queue is processed outside this recursive traversal to avoid
> stack overflows.
> * It updates visited and adds to result any object with a meta
> object that indicates that it is a subtype of type.
> */
> static private void collectReachableObjectsOfType
> (Collection<EObject> visited, LinkedList<EObject> itemQueue,
> Collection<EObject> result, EObject object, EClassifier type)
> {
> if (visited.add(object))
> {
> if (type.isInstance(object))
> {
> result.add(object);
> }
>
> EClass eClass = object.eClass(); ==========> NullPointer !!!!
> for (EStructuralFeature eStructuralFeature :
> eClass.getEAllStructuralFeatures())
> {
> if (!eStructuralFeature.isDerived())
> {
> if (eStructuralFeature instanceof EReference)
> {
> EReference eReference = (EReference)eStructuralFeature;
> if (eReference.isMany())
> {
> @SuppressWarnings("unchecked")
> List<EObject> list =
> ((List<EObject>)object.eGet(eReference));
> itemQueue.addAll(list);
> }
> else
> {
> EObject eObject = (EObject)object.eGet(eReference);
> if (eObject != null)
> {
> itemQueue.addLast(eObject);
> }
> }
> }
> else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
> {
> for (FeatureMap.Entry entry :
> (FeatureMap)object.eGet(eStructuralFeature))
> {
> if (entry.getEStructuralFeature() instanceof EReference
> && entry.getValue() != null)
> {
> itemQueue.addLast((EObject)entry.getValue());
> }
> }
> }
> }
> }
> }
> }
> ###################################
>
> Object has to be the model object, for which i tried to open a
> reference combo box. But it is null... hope this helps.
>
> Marc-Florian
>
> Ed Merks schrieb:
>> Marc-Florian,
>>
>> Comments below.
>>
>> Marc-Florian Wendland wrote:
>>> Hello @all,
>>>
>>> i've figured out a really weird behavior of the generated editor. I
>>> have some trivial containment references, but when i add some
>>> specific elements, the following stack trace is thrown, which has
>>> the effect, that no combo box will be opened any more. Even the
>>> validation dialog will not be shown. If i remove the error-causing
>>> element, everything works fine.
>>>
>>> java.lang.NullPointerException
>>> at
>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>>>
>> I don't see anything interesting, i.e., no code, at this line in the
>> latest version...
>>> at
>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>>>
>>> at
>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>>>
>>> at
>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>>>
>>> at
>>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>>>
>>> at
>>> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>>>
>>> at
>>> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>>>
>>> at
>>> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>>>
>>> at
>>> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>>>
>>> at
>>> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>>>
>>> at
>>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
>>>
>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
>>> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
>>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
>>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>>
>>> Strange ... :(
>> What does the debugger have to say about the cause?
>>>
>>> Marc-Florian


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Some elements cause a nullpoint in generated editor [message #480217 is a reply to message #480071] Fri, 14 August 2009 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Ed,

i've found out, that only subclasses of a particular abstract class
causes the exception. The structure was as following:

########
Element extends NamedElement
+fragment 0..*

Fragment extends NamedElement {abstract}

Occurrence extends Fragment {abstract}
+some specifc referenced

TimeOcurence extends Occurrence
...
########

Onl subclasses of Occurrence have shown the excpetional behavior. After
removing it compeletely from the package, it works, but no i have to
diverse all the references of Occurrence in all its subclasses (quite a
lot). I'm so curious, why Occurrence behaves like this?!

Marc-Florian





Ed Merks schrieb:
> Marc-Florian,
>
> Step into it. It shouldn't be possible to return null unless something
> is seriously wrong with your EPackage...
>
> Marc-Florian Wendland wrote:
>> Ed,
>>
>> here is the code. I've highlighted the location:
>>
>> ######################
>> /**
>> * This will visit all reachable references from object except those
>> in visited and add them to the queue.
>> * The queue is processed outside this recursive traversal to avoid
>> stack overflows.
>> * It updates visited and adds to result any object with a meta
>> object that indicates that it is a subtype of type.
>> */
>> static private void collectReachableObjectsOfType
>> (Collection<EObject> visited, LinkedList<EObject> itemQueue,
>> Collection<EObject> result, EObject object, EClassifier type)
>> {
>> if (visited.add(object))
>> {
>> if (type.isInstance(object))
>> {
>> result.add(object);
>> }
>>
>> EClass eClass = object.eClass(); ==========> NullPointer !!!!
>> for (EStructuralFeature eStructuralFeature :
>> eClass.getEAllStructuralFeatures())
>> {
>> if (!eStructuralFeature.isDerived())
>> {
>> if (eStructuralFeature instanceof EReference)
>> {
>> EReference eReference = (EReference)eStructuralFeature;
>> if (eReference.isMany())
>> {
>> @SuppressWarnings("unchecked")
>> List<EObject> list =
>> ((List<EObject>)object.eGet(eReference));
>> itemQueue.addAll(list);
>> }
>> else
>> {
>> EObject eObject = (EObject)object.eGet(eReference);
>> if (eObject != null)
>> {
>> itemQueue.addLast(eObject);
>> }
>> }
>> }
>> else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
>> {
>> for (FeatureMap.Entry entry :
>> (FeatureMap)object.eGet(eStructuralFeature))
>> {
>> if (entry.getEStructuralFeature() instanceof EReference
>> && entry.getValue() != null)
>> {
>> itemQueue.addLast((EObject)entry.getValue());
>> }
>> }
>> }
>> }
>> }
>> }
>> }
>> ###################################
>>
>> Object has to be the model object, for which i tried to open a
>> reference combo box. But it is null... hope this helps.
>>
>> Marc-Florian
>>
>> Ed Merks schrieb:
>>> Marc-Florian,
>>>
>>> Comments below.
>>>
>>> Marc-Florian Wendland wrote:
>>>> Hello @all,
>>>>
>>>> i've figured out a really weird behavior of the generated editor. I
>>>> have some trivial containment references, but when i add some
>>>> specific elements, the following stack trace is thrown, which has
>>>> the effect, that no combo box will be opened any more. Even the
>>>> validation dialog will not be shown. If i remove the error-causing
>>>> element, everything works fine.
>>>>
>>>> java.lang.NullPointerException
>>>> at
>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>>>>
>>> I don't see anything interesting, i.e., no code, at this line in the
>>> latest version...
>>>> at
>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>>>>
>>>> at
>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>>>>
>>>> at
>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>>>>
>>>> at
>>>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>>>>
>>>> at
>>>> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>>>>
>>>> at
>>>> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>>>>
>>>> at
>>>> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>>>>
>>>> at
>>>> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>>>>
>>>> at
>>>> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>>>>
>>>> at
>>>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
>>>>
>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
>>>> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
>>>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
>>>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>>>> at
>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>
>>>>
>>>> Strange ... :(
>>> What does the debugger have to say about the cause?
>>>>
>>>> Marc-Florian
Re: Some elements cause a nullpoint in generated editor [message #480439 is a reply to message #480217] Mon, 17 August 2009 07:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Marc-Florian,

I've never seen eClass() return null. Did you step through the logic for
that call to see what's going on?


Marc-Florian Wendland schrieb:
> Ed,
>
> i've found out, that only subclasses of a particular abstract class
> causes the exception. The structure was as following:
>
> ########
> Element extends NamedElement
> +fragment 0..*
>
> Fragment extends NamedElement {abstract}
>
> Occurrence extends Fragment {abstract}
> +some specifc referenced
>
> TimeOcurence extends Occurrence
> ...
> ########
>
> Onl subclasses of Occurrence have shown the excpetional behavior. After
> removing it compeletely from the package, it works, but no i have to
> diverse all the references of Occurrence in all its subclasses (quite a
> lot). I'm so curious, why Occurrence behaves like this?!
>
> Marc-Florian
>
>
>
>
>
> Ed Merks schrieb:
>> Marc-Florian,
>>
>> Step into it. It shouldn't be possible to return null unless
>> something is seriously wrong with your EPackage...
>>
>> Marc-Florian Wendland wrote:
>>> Ed,
>>>
>>> here is the code. I've highlighted the location:
>>>
>>> ######################
>>> /**
>>> * This will visit all reachable references from object except
>>> those in visited and add them to the queue.
>>> * The queue is processed outside this recursive traversal to avoid
>>> stack overflows.
>>> * It updates visited and adds to result any object with a meta
>>> object that indicates that it is a subtype of type.
>>> */
>>> static private void collectReachableObjectsOfType
>>> (Collection<EObject> visited, LinkedList<EObject> itemQueue,
>>> Collection<EObject> result, EObject object, EClassifier type)
>>> {
>>> if (visited.add(object))
>>> {
>>> if (type.isInstance(object))
>>> {
>>> result.add(object);
>>> }
>>>
>>> EClass eClass = object.eClass(); ==========> NullPointer !!!!
>>> for (EStructuralFeature eStructuralFeature :
>>> eClass.getEAllStructuralFeatures())
>>> {
>>> if (!eStructuralFeature.isDerived())
>>> {
>>> if (eStructuralFeature instanceof EReference)
>>> {
>>> EReference eReference = (EReference)eStructuralFeature;
>>> if (eReference.isMany())
>>> {
>>> @SuppressWarnings("unchecked")
>>> List<EObject> list =
>>> ((List<EObject>)object.eGet(eReference));
>>> itemQueue.addAll(list);
>>> }
>>> else
>>> {
>>> EObject eObject = (EObject)object.eGet(eReference);
>>> if (eObject != null)
>>> {
>>> itemQueue.addLast(eObject);
>>> }
>>> }
>>> }
>>> else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
>>> {
>>> for (FeatureMap.Entry entry :
>>> (FeatureMap)object.eGet(eStructuralFeature))
>>> {
>>> if (entry.getEStructuralFeature() instanceof EReference
>>> && entry.getValue() != null)
>>> {
>>> itemQueue.addLast((EObject)entry.getValue());
>>> }
>>> }
>>> }
>>> }
>>> }
>>> }
>>> }
>>> ###################################
>>>
>>> Object has to be the model object, for which i tried to open a
>>> reference combo box. But it is null... hope this helps.
>>>
>>> Marc-Florian
>>>
>>> Ed Merks schrieb:
>>>> Marc-Florian,
>>>>
>>>> Comments below.
>>>>
>>>> Marc-Florian Wendland wrote:
>>>>> Hello @all,
>>>>>
>>>>> i've figured out a really weird behavior of the generated editor. I
>>>>> have some trivial containment references, but when i add some
>>>>> specific elements, the following stack trace is thrown, which has
>>>>> the effect, that no combo box will be opened any more. Even the
>>>>> validation dialog will not be shown. If i remove the error-causing
>>>>> element, everything works fine.
>>>>>
>>>>> java.lang.NullPointerException
>>>>> at
>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>>>>>
>>>> I don't see anything interesting, i.e., no code, at this line in the
>>>> latest version...
>>>>> at
>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>>>>>
>>>>> at
>>>>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
>>>>>
>>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
>>>>> at
>>>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
>>>>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
>>>>> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>>>>> at
>>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>>
>>>>>
>>>>> Strange ... :(
>>>> What does the debugger have to say about the cause?
>>>>>
>>>>> Marc-Florian


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Some elements cause a nullpoint in generated editor [message #480455 is a reply to message #480439] Mon, 17 August 2009 08:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: florianwendland.freenet.de

Ed,

it is not the eClass(), which is returning null. The acutal variable
"EObject object" is null. A method call null.eClass() causes of course
an exception. But only, if the model's structure is like the one
below... without Occurrence, it works fine... very strange, may be you
got an idea?!

Marc-Florian

Ed Merks schrieb:
> Marc-Florian,
>
> I've never seen eClass() return null. Did you step through the logic for
> that call to see what's going on?
>
>
> Marc-Florian Wendland schrieb:
>> Ed,
>>
>> i've found out, that only subclasses of a particular abstract class
>> causes the exception. The structure was as following:
>>
>> ########
>> Element extends NamedElement
>> +fragment 0..*
>>
>> Fragment extends NamedElement {abstract}
>>
>> Occurrence extends Fragment {abstract}
>> +some specifc referenced
>>
>> TimeOcurence extends Occurrence
>> ...
>> ########
>>
>> Onl subclasses of Occurrence have shown the excpetional behavior.
>> After removing it compeletely from the package, it works, but no i
>> have to diverse all the references of Occurrence in all its subclasses
>> (quite a lot). I'm so curious, why Occurrence behaves like this?!
>>
>> Marc-Florian
>>
>>
>>
>>
>> Ed Merks schrieb:
>>> Marc-Florian,
>>>
>>> Step into it. It shouldn't be possible to return null unless
>>> something is seriously wrong with your EPackage...
>>>
>>> Marc-Florian Wendland wrote:
>>>> Ed,
>>>>
>>>> here is the code. I've highlighted the location:
>>>>
>>>> ######################
>>>> /**
>>>> * This will visit all reachable references from object except
>>>> those in visited and add them to the queue.
>>>> * The queue is processed outside this recursive traversal to
>>>> avoid stack overflows.
>>>> * It updates visited and adds to result any object with a meta
>>>> object that indicates that it is a subtype of type.
>>>> */
>>>> static private void collectReachableObjectsOfType
>>>> (Collection<EObject> visited, LinkedList<EObject> itemQueue,
>>>> Collection<EObject> result, EObject object, EClassifier type)
>>>> {
>>>> if (visited.add(object))
>>>> {
>>>> if (type.isInstance(object))
>>>> {
>>>> result.add(object);
>>>> }
>>>>
>>>> EClass eClass = object.eClass(); ==========> NullPointer !!!!
>>>> for (EStructuralFeature eStructuralFeature :
>>>> eClass.getEAllStructuralFeatures())
>>>> {
>>>> if (!eStructuralFeature.isDerived())
>>>> {
>>>> if (eStructuralFeature instanceof EReference)
>>>> {
>>>> EReference eReference = (EReference)eStructuralFeature;
>>>> if (eReference.isMany())
>>>> {
>>>> @SuppressWarnings("unchecked")
>>>> List<EObject> list =
>>>> ((List<EObject>)object.eGet(eReference));
>>>> itemQueue.addAll(list);
>>>> }
>>>> else
>>>> {
>>>> EObject eObject = (EObject)object.eGet(eReference);
>>>> if (eObject != null)
>>>> {
>>>> itemQueue.addLast(eObject);
>>>> }
>>>> }
>>>> }
>>>> else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
>>>> {
>>>> for (FeatureMap.Entry entry :
>>>> (FeatureMap)object.eGet(eStructuralFeature))
>>>> {
>>>> if (entry.getEStructuralFeature() instanceof
>>>> EReference && entry.getValue() != null)
>>>> {
>>>> itemQueue.addLast((EObject)entry.getValue());
>>>> }
>>>> }
>>>> }
>>>> }
>>>> }
>>>> }
>>>> }
>>>> ###################################
>>>>
>>>> Object has to be the model object, for which i tried to open a
>>>> reference combo box. But it is null... hope this helps.
>>>>
>>>> Marc-Florian
>>>>
>>>> Ed Merks schrieb:
>>>>> Marc-Florian,
>>>>>
>>>>> Comments below.
>>>>>
>>>>> Marc-Florian Wendland wrote:
>>>>>> Hello @all,
>>>>>>
>>>>>> i've figured out a really weird behavior of the generated editor.
>>>>>> I have some trivial containment references, but when i add some
>>>>>> specific elements, the following stack trace is thrown, which has
>>>>>> the effect, that no combo box will be opened any more. Even the
>>>>>> validation dialog will not be shown. If i remove the error-causing
>>>>>> element, everything works fine.
>>>>>>
>>>>>> java.lang.NullPointerException
>>>>>> at
>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>>>>>>
>>>>> I don't see anything interesting, i.e., no code, at this line in
>>>>> the latest version...
>>>>>> at
>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>>>>>>
>>>>>> at
>>>>>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
>>>>>>
>>>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
>>>>>> at
>>>>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
>>>>>> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
>>>>>> at
>>>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>>>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>>>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>>>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>>>>>> at
>>>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>>>
>>>>>>
>>>>>> Strange ... :(
>>>>> What does the debugger have to say about the cause?
>>>>>>
>>>>>> Marc-Florian
Re: Some elements cause a nullpoint in generated editor [message #480458 is a reply to message #480455] Mon, 17 August 2009 09:04 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Marc-Florian,

I don't expect null to ever be visited. Perhaps there was a bug that was
fixed a few years back. What version of EMF are you using?

Marc-Florian Wendland schrieb:
> Ed,
>
> it is not the eClass(), which is returning null. The acutal variable
> "EObject object" is null. A method call null.eClass() causes of course
> an exception. But only, if the model's structure is like the one
> below... without Occurrence, it works fine... very strange, may be you
> got an idea?!
>
> Marc-Florian
>
> Ed Merks schrieb:
>> Marc-Florian,
>>
>> I've never seen eClass() return null. Did you step through the logic
>> for that call to see what's going on?
>>
>>
>> Marc-Florian Wendland schrieb:
>>> Ed,
>>>
>>> i've found out, that only subclasses of a particular abstract class
>>> causes the exception. The structure was as following:
>>>
>>> ########
>>> Element extends NamedElement
>>> +fragment 0..*
>>>
>>> Fragment extends NamedElement {abstract}
>>>
>>> Occurrence extends Fragment {abstract}
>>> +some specifc referenced
>>>
>>> TimeOcurence extends Occurrence
>>> ...
>>> ########
>>>
>>> Onl subclasses of Occurrence have shown the excpetional behavior.
>>> After removing it compeletely from the package, it works, but no i
>>> have to diverse all the references of Occurrence in all its
>>> subclasses (quite a lot). I'm so curious, why Occurrence behaves like
>>> this?!
>>>
>>> Marc-Florian
>>>
>>>
>>>
>>> Ed Merks schrieb:
>>>> Marc-Florian,
>>>>
>>>> Step into it. It shouldn't be possible to return null unless
>>>> something is seriously wrong with your EPackage...
>>>>
>>>> Marc-Florian Wendland wrote:
>>>>> Ed,
>>>>>
>>>>> here is the code. I've highlighted the location:
>>>>>
>>>>> ######################
>>>>> /**
>>>>> * This will visit all reachable references from object except
>>>>> those in visited and add them to the queue.
>>>>> * The queue is processed outside this recursive traversal to
>>>>> avoid stack overflows.
>>>>> * It updates visited and adds to result any object with a meta
>>>>> object that indicates that it is a subtype of type.
>>>>> */
>>>>> static private void collectReachableObjectsOfType
>>>>> (Collection<EObject> visited, LinkedList<EObject> itemQueue,
>>>>> Collection<EObject> result, EObject object, EClassifier type)
>>>>> {
>>>>> if (visited.add(object))
>>>>> {
>>>>> if (type.isInstance(object))
>>>>> {
>>>>> result.add(object);
>>>>> }
>>>>>
>>>>> EClass eClass = object.eClass(); ==========> NullPointer !!!!
>>>>> for (EStructuralFeature eStructuralFeature :
>>>>> eClass.getEAllStructuralFeatures())
>>>>> {
>>>>> if (!eStructuralFeature.isDerived())
>>>>> {
>>>>> if (eStructuralFeature instanceof EReference)
>>>>> {
>>>>> EReference eReference = (EReference)eStructuralFeature;
>>>>> if (eReference.isMany())
>>>>> {
>>>>> @SuppressWarnings("unchecked")
>>>>> List<EObject> list =
>>>>> ((List<EObject>)object.eGet(eReference));
>>>>> itemQueue.addAll(list);
>>>>> }
>>>>> else
>>>>> {
>>>>> EObject eObject = (EObject)object.eGet(eReference);
>>>>> if (eObject != null)
>>>>> {
>>>>> itemQueue.addLast(eObject);
>>>>> }
>>>>> }
>>>>> }
>>>>> else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
>>>>> {
>>>>> for (FeatureMap.Entry entry :
>>>>> (FeatureMap)object.eGet(eStructuralFeature))
>>>>> {
>>>>> if (entry.getEStructuralFeature() instanceof
>>>>> EReference && entry.getValue() != null)
>>>>> {
>>>>> itemQueue.addLast((EObject)entry.getValue());
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>> ###################################
>>>>>
>>>>> Object has to be the model object, for which i tried to open a
>>>>> reference combo box. But it is null... hope this helps.
>>>>>
>>>>> Marc-Florian
>>>>>
>>>>> Ed Merks schrieb:
>>>>>> Marc-Florian,
>>>>>>
>>>>>> Comments below.
>>>>>>
>>>>>> Marc-Florian Wendland wrote:
>>>>>>> Hello @all,
>>>>>>>
>>>>>>> i've figured out a really weird behavior of the generated editor.
>>>>>>> I have some trivial containment references, but when i add some
>>>>>>> specific elements, the following stack trace is thrown, which has
>>>>>>> the effect, that no combo box will be opened any more. Even the
>>>>>>> validation dialog will not be shown. If i remove the
>>>>>>> error-causing element, everything works fine.
>>>>>>>
>>>>>>> java.lang.NullPointerException
>>>>>>> at
>>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.collect ReachableObjectsOfType(ItemPropertyDescriptor.java:919)
>>>>>>>
>>>>>> I don't see anything interesting, i.e., no code, at this line in
>>>>>> the latest version...
>>>>>>> at
>>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getReac hableObjectsOfType(ItemPropertyDescriptor.java:883)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getComb oBoxObjects(ItemPropertyDescriptor.java:806)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.edit.provider.ItemPropertyDescriptor.getChoi ceOfValues(ItemPropertyDescriptor.java:1459)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.emf.edit.ui.provider.PropertyDescriptor.createPr opertyEditor(PropertyDescriptor.java:428)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.ui.views.properties.PropertySheetEntry.getEditor (PropertySheetEntry.java:378)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.activate CellEditor(PropertySheetViewer.java:163)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.handleSe lect(PropertySheetViewer.java:729)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer.access$8 (PropertySheetViewer.java:707)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.ui.views.properties.PropertySheetViewer$6.mouseD own(PropertySheetViewer.java:817)
>>>>>>>
>>>>>>> at
>>>>>>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:179)
>>>>>>>
>>>>>>> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
>>>>>>> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
>>>>>>> at
>>>>>>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
>>>>>>> at
>>>>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
>>>>>>> at
>>>>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
>>>>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
>>>>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
>>>>>>> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
>>>>>>> at
>>>>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>>>>
>>>>>>>
>>>>>>> Strange ... :(
>>>>>> What does the debugger have to say about the cause?
>>>>>>>
>>>>>>> Marc-Florian


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Default new object/action - no wizard - file in root directory
Next Topic:Extend a metamodel
Goto Forum:
  


Current Time: Fri Mar 29 09:37:03 GMT 2024

Powered by FUDForum. Page generated in 0.06653 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top