src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/ClassBeanInfoImpl.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -46,10 +46,11 @@
import com.sun.xml.internal.bind.Util;
import com.sun.xml.internal.bind.api.AccessorException;
import com.sun.xml.internal.bind.v2.ClassFactory;
import com.sun.xml.internal.bind.v2.WellKnownNamespace;
import com.sun.xml.internal.bind.v2.model.core.ID;
+import com.sun.xml.internal.bind.v2.model.nav.Navigator;
import com.sun.xml.internal.bind.v2.model.runtime.RuntimeClassInfo;
import com.sun.xml.internal.bind.v2.model.runtime.RuntimePropertyInfo;
import com.sun.xml.internal.bind.v2.runtime.property.AttributeProperty;
import com.sun.xml.internal.bind.v2.runtime.property.Property;
import com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory;
@@ -188,18 +189,19 @@
ClassBeanInfoImpl bi = this;
while ((bi = bi.superClazz) != null) {
Property[] props = bi.properties;
if (props == null) break;
for (Property superProperty : props) {
- if (superProperty == null) break;
+ if (superProperty != null) {
String spName = superProperty.getFieldName();
if ((spName != null) && (spName.equals(p.getFieldName()))) {
superProperty.setHiddenByOverride(true);
}
}
}
}
+ }
@Override
protected void link(JAXBContextImpl grammar) {
if(uriProperties!=null)
return; // avoid linking twice
@@ -337,14 +339,21 @@
try {
for (Property<BeanT> p : properties) {
if (retainPropertyInfo) {
target.currentProperty.set(p);
}
- if (!(p.isHiddenByOverride() && !bean.getClass().equals(jaxbType))) {
+ boolean isThereAnOverridingProperty = p.isHiddenByOverride();
+ if (!isThereAnOverridingProperty || bean.getClass().equals(jaxbType)) {
+ p.serializeBody(bean, target, null);
+ } else if (isThereAnOverridingProperty) {
+ // need to double check the override - it should be safe to do after the model has been created because it's targeted to override properties only
+ Class beanClass = bean.getClass();
+ if (Navigator.REFLECTION.getDeclaredField(beanClass, p.getFieldName()) == null) {
p.serializeBody(bean, target, null);
}
}
+ }
} catch (AccessorException e) {
target.reportError(null, e);
}
}