Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java naming clash between method variable and package names

I have some classes generated from WSDL files by the Axis Framework. In one of these classes, there is a generated method


public com.initechsystems.www.initech7.initechbo.Organization createOrganization(com.initechsystems.www.initech7.initechbo.Organization org) throws java.rmi.RemoteException {

//(... snip ...)
_call.setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR, Boolean.FALSE);
//(... snip ...)
}

The variable name org in the method parameter creates a naming clash with package org.apache.axis.client, as the compiler cannot differentiate between the package and variable. I realize I can fix this easily by changing the variable name org in the method, but I would like to avoid this, because it slows down the workflow. Is there some way around this other than either modifying the WSDL file or the generated classes?

Compiler error:


 D:\projects\java\initechdir\target\generated-sources\axistools\wsdl2java\com\initechsystems\www\initech7\initechws\OrganizationManagement\OrganizationManagementSoapStub.java:[1678,29] cannot find symbol
symbol  : variable apache
location: class com.initechsystems.www.initech7.initechbo.Organization
like image 877
simon Avatar asked Dec 05 '25 17:12

simon


1 Answers

Is there a way to cause that generated code to have import statements? That would prevent you from having to have the fully-qualified name of the class.

So, if you could add:

import org.apache.axis.client.Call;

to the file then your method call would just be:

_call.setProperty(Call.SEND_TYPE_ATTR, Boolean.FALSE);

I'm not sure if Axis has an option for that though. If not I'd say renaming the variable (maybe to "organization") would be the best thing. I would recommend avoiding manual edits of auto-generated files, as that makes regenerating them harder.

like image 99
Herms Avatar answered Dec 08 '25 08:12

Herms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!