--- old/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceAp.java 2016-09-26 02:15:59.592641130 +0300 +++ new/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceAp.java 2016-09-26 02:15:59.500639762 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, 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 @@ -51,13 +51,9 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.PrintStream; -import java.lang.reflect.Method; -import java.rmi.Remote; -import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; -import java.util.Scanner; import java.util.Set; import java.util.logging.Level; @@ -89,21 +85,20 @@ "javax.xml.ws.WebServiceProvider", "javax.xml.ws.WebServiceRef" }) -@SupportedOptions({WebServiceAp.DO_NOT_OVERWRITE, WebServiceAp.IGNORE_NO_WEB_SERVICE_FOUND_WARNING}) +@SupportedOptions({WebServiceAp.DO_NOT_OVERWRITE, WebServiceAp.IGNORE_NO_WEB_SERVICE_FOUND_WARNING, WebServiceAp.VERBOSE}) public class WebServiceAp extends AbstractProcessor implements ModelBuilder { private static final Logger LOGGER = Logger.getLogger(WebServiceAp.class); public static final String DO_NOT_OVERWRITE = "doNotOverWrite"; public static final String IGNORE_NO_WEB_SERVICE_FOUND_WARNING = "ignoreNoWebServiceFoundWarning"; + public static final String VERBOSE = "verbose"; private WsgenOptions options; protected AnnotationProcessorContext context; private File sourceDir; private boolean doNotOverWrite; private boolean ignoreNoWebServiceFoundWarning = false; - private TypeElement remoteElement; - private TypeMirror remoteExceptionElement; private TypeMirror exceptionElement; private TypeMirror runtimeExceptionElement; private TypeElement defHolderElement; @@ -126,8 +121,6 @@ @Override public synchronized void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); - remoteElement = processingEnv.getElementUtils().getTypeElement(Remote.class.getName()); - remoteExceptionElement = processingEnv.getElementUtils().getTypeElement(RemoteException.class.getName()).asType(); exceptionElement = processingEnv.getElementUtils().getTypeElement(Exception.class.getName()).asType(); runtimeExceptionElement = processingEnv.getElementUtils().getTypeElement(RuntimeException.class.getName()).asType(); defHolderElement = processingEnv.getElementUtils().getTypeElement(Holder.class.getName()); @@ -135,71 +128,14 @@ options = new WsgenOptions(); out = new PrintStream(new ByteArrayOutputStream()); - doNotOverWrite = getOption(DO_NOT_OVERWRITE); ignoreNoWebServiceFoundWarning = getOption(IGNORE_NO_WEB_SERVICE_FOUND_WARNING); - - String classDir = parseArguments(); - String property = System.getProperty("java.class.path"); - options.classpath = classDir + File.pathSeparator + (property != null ? property : ""); + options.verbose = getOption(VERBOSE); isCommandLineInvocation = true; } options.filer = processingEnv.getFiler(); } - private String parseArguments() { - // let's try to parse JavacOptions - - String classDir = null; - try { - ClassLoader cl = WebServiceAp.class.getClassLoader(); - Class javacProcessingEnvironmentClass = Class.forName("com.sun.tools.javac.processing.JavacProcessingEnvironment", false, cl); - if (javacProcessingEnvironmentClass.isInstance(processingEnv)) { - Method getContextMethod = javacProcessingEnvironmentClass.getDeclaredMethod("getContext"); - Object tmpContext = getContextMethod.invoke(processingEnv); - Class optionsClass = Class.forName("com.sun.tools.javac.util.Options", false, cl); - Class contextClass = Class.forName("com.sun.tools.javac.util.Context", false, cl); - Method instanceMethod = optionsClass.getDeclaredMethod("instance", new Class[]{contextClass}); - Object tmpOptions = instanceMethod.invoke(null, tmpContext); - if (tmpOptions != null) { - Method getMethod = optionsClass.getDeclaredMethod("get", new Class[]{String.class}); - Object result = getMethod.invoke(tmpOptions, "-s"); // todo: we have to check for -d also - if (result != null) { - classDir = (String) result; - } - this.options.verbose = getMethod.invoke(tmpOptions, "-verbose") != null; - } - } - } catch (Exception e) { - /// some Error was here - problems with reflection or security - processWarning(WebserviceapMessages.WEBSERVICEAP_PARSING_JAVAC_OPTIONS_ERROR()); - report(e.getMessage()); - } - - if (classDir == null) { // some error within reflection block - String property = System.getProperty("sun.java.command"); - if (property != null) { - Scanner scanner = new Scanner(property); - boolean sourceDirNext = false; - while (scanner.hasNext()) { - String token = scanner.next(); - if (sourceDirNext) { - classDir = token; - sourceDirNext = false; - } else if ("-verbose".equals(token)) { - options.verbose = true; - } else if ("-s".equals(token)) { - sourceDirNext = true; - } - } - } - } - if (classDir != null) { - sourceDir = new File(classDir); - } - return classDir; - } - private boolean getOption(String key) { String value = processingEnv.getOptions().get(key); if (value != null) { @@ -309,14 +245,14 @@ @Override public boolean isRemote(TypeElement typeElement) { - return processingEnv.getTypeUtils().isSubtype(typeElement.asType(), remoteElement.asType()); + return TypeModeler.isRemote(typeElement); } @Override public boolean isServiceException(TypeMirror typeMirror) { return processingEnv.getTypeUtils().isSubtype(typeMirror, exceptionElement) && !processingEnv.getTypeUtils().isSubtype(typeMirror, runtimeExceptionElement) - && !processingEnv.getTypeUtils().isSubtype(typeMirror, remoteExceptionElement); + && !TypeModeler.isRemoteException(processingEnv, typeMirror); } @Override