This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 27058 - MDR Libraries since 2002-08-31 and later are not backwards compatible
Summary: MDR Libraries since 2002-08-31 and later are not backwards compatible
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P1 blocker (vote)
Assignee: Martin Matula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-05 16:14 UTC by Jens Fransson
Modified: 2002-09-15 14:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Fransson 2002-09-05 16:14:08 UTC
Hi!

Today I checked out and built the latest Netbeans/MDR cvs 
version. The last one I used till then was dated 2002-08-
01. With the new version (dated 2002-08-31 and 2002-09-
05), the following code does no longer work:


  MofPackage m2UmlPackage = (MofPackage) 
MdrUtil.findModelElement(
      m2Model, "UML", MofPackage.class, null
    );



  public static ModelElement findModelElement(
    final javax.jmi.model.ModelPackage modelPackage,
    final String name, final Class type,
    final javax.jmi.model.Namespace container)
  {
    javax.jmi.model.ModelElement m = null;
    Iterator i = modelPackage.getModelElement
().refAllOfType().iterator();
    if (i != null) {
      for (; i.hasNext(); m = 
(javax.jmi.model.ModelElement) i.next()) {
        if (m != null) {
          if ((type.isInstance(m)) && name.equals(m.getName
())) {
            if (container == null) return m;
            if (container == m.getContainer()) return m;
          }
        }
      }
    }
    throw new RuntimeException("ModelElement "
      + "[Name = '" + name + "', "
      + "Class = '" + type + "', "
      + "Container = '" + container + "'] not found!");
  }


The method findModelElement() does not find any longer the 
MofPackage named "UML" from the UML 1.4 diff XMI file. It 
now throws an exception.

Regards,
Jens
____________________________________________
| Jens Fransson
| University of Hamburg
| Department of Computer Science
| Vogt-Koeln-Str. 30
| 22527 Hamburg, Germany
| E-Mail: 3fransso@informatik.uni-hamburg.de
Comment 1 Martin Matula 2002-09-05 16:40:13 UTC
Hi Jens,
I've tried the code and it worked for me after rebooting the
repository. We made significant changes to the repository storage
which resulted in the storage not being backwards compatible and even
our mechanisms for autorebooting did not work as the change we made
was too deep.
Keeping MDR storage backward compatible is not a requirement for MDR
since the storage contains only derived data - MDR should not be used
to store primary data - the primary data should be stored in source
files/XMI files and the MDR serves only as a cache for them.
Please confirm that after deleting the storage files (thus forcing the
reboot of the storage manually) the problems still presist.
Comment 2 Martin Matula 2002-09-13 16:08:12 UTC
I suppose that it is working for you now (after 
rebooting?), since you haven't reply my last message.
Comment 3 Jens Fransson 2002-09-14 15:54:26 UTC
Hi Martin!

Indeed it is the case that the problem persists when 
deleting the repository. 
I always delete the repository and force it to reboot, 
loading any needed contents from XMI. 
It must be another problem.

I find the problem severe (P1) as I am disconnected from 
the actual MDR evolvement because I am forced to use an 
old version.

Regards,
Jens
Comment 4 Martin Matula 2002-09-15 14:16:03 UTC
Hi Jens, there is a very stupid bug in your code. Your code does not
iterate through the last element of the iterator. First time it
iterates through null (that's why you needed to put if (m != null) to
your code, which is normaly not necessary), then through the all the
elements of the iterator but the last one.
Try using:    
    for (; i.hasNext();) {
        m = (javax.jmi.model.ModelElement) i.next());
        ...
    }
instead of:
    for (; i.hasNext(); m = (javax.jmi.model.ModelElement) i.next()) {
        if (m != null) {
            ...
        }
    }

Also I recommend you to not use your custom lookup. Just delete the
lookup class. Openide library (since NB 3.4) already contains a
default implementation of lookup which is able to resolve all the
needed instances (registered in meta-inf folder of jars - see e.g.
jmiutils.jar)