Introduction

This is the second release of MetaClass. This release introduces several refactorings to simplify usage of MetaClass in response to user feedback. See the changes below for a comprehensive list of changes in the release. The release can be downloaded from;

Changes

  • Support reading and writing descriptors as part of the .class file. The aim of this technique is to reduce the chance that descriptors and .class files will get out of sync. MetaClass will attempt to load descriptors from .class files prior to attempting to load descriptors that sit side-by-side the .class file.
  • Removed the notion of Package-level attributes and corresponding PackageDescriptor. This was removed as there was no actual mechanism to compile package attributes. There was also ambiguity wrt how to handle package attributes. See the FAQ for more details.
  • Fixed a bug where methods with the same name and the same number of parameters would always return the first methods attributes. This bug was also fixed for constructors that had the same number of parameters.
  • Moved the following classes into the package org.codehaus.metaclass.introspector so that now all the packages have clean dependency lines and there is no circular dependencies. The classes moved included; org.codehaus.metaclass.MetaClassIntrospector, org.codehaus.metaclass.MetaClassException, org.codehaus.metaclass.io.DefaultMetaClassAccessor and org.codehaus.metaclass.io.MetaClassAccessor.
  • Removed constants pertaining to the serialized format for MetaClass descriptors as they were never used and are unlikely to be used in the future.
  • GenerateClassDescriptorsTask will continue to process source files even if generation of a descriptor fails. However if generation of descriptor does fail it will still throw a BuildException after it has finished processing the rest of the descriptors.
  • Achieve 100% unit test coverage of MetaClass code.
  • Remove modifiers from FeatureDescriptor as they can be derived from the corresponding classes in java.lang.reflect. This was a backwards incompatible change in serialization format and thus the version of the MetaClass file format was increased to 2.
  • Added in CachingMetaClassAccessor that caches results to a child Accessor and reworked Introspector to use this internally.
  • Modified the MetaClassAccessor interface to accept an extra parameter of type MetaClassAccessor. This accessor can be used to resolve related classes when loading a ClassDescriptor. This enables support for creating an Accessor that supports inheritance of attributes.
  • By default the ant task will now not filter out attributes that do not have a name space (ie are not in the form X.Y). To disable this behaviour use set the namespaceTagsOnly="false" attribute on the task.
  • Support reading and writing of descriptors in XML format. The runtime will attempt to load XML descriptors if binary descriptors are not present.
  • Documented the ant task.
  • Added in compacting of ClassDescriptors prior to serializing the descriptor. If a field has no attributes then it is not serialized. If a method has no attributes and keepEmptyMethods=false then it is not serialized. If a class has no methods or fields to serialize and has no attributes then it is not serialized.
  • Created Ant DataTypes "interceptorSet" and "filterSet" to contain definitions of interceptors and filters respectively. Also created Ant tasks "metaclass_addToInterceptorSet" and "metaclass_addToFilterSet" so that existing sets could be combined.
  • Created a Maven plugin to generate MetaClass descriptors. Developers need to invoke the "metaclass:generate" goal to generate descriptors. See documentation for further details.