Skip to content

Commit

Permalink
code cleanup in wscompile
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
  • Loading branch information
lukasj committed Oct 16, 2023
1 parent 5581649 commit fbd1eef
Show file tree
Hide file tree
Showing 69 changed files with 457 additions and 481 deletions.
3 changes: 2 additions & 1 deletion jaxws-ri/bundles/jaxws-tools/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
* @since 2.4.0
*/
@SuppressWarnings({"deprecation"})
module com.sun.tools.ws {

requires transitive java.compiler;
Expand All @@ -24,7 +25,7 @@

requires transitive com.sun.xml.ws;

requires com.sun.tools.jxc;
requires transitive com.sun.tools.jxc;
requires transitive com.sun.tools.xjc;

exports com.sun.tools.ws;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -125,8 +125,8 @@ static int invoke(String mainClass, String[] args) throws Throwable {

Thread.currentThread().setContextClassLoader(cl);

Class compileTool = cl.loadClass(mainClass);
Constructor ctor = compileTool.getConstructor(OutputStream.class);
Class<?> compileTool = cl.loadClass(mainClass);
Constructor<?> ctor = compileTool.getConstructor(OutputStream.class);
Object tool = ctor.newInstance(System.out);
Method runMethod = compileTool.getMethod("run",String[].class);
boolean r = (Boolean)runMethod.invoke(tool,new Object[]{args});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -39,6 +39,7 @@
/**
* annotation processing task for use with the JAXWS project.
*/
@SuppressWarnings({"exports"})
public class AnnotationProcessingTask extends Javac {

private boolean procOnly = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -41,6 +41,7 @@ protected String getCoreClassName() {


@Override
@SuppressWarnings({"exports"})
public void setDynamicAttribute(String name, String value) throws BuildException {
super.setDynamicAttribute(name,value);
if(name.equals("target"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -80,7 +80,7 @@ public void setClasspathRef(Reference r) {
createClasspath().setRefid(r);
}

/************************ -cp option *************************/
/* *********************** -cp option *************************/
/**
* Gets the classpath.
*
Expand Down Expand Up @@ -272,7 +272,7 @@ public void setSei(String endpointImplementationClass) {
protected CommandlineJava setupCommand() {
CommandlineJava cmd = super.setupCommand();
Path classpath = getClasspath();
if (classpath != null && !classpath.toString().equals("")) {
if (classpath != null && !classpath.toString().isEmpty()) {
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(classpath);
}
Expand All @@ -284,17 +284,17 @@ protected CommandlineJava setupCommand() {

if (getGenwsdl()) {
String tmp = "-wsdl";
if (protocol.length() > 0) {
if (!protocol.isEmpty()) {
tmp += ":" + protocol;
}
cmd.createArgument().setValue(tmp);

if (serviceName != null && serviceName.length() > 0) {
if (serviceName != null && !serviceName.isEmpty()) {
cmd.createArgument().setValue("-servicename");
cmd.createArgument().setValue(serviceName);
}

if (portName != null && portName.length() > 0) {
if (portName != null && !portName.isEmpty()) {
cmd.createArgument().setValue("-portname");
cmd.createArgument().setValue(portName);
}
Expand All @@ -307,7 +307,7 @@ protected CommandlineJava setupCommand() {
}

// r option
if (null != getResourcedestdir() && !getResourcedestdir().getName().equals("")) {
if (null != getResourcedestdir() && !getResourcedestdir().getName().isEmpty()) {
cmd.createArgument().setValue("-r");
cmd.createArgument().setFile(getResourcedestdir());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -32,6 +32,7 @@
*
* @author lukas
*/
@SuppressWarnings({"exports"})
public class WsImportBase extends WsTask2 {

/**
Expand Down Expand Up @@ -430,7 +431,7 @@ protected CommandlineJava setupCommand() {
}

//catalog
if((getCatalog() != null) && (getCatalog().getName().length() > 0)){
if((getCatalog() != null) && (!getCatalog().getName().isEmpty())){
cmd.createArgument().setValue("-catalog");
cmd.createArgument().setFile(getCatalog());
}
Expand Down Expand Up @@ -459,7 +460,7 @@ protected CommandlineJava setupCommand() {
}

//package
if((getPackage() != null) && (getPackage().length() > 0)){
if((getPackage() != null) && (!getPackage().isEmpty())){
cmd.createArgument().setValue("-p");
cmd.createArgument().setValue(getPackage());
}
Expand Down Expand Up @@ -505,7 +506,7 @@ protected CommandlineJava setupCommand() {
}
}

if((wsdlLocation != null) && (wsdlLocation.length() != 0)){
if((wsdlLocation != null) && (!wsdlLocation.isEmpty())){
cmd.createArgument().setValue("-wsdllocation");
cmd.createArgument().setValue(wsdlLocation);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -500,7 +500,7 @@ protected final void execute(String tool, String toolClass) throws BuildExceptio
*/
protected CommandlineJava setupCommand() {
// d option
if (null != getDestdir() && !getDestdir().getName().equals("")) {
if (null != getDestdir() && !getDestdir().getName().isEmpty()) {
getCommandline().createArgument().setValue("-d");
getCommandline().createArgument().setFile(getDestdir());
}
Expand All @@ -517,7 +517,7 @@ protected CommandlineJava setupCommand() {
getCommandline().createArgument().setValue("-keep");
}
// s option
if (null != getSourcedestdir() && !getSourcedestdir().getName().equals("")) {
if (null != getSourcedestdir() && !getSourcedestdir().getName().isEmpty()) {
getCommandline().createArgument().setValue("-s");
getCommandline().createArgument().setFile(getSourcedestdir());
}
Expand Down Expand Up @@ -582,29 +582,29 @@ public void setupForkCommand(String className) {
cp.append(mvn);
}

if (getModulepath() != null && getModulepath().size() > 0) {
if (getModulepath() != null && !getModulepath().isEmpty()) {
getCommandline().createModulepath(getProject()).add(getModulepath());
}

if (getUpgrademodulepath() != null && getUpgrademodulepath().size() > 0) {
if (getUpgrademodulepath() != null && !getUpgrademodulepath().isEmpty()) {
getCommandline().createUpgrademodulepath(getProject()).add(getUpgrademodulepath());
}
if (getAddmodules() != null && getAddmodules().length() > 0) {
if (getAddmodules() != null && !getAddmodules().isEmpty()) {
getCommandline().createVmArgument().setLine("--add-modules " + getAddmodules());
}
if (getAddreads() != null && getAddreads().length() > 0) {
if (getAddreads() != null && !getAddreads().isEmpty()) {
getCommandline().createVmArgument().setLine("--add-reads " + getAddreads());
}
if (getAddexports() != null && getAddexports().length() > 0) {
if (getAddexports() != null && !getAddexports().isEmpty()) {
getCommandline().createVmArgument().setLine("--add-exports " + getAddexports());
}
if (getAddopens() != null && getAddopens().length() > 0) {
if (getAddopens() != null && !getAddopens().isEmpty()) {
getCommandline().createVmArgument().setLine("--add-opens " + getAddopens());
}
if (getPatchmodule() != null && getPatchmodule().length() > 0) {
if (getPatchmodule() != null && !getPatchmodule().isEmpty()) {
getCommandline().createVmArgument().setLine("--patch-module " + getPatchmodule());
}
if (getLimitmodules() != null && getLimitmodules().length() > 0) {
if (getLimitmodules() != null && !getLimitmodules().isEmpty()) {
getCommandline().createVmArgument().setLine("--limit-modules " + getLimitmodules());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -67,7 +67,7 @@ public void visit(Fault fault) throws Exception {
}

private boolean isRegistered(Fault fault) {
if(faults.keySet().contains(fault.getJavaException().getName())){
if(faults.containsKey(fault.getJavaException().getName())){
fault.setExceptionClass(faults.get(fault.getJavaException().getName()));
return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -108,11 +108,11 @@ public void visit(Operation operation) throws Exception {
if (operation.getResponse() != null) {
operation.getResponse().accept(this);
}
Iterator faults = operation.getFaultsSet().iterator();
Iterator<Fault> faults = operation.getFaultsSet().iterator();
if (faults != null) {
Fault fault;
while (faults.hasNext()) {
fault = (Fault) faults.next();
fault = faults.next();
fault.accept(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -33,7 +33,7 @@ public enum GeneratorConstants {

private String value;

private GeneratorConstants(String value) {
GeneratorConstants(String value) {
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -354,7 +354,7 @@ private String transToValidJavaIdentifier(String s) {

private String makePackageQualified(String s) {
s = transToValidJavaIdentifier(s);
if (options.defaultPackage != null && !options.defaultPackage.equals("")) {
if (options.defaultPackage != null && !options.defaultPackage.isEmpty()) {
return options.defaultPackage + "." + s;
} else {
return s;
Expand Down Expand Up @@ -424,10 +424,10 @@ private String getBindingType(QName bName) {
if (model.getEntity() instanceof Definitions) {
Definitions definitions = (Definitions) model.getEntity();
if (definitions != null) {
Iterator bindings = definitions.bindings();
Iterator<Binding> bindings = definitions.bindings();
if (bindings != null) {
while (bindings.hasNext()) {
Binding binding = (Binding) bindings.next();
Binding binding = bindings.next();
if (bName.getLocalPart().equals(binding.getName())
&& bName.getNamespaceURI().equals(binding.getNamespaceURI())) {
List<TWSDLExtension> bindextends = (List<TWSDLExtension>) binding
Expand Down Expand Up @@ -519,7 +519,7 @@ public static List<ImplFile> toImplFiles(List<String> qualifiedClassNames) {

private static File makePackageDir(WsimportOptions options) {
File ret = null;
if (options.defaultPackage != null && !options.defaultPackage.equals("")) {
if (options.defaultPackage != null && !options.defaultPackage.isEmpty()) {
String subDir = options.defaultPackage.replace('.', '/');
ret = new File(options.implDestDir, subDir);
} else {
Expand Down Expand Up @@ -566,7 +566,7 @@ private static boolean equalsNSOptional(String strQName, QName checkQN) {
strQName = strQName.trim();
QName reqQN = QName.valueOf(strQName);

if (reqQN.getNamespaceURI() == null || reqQN.getNamespaceURI().equals(""))
if (reqQN.getNamespaceURI() == null || reqQN.getNamespaceURI().isEmpty())
return reqQN.getLocalPart().equals(checkQN.getLocalPart());

return reqQN.equals(checkQN);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand All @@ -19,7 +19,6 @@
import com.sun.tools.ws.processor.model.jaxb.JAXBType;
import com.sun.tools.ws.processor.model.jaxb.JAXBTypeAndAnnotation;
import com.sun.tools.ws.wscompile.ErrorReceiver;
import com.sun.tools.ws.wscompile.Options;
import com.sun.tools.ws.wscompile.WsimportOptions;
import com.sun.tools.ws.wsdl.document.soap.SOAPStyle;
import com.sun.tools.ws.wsdl.document.PortType;
Expand Down Expand Up @@ -210,14 +209,14 @@ private void writeWebMethod(Operation operation, JMethod m) {
webMethodAnn.param("operationName", operationName);
}

if (operation.getSOAPAction() != null && operation.getSOAPAction().length() > 0){
if (operation.getSOAPAction() != null && !operation.getSOAPAction().isEmpty()){
webMethodAnn.param("action", operation.getSOAPAction());
}

if (operation.getResponse() == null){
m.annotate(jakarta.jws.Oneway.class);
}else if (!operation.getJavaMethod().getReturnType().getName().equals("void") &&
operation.getResponse().getParametersList().size() > 0){
!operation.getResponse().getParametersList().isEmpty()){
Block block;
String resultName = null;
String nsURI = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand Down Expand Up @@ -35,7 +35,6 @@
import com.sun.tools.ws.processor.model.java.JavaInterface;
import com.sun.tools.ws.resources.GeneratorMessages;
import com.sun.tools.ws.wscompile.ErrorReceiver;
import com.sun.tools.ws.wscompile.Options;
import com.sun.tools.ws.wscompile.WsimportOptions;
import com.sun.tools.ws.wsdl.document.PortType;
import com.sun.xml.ws.spi.db.BindingHelper;
Expand Down

0 comments on commit fbd1eef

Please sign in to comment.