[jbossws-commits] JBossWS SVN: r11741 - stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/jaxws/impl.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed Mar 10 05:53:41 EST 2010
Author: alessio.soldano at jboss.com
Date: 2010-03-10 05:53:40 -0500 (Wed, 10 Mar 2010)
New Revision: 11741
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/jaxws/impl/SourceWrapperGenerator.java
Log:
[JBPAPP-3457] Checking for reserved keywords before generating fields
Modified: stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/jaxws/impl/SourceWrapperGenerator.java
===================================================================
--- stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/jaxws/impl/SourceWrapperGenerator.java 2010-03-10 09:55:48 UTC (rev 11740)
+++ stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/tools/jaxws/impl/SourceWrapperGenerator.java 2010-03-10 10:53:40 UTC (rev 11741)
@@ -132,8 +132,11 @@
private void addProperty(JDefinedClass clazz, String typeName, QName name, String variable)
throws ClassNotFoundException
{
+ // be careful about reserved keywords when generating variable names
+ String realVariableName = JavaUtils.isReservedKeyword(variable) ? "_" + variable : variable;
+
Class type = JavaUtils.loadJavaType(typeName, loader);
- JFieldVar field = clazz.field(JMod.PRIVATE, type, variable);
+ JFieldVar field = clazz.field(JMod.PRIVATE, type, realVariableName);
JAnnotationUse annotation = field.annotate(XmlElement.class);
if (name.getNamespaceURI() != null)
annotation.param("namespace", name.getNamespaceURI());
@@ -141,10 +144,10 @@
// Add acessor methods
JMethod method = clazz.method(JMod.PUBLIC, type, getterPrefix(type) + JavaUtils.capitalize(variable));
- method.body()._return(JExpr._this().ref(variable));
+ method.body()._return(JExpr._this().ref(realVariableName));
method = clazz.method(JMod.PUBLIC, void.class, "set" + JavaUtils.capitalize(variable));
- method.body().assign(JExpr._this().ref(variable), method.param(type, variable));
+ method.body().assign(JExpr._this().ref(realVariableName), method.param(type, realVariableName));
}
private static void addClassAnnotations(JDefinedClass clazz, QName xmlName, QName xmlType, String[] propertyOrder)
@@ -168,4 +171,4 @@
annotation = clazz.annotate(XmlAccessorType.class);
annotation.param("value", XmlAccessType.FIELD);
}
-}
\ No newline at end of file
+}
More information about the jbossws-commits
mailing list