1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceVisitor.java Thu Apr 04 19:05:24 2013 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceVisitor.java Tue Apr 09 14:51:13 2013 +0100 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -31,6 +31,7 @@ 1.11 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle; 1.12 import com.sun.xml.internal.ws.model.RuntimeModeler; 1.13 1.14 +import javax.annotation.processing.ProcessingEnvironment; 1.15 import javax.jws.Oneway; 1.16 import javax.jws.WebMethod; 1.17 import javax.jws.WebParam; 1.18 @@ -53,6 +54,7 @@ 1.19 import javax.lang.model.util.ElementFilter; 1.20 import javax.lang.model.util.SimpleElementVisitor6; 1.21 import javax.lang.model.util.SimpleTypeVisitor6; 1.22 +import javax.lang.model.util.Types; 1.23 import java.lang.annotation.Annotation; 1.24 import java.util.Collection; 1.25 import java.util.HashSet; 1.26 @@ -139,7 +141,10 @@ 1.27 serviceImplName = null; 1.28 postProcessWebService(webService, e); 1.29 serviceImplName = null; 1.30 + break; 1.31 } 1.32 + default: 1.33 + break; 1.34 } 1.35 return null; 1.36 } 1.37 @@ -281,6 +286,8 @@ 1.38 soapStyle = SOAPStyle.DOCUMENT; 1.39 wrapped = soapBinding.parameterStyle().equals(ParameterStyle.WRAPPED); 1.40 } 1.41 + } else { 1.42 + pushedSoapBinding = false; 1.43 } 1.44 return soapBinding; 1.45 } 1.46 @@ -366,6 +373,7 @@ 1.47 } 1.48 for (TypeMirror superType : element.getInterfaces()) 1.49 processMethods((TypeElement) ((DeclaredType) superType).asElement()); 1.50 + break; 1.51 } 1.52 case CLASS: { 1.53 builder.log("ProcessedMethods Class: " + element); 1.54 @@ -382,7 +390,10 @@ 1.55 if (!superclass.getKind().equals(TypeKind.NONE)) { 1.56 processMethods((TypeElement) ((DeclaredType) superclass).asElement()); 1.57 } 1.58 + break; 1.59 } 1.60 + default: 1.61 + break; 1.62 } 1.63 } 1.64 1.65 @@ -504,7 +515,7 @@ 1.66 boolean hasDefaultConstructor = false; 1.67 for (ExecutableElement constructor : ElementFilter.constructorsIn(classElement.getEnclosedElements())) { 1.68 if (constructor.getModifiers().contains(Modifier.PUBLIC) && 1.69 - constructor.getParameters().size() == 0) { 1.70 + constructor.getParameters().isEmpty()) { 1.71 hasDefaultConstructor = true; 1.72 break; 1.73 } 1.74 @@ -547,7 +558,7 @@ 1.75 if (((DeclaredType) interfaceType).asElement().equals(interfaceElement)) 1.76 return true; 1.77 } 1.78 - List<ExecutableElement> classMethods = ElementFilter.methodsIn(classElement.getEnclosedElements()); 1.79 + List<ExecutableElement> classMethods = getClassMethods(classElement); 1.80 boolean implementsMethod; 1.81 for (ExecutableElement interfaceMethod : ElementFilter.methodsIn(interfaceElement.getEnclosedElements())) { 1.82 implementsMethod = false; 1.83 @@ -566,17 +577,32 @@ 1.84 return true; 1.85 } 1.86 1.87 + private static List<ExecutableElement> getClassMethods(TypeElement classElement) { 1.88 + if (classElement.getQualifiedName().toString().equals(Object.class.getName())) // we don't need Object's methods 1.89 + return null; 1.90 + TypeElement superclassElement = (TypeElement) ((DeclaredType) classElement.getSuperclass()).asElement(); 1.91 + List<ExecutableElement> superclassesMethods = getClassMethods(superclassElement); 1.92 + List<ExecutableElement> classMethods = ElementFilter.methodsIn(classElement.getEnclosedElements()); 1.93 + if (superclassesMethods == null) 1.94 + return classMethods; 1.95 + else 1.96 + superclassesMethods.addAll(classMethods); 1.97 + return superclassesMethods; 1.98 + } 1.99 + 1.100 protected boolean sameMethod(ExecutableElement method1, ExecutableElement method2) { 1.101 if (!method1.getSimpleName().equals(method2.getSimpleName())) 1.102 return false; 1.103 - if (!method1.getReturnType().equals(method2.getReturnType())) 1.104 + Types typeUtils = builder.getProcessingEnvironment().getTypeUtils(); 1.105 + if(!typeUtils.isSameType(method1.getReturnType(), method2.getReturnType()) 1.106 + && !typeUtils.isSubtype(method2.getReturnType(), method1.getReturnType())) 1.107 return false; 1.108 List<? extends VariableElement> parameters1 = method1.getParameters(); 1.109 List<? extends VariableElement> parameters2 = method2.getParameters(); 1.110 if (parameters1.size() != parameters2.size()) 1.111 return false; 1.112 for (int i = 0; i < parameters1.size(); i++) { 1.113 - if (!builder.getProcessingEnvironment().getTypeUtils().isSameType(parameters1.get(i).asType(), parameters2.get(i).asType())) 1.114 + if (!typeUtils.isSameType(parameters1.get(i).asType(), parameters2.get(i).asType())) 1.115 return false; 1.116 } 1.117 return true; 1.118 @@ -616,9 +642,9 @@ 1.119 } 1.120 DeclaredType superClass = (DeclaredType) element.getSuperclass(); 1.121 1.122 - TypeElement typeElement = (TypeElement) superClass.asElement(); 1.123 - return typeElement.getQualifiedName().toString().equals(Object.class.getName()) 1.124 - || methodsAreLegal(typeElement); 1.125 + TypeElement tE = (TypeElement) superClass.asElement(); 1.126 + return tE.getQualifiedName().toString().equals(Object.class.getName()) 1.127 + || methodsAreLegal(tE); 1.128 } 1.129 default: { 1.130 throw new IllegalArgumentException("Class or interface was expecting. But element: " + element); 1.131 @@ -800,12 +826,12 @@ 1.132 protected boolean isLegalType(TypeMirror type) { 1.133 if (!(type != null && type.getKind().equals(TypeKind.DECLARED))) 1.134 return true; 1.135 - TypeElement typeElement = (TypeElement) ((DeclaredType) type).asElement(); 1.136 - if (typeElement == null) { 1.137 + TypeElement tE = (TypeElement) ((DeclaredType) type).asElement(); 1.138 + if (tE == null) { 1.139 // can be null, if this type's declaration is unknown. This may be the result of a processing error, such as a missing class file. 1.140 builder.processError(WebserviceapMessages.WEBSERVICEAP_COULD_NOT_FIND_TYPEDECL(type.toString(), context.getRound())); 1.141 } 1.142 - return !builder.isRemote(typeElement); 1.143 + return !builder.isRemote(tE); 1.144 } 1.145 1.146 protected VariableElement getOutParameter(ExecutableElement method) { 1.147 @@ -821,18 +847,22 @@ 1.148 1.149 protected static class MySoapBinding implements SOAPBinding { 1.150 1.151 + @Override 1.152 public Style style() { 1.153 return SOAPBinding.Style.DOCUMENT; 1.154 } 1.155 1.156 + @Override 1.157 public Use use() { 1.158 return SOAPBinding.Use.LITERAL; 1.159 } 1.160 1.161 + @Override 1.162 public ParameterStyle parameterStyle() { 1.163 return SOAPBinding.ParameterStyle.WRAPPED; 1.164 } 1.165 1.166 + @Override 1.167 public Class<? extends java.lang.annotation.Annotation> annotationType() { 1.168 return SOAPBinding.class; 1.169 }