small fixes (improved logging in XMI tools, bugfix in bytecode generators, UML 1.3 diff fixed) BLD200210030100
authormmatula@netbeans.org
Wed, 02 Oct 2002 19:29:48 +0000
changeset 10639013e83e4b94
parent 1062 0efbe6adc5ab
child 1064 152f122b1662
small fixes (improved logging in XMI tools, bugfix in bytecode generators, UML 1.3 diff fixed)
addition of experimental action for generating skeletons of implementation classes
added to the mdrtoolkit.
mdr/src/org/netbeans/mdr/handlers/gen/ClassGenerator.java
mdr/src/org/netbeans/mdr/storagemodel/StorableAssociation.java
mdr/src/org/netbeans/mdr/storagemodel/StorableBaseObject.java
mdr/src/org/netbeans/mdr/storagemodel/StorableClass.java
mdr/src/org/netbeans/mdr/storagemodel/StorablePackage.java
mdr/src/org/netbeans/mdr/util/TransactionMutex.java
mdr/xmidiffs/01-12-02_Diff.xml
     1.1 --- a/mdr/src/org/netbeans/mdr/handlers/gen/ClassGenerator.java	Mon Sep 30 14:54:34 2002 +0000
     1.2 +++ b/mdr/src/org/netbeans/mdr/handlers/gen/ClassGenerator.java	Wed Oct 02 19:29:48 2002 +0000
     1.3 @@ -208,7 +208,7 @@
     1.4              out.writeByte(opc_aload_1);
     1.5              code_ipush(i, out);
     1.6              out.writeByte(opc_aaload);
     1.7 -            codeUnwrapArgument(attrs[i], out);
     1.8 +            codeUnwrapArgumentNull(attrs[i], out);
     1.9          }
    1.10          out.writeByte(opc_invokevirtual);
    1.11          out.writeShort(cp.getMethodRef(dotToSlash(className), name, getMethodDescriptor(attrs, type)));
    1.12 @@ -234,6 +234,38 @@
    1.13          return minfo;
    1.14      }
    1.15      
    1.16 +    protected void codeUnwrapArgumentNull(String typeName, DataOutputStream out) throws IOException {
    1.17 +        PrimitiveTypeInfo prim = PrimitiveTypeInfo.get(typeName);
    1.18 +        if (prim != null) {
    1.19 +            out.writeByte(opc_dup);
    1.20 +            out.writeByte(opc_ifnull);
    1.21 +            out.writeShort(12);
    1.22 +            
    1.23 +            out.writeByte(opc_checkcast);
    1.24 +            out.writeShort(cp.getClass(prim.wrapperClassName));
    1.25 +            
    1.26 +            out.writeByte(opc_invokevirtual);
    1.27 +            out.writeShort(cp.getMethodRef(
    1.28 +            prim.wrapperClassName,
    1.29 +            prim.unwrapMethodName, prim.unwrapMethodDesc));
    1.30 +            out.writeByte(opc_goto);
    1.31 +            out.writeShort(5);
    1.32 +            out.writeByte(opc_pop);
    1.33 +            if (typeName.equals("java.lang.Long")) {
    1.34 +                out.writeByte(opc_lconst_0);
    1.35 +            } else if (typeName.equals("java.lang.Double")) {
    1.36 +                out.writeByte(opc_dconst_0);
    1.37 +            } else if (typeName.equals("java.lang.Float")) {
    1.38 +                out.writeByte(opc_fconst_0);
    1.39 +            } else {
    1.40 +                out.writeByte(opc_iconst_0);
    1.41 +            }
    1.42 +        } else {
    1.43 +            out.writeByte(opc_checkcast);
    1.44 +            out.writeShort(cp.getClass(getParamType(typeName)));
    1.45 +        }
    1.46 +    }
    1.47 +    
    1.48      protected Collection getCreateMethod(String methodName, String[] parameterTypes, String returnType, String handlerName, String handlerDescriptor, String handlerType, String featureName) throws IOException {
    1.49          
    1.50          if (featureName != null) {
     2.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/StorableAssociation.java	Mon Sep 30 14:54:34 2002 +0000
     2.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/StorableAssociation.java	Wed Oct 02 19:29:48 2002 +0000
     2.3 @@ -150,8 +150,8 @@
     2.4          try {
     2.5              return BaseObjectHandler.resolveImplementation(TagSupport.getImplFullName(getMetaObject(), TagSupport.ASSOCIATION));
     2.6          } catch (ClassNotFoundException e) {
     2.7 -            if (((Boolean) getMetaObject().getAttribute(MOFConstants.SH_MODEL_ASSOCIATION_IS_DERIVED)).booleanValue())
     2.8 -                throw e;
     2.9 +//            if (((Boolean) getMetaObject().getAttribute(MOFConstants.SH_MODEL_ASSOCIATION_IS_DERIVED)).booleanValue())
    2.10 +//                throw e;
    2.11              return AssociationHandler.class;
    2.12          }
    2.13      }
     3.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/StorableBaseObject.java	Mon Sep 30 14:54:34 2002 +0000
     3.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/StorableBaseObject.java	Wed Oct 02 19:29:48 2002 +0000
     3.3 @@ -53,17 +53,10 @@
     3.4          initFinished = true;
     3.5      }
     3.6  
     3.7 -    /** Creates new StorableBaseObject passing all needed arguments.
     3.8 -     * @param mdrStorage parent storage
     3.9 -     * @param immediatePackage MOFID of immediate package
    3.10 -     * @param meta MOFID of metaobject
    3.11 -     * @param context context name
    3.12 -     * @throws StorageException problem in storage
    3.13 -     */
    3.14 -    StorableBaseObject(MdrStorage mdrStorage, org.netbeans.mdr.persistence.MOFID immediatePackage, org.netbeans.mdr.persistence.MOFID meta) throws StorageException {
    3.15 -        this (mdrStorage, immediatePackage, meta, null);
    3.16 +    StorableBaseObject (MdrStorage mdrStorage, org.netbeans.mdr.persistence.MOFID immediatePackage, org.netbeans.mdr.persistence.MOFID meta) throws StorageException {
    3.17 +        this(mdrStorage, immediatePackage, meta, null);
    3.18      }
    3.19 -    
    3.20 +
    3.21      StorableBaseObject (MdrStorage mdrStorage, org.netbeans.mdr.persistence.MOFID immediatePackage, org.netbeans.mdr.persistence.MOFID meta, String storageId) throws StorageException {
    3.22          initFinished = false;
    3.23          if (storageId == null) {
     4.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/StorableClass.java	Mon Sep 30 14:54:34 2002 +0000
     4.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/StorableClass.java	Wed Oct 02 19:29:48 2002 +0000
     4.3 @@ -80,10 +80,6 @@
     4.4       */
     4.5      private HashMap indexesByName;
     4.6      
     4.7 -    // mutexes
     4.8 -    private final Object attrMutex = new Object();
     4.9 -    private final Object superclassMutex = new Object();
    4.10 -
    4.11      /** Replaces MOFIDs using the passed map. (This method is used when rebuilding metaobjects.)
    4.12       * @param table Map of old MOFIDs to new MOFIDs.
    4.13       */
    4.14 @@ -428,21 +424,17 @@
    4.15          return descs;
    4.16      }
    4.17      
    4.18 -    private void checkAttributes() throws StorageException {
    4.19 +    private synchronized void checkAttributes() throws StorageException {
    4.20          if (attributes == null) {
    4.21 -            synchronized (attrMutex) {
    4.22 -                if (attributes == null) {
    4.23 -                    //Logger.getDefault().log("collecting attributes for: " + getMofId());
    4.24 -                    attributes = new ArrayList();
    4.25 -                    List attribDescs = new ArrayList();
    4.26 -                    indexDescriptors = new ArrayList();
    4.27 -                    collectAttributes(attributes, attribDescs, indexDescriptors, new HashSet());
    4.28 -                    this.attributeDescs = (AttributeDescriptor[])attribDescs.toArray(
    4.29 -                        new AttributeDescriptor[attribDescs.size()]);
    4.30 -                    buildIndexMap();
    4.31 -                } // if
    4.32 -            } // synchronized
    4.33 -        } // if
    4.34 +            //Logger.getDefault().log("collecting attributes for: " + getMofId());
    4.35 +            attributes = new ArrayList();
    4.36 +            List attribDescs = new ArrayList();
    4.37 +            indexDescriptors = new ArrayList();
    4.38 +            collectAttributes(attributes, attribDescs, indexDescriptors, new HashSet());
    4.39 +            this.attributeDescs = (AttributeDescriptor[])attribDescs.toArray(
    4.40 +                new AttributeDescriptor[attribDescs.size()]);
    4.41 +            buildIndexMap();
    4.42 +        }
    4.43      }
    4.44  
    4.45      private void collectAttributes(List attrs, List descs, List indexes, Set visited) throws StorageException {
    4.46 @@ -469,15 +461,11 @@
    4.47      /**
    4.48       * Returns the super-class for generated handler classes.
    4.49       */
    4.50 -    public Class getClassSuperclass() throws StorageException, ClassNotFoundException {
    4.51 +    public synchronized Class getClassSuperclass() throws StorageException, ClassNotFoundException {
    4.52          if (classSuperclass == null) {
    4.53 -            synchronized (superclassMutex) {
    4.54 -                if (classSuperclass == null) {
    4.55 -                    objectWillChange();
    4.56 -                    classSuperclass = resolveClassSuperclass(new Class[1]).getName();
    4.57 -                    objectChanged();
    4.58 -                }
    4.59 -            }
    4.60 +            objectWillChange();
    4.61 +            classSuperclass = resolveClassSuperclass(new Class[1]).getName();
    4.62 +            objectChanged();
    4.63          }
    4.64          return resolveClass(classSuperclass);
    4.65      }
    4.66 @@ -490,15 +478,11 @@
    4.67          return null;
    4.68      }
    4.69  
    4.70 -    public Class getInstanceSuperclass() throws StorageException, ClassNotFoundException {
    4.71 +    public synchronized Class getInstanceSuperclass() throws StorageException, ClassNotFoundException {
    4.72          if (instanceSuperclass == null) {
    4.73 -            synchronized (superclassMutex) {
    4.74 -                if (instanceSuperclass == null) {
    4.75 -                    objectWillChange();
    4.76 -                    instanceSuperclass = resolveInstanceSuperclass(new Class[1]).getName();
    4.77 -                    objectChanged();
    4.78 -                }
    4.79 -            }
    4.80 +            objectWillChange();
    4.81 +            instanceSuperclass = resolveInstanceSuperclass(new Class[1]).getName();
    4.82 +            objectChanged();
    4.83          }
    4.84          return resolveClass(instanceSuperclass);
    4.85      }
    4.86 @@ -546,8 +530,8 @@
    4.87              result = resolveClass(this, TagSupport.CLASS);
    4.88              iface[0] = resolveInterface(this, TagSupport.CLASS);
    4.89          } catch (ClassNotFoundException e) {
    4.90 -            if (classDerived)
    4.91 -                throw e;
    4.92 +//            if (classDerived)
    4.93 +//                throw e;
    4.94              Class current;
    4.95              Class currentIface[] = new Class[1];
    4.96              for (Iterator it = superclasses.iterator(); it.hasNext();) {
    4.97 @@ -584,8 +568,8 @@
    4.98              result = resolveClass(this, TagSupport.INSTANCE);
    4.99              iface[0] = resolveInterface(this, TagSupport.INSTANCE);
   4.100          } catch (ClassNotFoundException e) {
   4.101 -            if (instanceDerived)
   4.102 -                throw e;
   4.103 +//            if (instanceDerived)
   4.104 +//                throw e;
   4.105              Class current;
   4.106              Class currentIface[] = new Class[1];
   4.107              for (Iterator it = superclasses.iterator(); it.hasNext();) {
     5.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/StorablePackage.java	Mon Sep 30 14:54:34 2002 +0000
     5.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/StorablePackage.java	Wed Oct 02 19:29:48 2002 +0000
     5.3 @@ -31,8 +31,8 @@
     5.4      private Map assocProxies;
     5.5      private Map classProxies;
     5.6      private Map datatypes;
     5.7 +    private List superclasses;
     5.8      private Class packageSuperclass = null;
     5.9 -    private final Object superclassMutex = new Object();
    5.10      
    5.11      /** Replaces MOFIDs using the passed map. (This method is used when rebuilding metaobjects.)
    5.12       * @param table Map of old MOFIDs to new MOFIDs.
    5.13 @@ -50,26 +50,34 @@
    5.14      public StorablePackage(MdrStorage mdrStorage, org.netbeans.mdr.persistence.MOFID packageId, org.netbeans.mdr.persistence.MOFID metaId,
    5.15          String mofContext, Map datatypes, String storageId) throws StorageException {
    5.16          super (mdrStorage, packageId, metaId, storageId);
    5.17 -        this.init (packageId, mofContext, datatypes);
    5.18 +        objectWillChange();
    5.19 +        this.packageProxies = new HashMap();
    5.20 +        this.assocProxies = new HashMap();
    5.21 +        this.classProxies = new HashMap();
    5.22 +        this.datatypes = datatypes;
    5.23 +        this.getMdrStorage().addObject(this);
    5.24 +        if (packageId == null && mofContext != null) {
    5.25 +            this.context = mofContext;
    5.26 +            this.getMdrStorage().createContext(mofContext, this.getMofId());
    5.27 +        }
    5.28 +        else {
    5.29 +            this.context = null;
    5.30 +        }
    5.31 +        this.initFinished = true;
    5.32 +        objectChanged ();
    5.33      }
    5.34 -
    5.35 +    
    5.36      /** Creates new StorablePackage */
    5.37      public StorablePackage(MdrStorage mdrStorage, org.netbeans.mdr.persistence.MOFID packageId, org.netbeans.mdr.persistence.MOFID metaId,
    5.38          String mofContext, Map datatypes) throws StorageException {
    5.39 -        super(mdrStorage, packageId, metaId);
    5.40 -        this.init(packageId, mofContext, datatypes);
    5.41 +        this(mdrStorage, packageId, metaId, mofContext, datatypes, null);
    5.42      }
    5.43      
    5.44 -    public Class getPackageSuperclass() throws StorageException, ClassNotFoundException {
    5.45 -        if (packageSuperclass == null) {
    5.46 -            synchronized (superclassMutex) {
    5.47 -                if (packageSuperclass == null) {
    5.48 -                    objectWillChange();
    5.49 -                    packageSuperclass = resolvePackageSuperclass();
    5.50 -                    objectChanged();
    5.51 -                }
    5.52 -            }
    5.53 -        }
    5.54 +    public synchronized Class getPackageSuperclass() throws StorageException, ClassNotFoundException {
    5.55 +        objectWillChange();
    5.56 +        packageSuperclass = resolvePackageSuperclass();
    5.57 +        objectChanged();
    5.58 +
    5.59          return packageSuperclass;
    5.60      }
    5.61      
    5.62 @@ -267,22 +275,4 @@
    5.63              throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
    5.64          }
    5.65      }
    5.66 -    
    5.67 -    private void init(org.netbeans.mdr.persistence.MOFID packageId, String mofContext, Map datatypes) throws StorageException {
    5.68 -        objectWillChange();
    5.69 -        this.packageProxies = new HashMap();
    5.70 -        this.assocProxies = new HashMap();
    5.71 -        this.classProxies = new HashMap();
    5.72 -        this.datatypes = datatypes;
    5.73 -        this.getMdrStorage().addObject(this);
    5.74 -        if (packageId == null && mofContext != null) {
    5.75 -            this.context = mofContext;
    5.76 -            this.getMdrStorage().createContext(mofContext, this.getMofId());
    5.77 -        }
    5.78 -        else {
    5.79 -            this.context = null;
    5.80 -        }
    5.81 -        this.initFinished = true;
    5.82 -        objectChanged ();
    5.83 -    }
    5.84  }
     6.1 --- a/mdr/src/org/netbeans/mdr/util/TransactionMutex.java	Mon Sep 30 14:54:34 2002 +0000
     6.2 +++ b/mdr/src/org/netbeans/mdr/util/TransactionMutex.java	Wed Oct 02 19:29:48 2002 +0000
     6.3 @@ -104,6 +104,10 @@
     6.4                 (writeAccess && !readers.isEmpty())) {
     6.5  //               (writeAccess && (((size = readers.size()) > 1) ||
     6.6  //               (size == 1 && readers.get(thread) == null)))) {
     6.7 +                   
     6.8 +            // reader cannot enter a write transaction as it would not be possible to
     6.9 +            // prevent deadlocks (when two readers decide to enter write, they would
    6.10 +            // lock each other)
    6.11              if (readers.get(thread) != null) throw new DebugException("Writable lock nested in read-only lock.");
    6.12              try {
    6.13                  this.wait();
     7.1 --- a/mdr/xmidiffs/01-12-02_Diff.xml	Mon Sep 30 14:54:34 2002 +0000
     7.2 +++ b/mdr/xmidiffs/01-12-02_Diff.xml	Wed Oct 02 19:29:48 2002 +0000
     7.3 @@ -188,6 +188,24 @@
     7.4                      <XMI.any xmi.type = 'string' xmi.name = ''>UML</XMI.any>
     7.5                  </Model:Tag.values>
     7.6              </Model:Tag>
     7.7 +            <Model:Tag xmi.id = 'xmitag10' name = 'org.omg.xmi.namespace=UML'
     7.8 +                annotation = '' tagId = 'org.omg.xmi.namespace'>
     7.9 +                <Model:Tag.elements>
    7.10 +                    <Model:ModelElement href='01-12-02.xml|a336185C00118'/>
    7.11 +                </Model:Tag.elements>
    7.12 +                <Model:Tag.values>
    7.13 +                    <XMI.any xmi.type = 'string' xmi.name = ''>UML</XMI.any>
    7.14 +                </Model:Tag.values>
    7.15 +            </Model:Tag>
    7.16 +            <Model:Tag xmi.id = 'xmitag11' name = 'org.omg.xmi.namespace=UML'
    7.17 +                annotation = '' tagId = 'org.omg.xmi.namespace'>
    7.18 +                <Model:Tag.elements>
    7.19 +                    <Model:ModelElement href='01-12-02.xml|a335C122001A4'/>
    7.20 +                </Model:Tag.elements>
    7.21 +                <Model:Tag.values>
    7.22 +                    <XMI.any xmi.type = 'string' xmi.name = ''>UML</XMI.any>
    7.23 +                </Model:Tag.values>
    7.24 +            </Model:Tag>
    7.25              <!-- ===================== Clustered Imports=========== -->
    7.26              <Model:Import xmi.id='import1' name='Foundation' 
    7.27                  annotation='' visibility='public_vis' isClustered='true'>