[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ecj vs javac



I've gone through them now, and it looks like most of them are missing
downcasting, where they've got

Field[] fields = null;
...
fields = AccessController.doPrivileged(new
PrivilegedGetDeclaredFields(clazz));


PrivilegedGetDeclaredFields.run() returns an Object, which turns out is
actually a Field[]. I guess ecj is allowing an implicit down-cast. I've
been able to fix this by adding an explicit cast (which is what the
codebase in question does most of the time).


The only other compile failure I've found was use of a class without
generics in a generic declaration (not sure of the right terminology
here), i.e.

public abstract class XMLMarshaller<
   ABSTRACT_SESSION extends CoreAbstractSession,
   CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, ?, ?>,
   DESCRIPTOR extends Descriptor,
   MEDIA_TYPE extends MediaType,
   NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper,
   OBJECT_BUILDER extends ObjectBuilder<?, ABSTRACT_SESSION, ?,
XMLMarshaller>> extends Marshaller<CONTEXT, MEDIA_TYPE,
NAMESPACE_PREFIX_MAPPER> {

instead of

public abstract class XMLMarshaller<
   ABSTRACT_SESSION extends CoreAbstractSession,
   CONTEXT extends Context<ABSTRACT_SESSION, DESCRIPTOR, ?, ?, ?, ?, ?>,
   DESCRIPTOR extends Descriptor<?,?,?,?,?,?,?,?,?>,
   MEDIA_TYPE extends MediaType,
   NAMESPACE_PREFIX_MAPPER extends NamespacePrefixMapper,
   OBJECT_BUILDER extends ObjectBuilder<?, ABSTRACT_SESSION, ?,
XMLMarshaller>> extends Marshaller<CONTEXT, MEDIA_TYPE,
NAMESPACE_PREFIX_MAPPER> {


Descriptor is defined as:

public interface Descriptor <
    ATTRIBUTE_ACCESSOR extends CoreAttributeAccessor,
    CORE_MAPPING extends CoreMapping,
    FIELD extends CoreField,
    INHERITANCE_POLICY extends CoreInheritancePolicy,
    INSTANTIATION_POLICY extends CoreInstantiationPolicy,
    NAMESPACE_RESOLVER extends NamespaceResolver,
    OBJECT_BUILDER extends CoreObjectBuilder,
    UNMARSHAL_RECORD extends UnmarshalRecord,
    UNMARSHALLER extends Unmarshaller> {
...
}

I haven't completely figured this bit out, but the change certainly lets
the code compile.

I'm tempted to report these as upstream bugs - the missing casts
definitely appear to be an oversight when you look through the rest of
the eclipselink codebase.

Thanks
Andy


On 26/09/13 23:04, Emmanuel Bourg wrote:
> Hi Andrew,
> 
> What kind of errors do you get with javac? Is this specific to Java 7?
> 
> Emmanuel Bourg
> 
> 
> Le 26/09/2013 23:23, Andrew Ross a écrit :
>> Hi,
>>
>> I've been looking to update the eclipselink package, which is a
>> dependency of Netbeans. The latest version only appears to compile
>> without errors when using the ecj compiler rather than javac. Is it
>> acceptable to do this, or should I try and patch the source to avoid the
>> errors. There's only 10 or so which I think can mostly be fixed quite
>> easily, but it's not clear if that is a good option or not.
>>
>> Any advice welcome!
>>
>> Thanks,
>> Andy
>>
>>
> 
> 


Reply to: