Bug 446115 - JAX-WS not working with Java 8
https://bugs.eclipse.org/bugs/show_bug.cgi?id=446115
diff --git a/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/jdt/finegrained/FineGrainedJavaElementDeltaManager.java b/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/jdt/finegrained/FineGrainedJavaElementDeltaManager.java
index 4232a9b..9a1bd2b 100644
--- a/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/jdt/finegrained/FineGrainedJavaElementDeltaManager.java
+++ b/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/jdt/finegrained/FineGrainedJavaElementDeltaManager.java
@@ -37,7 +37,7 @@
}
private final Object m_cacheLock;
- private final WeakHashMap<IJavaElementDelta, Set<IJavaElement>> m_deltaCache;
+ private final Map<IJavaElementDelta, Set<IJavaElement>> m_deltaCache;
private final Map<String/* path */, String/* source */> m_sourceCache;
private final IBufferChangedListener m_bufferListener;
@@ -48,13 +48,11 @@
m_bufferListener = new IBufferChangedListener() {
@Override
public void bufferChanged(BufferChangedEvent e) {
- if (e.getBuffer().isClosed()) {
- if (e.getBuffer().getOwner() instanceof ICompilationUnit) {
- ICompilationUnit icu = (ICompilationUnit) e.getBuffer().getOwner();
- synchronized (m_cacheLock) {
- String path = icu.getPath().toString();
- m_sourceCache.remove(path);
- }
+ if (e.getBuffer().isClosed() && e.getBuffer().getOwner() instanceof ICompilationUnit) {
+ ICompilationUnit icu = (ICompilationUnit) e.getBuffer().getOwner();
+ synchronized (m_cacheLock) {
+ String path = icu.getPath().toString();
+ m_sourceCache.remove(path);
}
}
}
diff --git a/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/marker/commands/InvalidServiceCommand.java b/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/marker/commands/InvalidServiceCommand.java
index 29d8ab9..cf38336 100644
--- a/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/marker/commands/InvalidServiceCommand.java
+++ b/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/marker/commands/InvalidServiceCommand.java
@@ -10,7 +10,7 @@
******************************************************************************/
package org.eclipse.scout.sdk.ws.jaxws.marker.commands;
-import java.util.Arrays;
+import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -24,6 +24,7 @@
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
+import org.eclipse.scout.commons.CollectionUtility;
import org.eclipse.scout.sdk.operation.util.SourceFormatOperation;
import org.eclipse.scout.sdk.ui.internal.ScoutSdkUi;
import org.eclipse.scout.sdk.util.ScoutUtility;
@@ -53,8 +54,8 @@
@Override
public boolean prepareForUi() throws CoreException {
- IType[] candidates = JaxWsSdkUtility.resolveServiceTypes(null, m_stubJarFile);
- switch (candidates.length) {
+ Set<IType> candidates = JaxWsSdkUtility.resolveServiceTypes(null, m_stubJarFile);
+ switch (candidates.size()) {
case 0: {
MessageBox messageBox = new MessageBox(ScoutSdkUi.getShell(), SWT.ICON_INFORMATION | SWT.OK);
messageBox.setText(Texts.get("Information"));
@@ -63,12 +64,12 @@
break;
}
case 1: {
- m_serviceType = candidates[0];
+ m_serviceType = CollectionUtility.firstElement(candidates);
break;
}
default: {
TypeSelectionDialog dialog = new TypeSelectionDialog(ScoutSdkUi.getShell(), Texts.get("Service"), Texts.get("PleaseChooseServiceType"));
- dialog.setElements(Arrays.asList(candidates));
+ dialog.setElements(candidates);
if (dialog.open() == Dialog.OK) {
m_serviceType = dialog.getElement();
}
diff --git a/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/util/JaxWsSdkUtility.java b/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/util/JaxWsSdkUtility.java
index 5b2ead9..d356418 100644
--- a/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/util/JaxWsSdkUtility.java
+++ b/org.eclipse.scout.sdk.ws.jaxws/src/org/eclipse/scout/sdk/ws/jaxws/util/JaxWsSdkUtility.java
@@ -91,6 +91,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
+import org.eclipse.scout.commons.CollectionUtility;
import org.eclipse.scout.commons.CompareUtility;
import org.eclipse.scout.commons.StringUtility;
import org.eclipse.scout.sdk.jobs.OperationJob;
@@ -98,6 +99,7 @@
import org.eclipse.scout.sdk.ui.view.outline.IScoutExplorerPart;
import org.eclipse.scout.sdk.ui.view.outline.pages.IPage;
import org.eclipse.scout.sdk.ui.view.properties.part.ISection;
+import org.eclipse.scout.sdk.util.jdt.JdtUtility;
import org.eclipse.scout.sdk.util.pde.PluginModelHelper;
import org.eclipse.scout.sdk.util.resources.ResourceUtility;
import org.eclipse.scout.sdk.util.signature.ImportValidator;
@@ -553,34 +555,35 @@
new SearchEngine().search(
SearchPattern.createPattern("*", IJavaSearchConstants.INTERFACE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH),
new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},
- new JarFileSearchScope(jarFile), //SearchEngine.createWorkspaceScope(),
+ new JarFileSearchScope(jarFile),
new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (!(match instanceof TypeDeclarationMatch)) {
return;
}
+
IType candidate = (IType) match.getElement();
if (!TypeUtility.exists(candidate) || !candidate.isBinary()) {
// type must be binary
return;
}
+
// candidates must be annotated WebService annotation
IAnnotation annotation = JaxWsSdkUtility.getAnnotation(candidate, WebService.class.getName(), false);
if (!TypeUtility.exists(annotation)) {
return;
}
+
if (portTypeQName == null) {
types.add(candidate);
return;
}
+
// candidate must match the port type
- IMemberValuePair[] properties = annotation.getMemberValuePairs();
- for (IMemberValuePair property : properties) {
- if ("name".equals(property.getMemberName()) && property.getValue().equals(portTypeQName.getLocalPart())) {
- types.add(candidate);
- return;
- }
+ String serviceName = JdtUtility.getAnnotationValueString(annotation, "name");
+ if (CompareUtility.equals(serviceName, portTypeQName.getLocalPart())) {
+ types.add(candidate);
}
}
},
@@ -604,14 +607,14 @@
if (serviceQName == null) {
return null;
}
- IType[] types = resolveServiceTypes(serviceQName, jarFile);
- if (types.length == 0) {
+ Set<IType> types = resolveServiceTypes(serviceQName, jarFile);
+ if (types.size() == 0) {
return null;
}
- else if (types.length > 1) {
+ else if (types.size() > 1) {
JaxWsSdk.logWarning("Multiple service types found for service '" + serviceQName + "'");
}
- return types[0];
+ return CollectionUtility.firstElement(types);
}
/**
@@ -623,13 +626,13 @@
* the jar file the service type to be searched in
* @return
*/
- public static IType[] resolveServiceTypes(final QName serviceQName, IFile jarFile) {
+ public static Set<IType> resolveServiceTypes(final QName serviceQName, IFile jarFile) {
final Set<IType> types = new HashSet<IType>();
try {
new SearchEngine().search(
SearchPattern.createPattern("*", IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH),
new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},
- new JarFileSearchScope(jarFile), //SearchEngine.createWorkspaceScope(),
+ new JarFileSearchScope(jarFile),
new SearchRequestor() {
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
@@ -651,22 +654,22 @@
if (!JaxWsSdkUtility.isJdtSubType(javax.xml.ws.Service.class.getName(), candidate)) {
return;
}
+
// candidates must be annotated WebServiceClient annotation
IAnnotation annotation = JaxWsSdkUtility.getAnnotation(candidate, WebServiceClient.class.getName(), false);
if (!TypeUtility.exists(annotation)) {
return;
}
+
if (serviceQName == null) {
types.add(candidate);
return;
}
+
// candidate must match the service type
- IMemberValuePair[] properties = annotation.getMemberValuePairs();
- for (IMemberValuePair property : properties) {
- if ("name.".equals(property.getMemberName()) && property.getValue().equals(serviceQName.getLocalPart())) {
- types.add(candidate);
- return;
- }
+ String serviceName = JdtUtility.getAnnotationValueString(annotation, "name");
+ if (CompareUtility.equals(serviceName, serviceQName.getLocalPart())) {
+ types.add(candidate);
}
}
},
@@ -676,7 +679,7 @@
catch (Exception e) {
JaxWsSdk.logError("Failed to resolve portType interface type", e);
}
- return types.toArray(new IType[types.size()]);
+ return types;
}
public static boolean isProviderAuthenticationSet(String fqn) {
@@ -892,32 +895,26 @@
* @return
*/
public static IAnnotation getAnnotation(IType declaringType, String fqnAnnotationName, boolean recursively) {
- try {
- if (!TypeUtility.exists(declaringType)) {
- return null;
- }
- IAnnotation[] annotations = declaringType.getAnnotations();
- for (IAnnotation annotation : annotations) {
- if (declaringType.isBinary()) {
- // annotation name is always fully qualified name if coming from a class file
- if (annotation.getElementName().equals(fqnAnnotationName)) {
- return annotation;
- }
- }
- else {
- if (annotation.getElementName().equals(fqnAnnotationName) || annotation.getElementName().equals(Signature.getSimpleName(fqnAnnotationName))) {
- return annotation;
- }
- }
- }
-
- if (recursively) {
- IType superType = TypeUtility.getSupertypeHierarchy(declaringType).getSuperclass(declaringType);
- return getAnnotation(superType, fqnAnnotationName, recursively);
- }
+ ITypeHierarchy superTypeHierarchy = null;
+ if (recursively) {
+ superTypeHierarchy = TypeUtility.getSupertypeHierarchy(declaringType);
}
- catch (JavaModelException e) {
- JaxWsSdk.logError("failed to resolve annotations", e);
+ return getAnnotation(declaringType, fqnAnnotationName, recursively, superTypeHierarchy);
+ }
+
+ private static IAnnotation getAnnotation(IType declaringType, String fqnAnnotationName, boolean recursively, ITypeHierarchy superTypeHierarchy) {
+ if (!TypeUtility.exists(declaringType)) {
+ return null;
+ }
+
+ IAnnotation annotation = JdtUtility.getAnnotation(declaringType, fqnAnnotationName);
+ if (TypeUtility.exists(annotation)) {
+ return annotation;
+ }
+
+ if (recursively) {
+ IType superType = superTypeHierarchy.getSuperclass(declaringType);
+ return getAnnotation(superType, fqnAnnotationName, recursively, superTypeHierarchy);
}
return null;
}
@@ -1131,17 +1128,16 @@
* @return
*/
public static boolean isJdtSubType(String fqnSuperType, IType candidateToCheck) {
- if (candidateToCheck == null) {
+ if (!TypeUtility.exists(candidateToCheck)) {
return false;
}
- Set<IType> superTypes = TypeUtility.getTypes(fqnSuperType);
- ITypeHierarchy superTypeHierarchy = TypeUtility.getSupertypeHierarchy(candidateToCheck);
- for (IType superType : superTypes) {
- if (superTypeHierarchy.contains(superType)) {
- return true;
- }
+
+ IType superTypes = TypeUtility.getType(fqnSuperType);
+ if (!TypeUtility.exists(superTypes)) {
+ return false;
}
- return false;
+
+ return TypeUtility.getSupertypeHierarchy(candidateToCheck).isSubtype(superTypes, candidateToCheck);
}
public static String resolveTypeName(IType declaringType, IType typeToBeResolved) throws CoreException {