butek 2002/06/04 14:30:52
Modified: java/src/org/apache/axis/wsdl/toJava
JavaGeneratorFactory.java
Log:
Fixed a hidden bug in the relationship between javifyNames and
resolveNameClashes. This is not apparent until you upgrade to
JDK1.4 and the order of HashTable changes. There still seems
to be too much interrelation between these two methods but I'll
leave cleaning that up as an exercise to the reader.
This is a first step toward fixing bugzilla 8631, but the functional-tests
still fail further on for some other reason.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8631
Revision Changes Path
1.7 +13 -5
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java
Index: JavaGeneratorFactory.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JavaGeneratorFactory.java 17 May 2002 19:09:32 -0000 1.6
+++ JavaGeneratorFactory.java 4 Jun 2002 21:30:52 -0000 1.7
@@ -347,7 +347,7 @@
SymTabEntry entry = (SymTabEntry) v.elementAt(i);
// Use the type or the referenced type's QName to generate the java
name.
- if (entry instanceof TypeEntry) {
+ if (entry instanceof TypeEntry && entry.getName() == null) {
TypeEntry tEntry = (TypeEntry) entry;
String dims = tEntry.getDimensions();
TypeEntry refType = tEntry.getRefType();
@@ -375,9 +375,7 @@
// collision. If there is an existing anon type, there
will be a
// collision. In both cases, the java type name should be
mangled.
TypeEntry existing = symbolTable.getType(typeQName);
- if (anonQNames.get(typeQName) != null ||
- (existing != null &&
- !(existing instanceof DefinedElement))) {
+ if (anonQNames.get(typeQName) != null) {
localName += "Type" + uniqueNum++;
typeQName = new QName(typeQName.getNamespaceURI(),
localName);
}
@@ -560,6 +558,10 @@
* Definition, force their names to be suffixed with _PortType and _Service,
respectively.
*/
protected void resolveNameClashes(SymbolTable symbolTable) {
+
+ // Keep a list of anonymous types so we don't try to resolve them twice.
+ HashSet anonTypes = new HashSet();
+
Iterator it = symbolTable.getHashMap().values().iterator();
while (it.hasNext()) {
Vector v = new Vector((Vector) it.next()); // New vector we can
temporarily add to it
@@ -623,6 +625,7 @@
if (entry instanceof Element) {
entry.setName(mangleName(entry.getName(),
"_ElemType"));
+
// If this global element was defined using
// an anonymous type, then need to change the
// java name of the anonymous type to match.
@@ -632,6 +635,7 @@
TypeEntry anonType = symbolTable.getType(anonQName);
if (anonType != null) {
anonType.setName(entry.getName());
+ anonTypes.add(anonType);
}
}
else if (entry instanceof TypeEntry) {
@@ -654,7 +658,11 @@
}
}
}
- entry.setName(mangleName(entry.getName(), "_Type"));
+ // If this is an anonymous type, it's name was resolved
in
+ // the previous if block. Don't reresolve it.
+ if (!anonTypes.contains(entry)) {
+ entry.setName(mangleName(entry.getName(), "_Type"));
+ }
}
else if (entry instanceof PortTypeEntry) {
entry.setName(mangleName(entry.getName(), "_Port"));