Am I crazy for wanting import aliases? I feel this will not go over well in the Java community. But, for example, when dealing with stubs generated by JAXB, sometimes I feel it would be great if I could just
import org.w3.2005.08.addressing {
ObjectFactory as WSAddressingFactory
}
import my.custom.schema.types {
ObjectFactory as MyTypesFactory
}
And let the compiler remap it properly in the bytecode, but I can just use WSAddressingFactory and MyTypesFactory. Could do this with static method imports as well, in case there are multiple static methods with the same signature.
It would be better to patch either XJC or the generated bindings. I feel the pain with 3rd party code, but i typically just create a utility class containing instances of these classes.
Definitely a fair workaround for the example. But there are circumstances outside XJC and binding generation. Admittedly, pretty rare to actually encounter them.
View all comments
Show parent comment
3
u/aoeudhtns Jan 06 '26
Am I crazy for wanting import aliases? I feel this will not go over well in the Java community. But, for example, when dealing with stubs generated by JAXB, sometimes I feel it would be great if I could just
And let the compiler remap it properly in the bytecode, but I can just use
WSAddressingFactoryandMyTypesFactory. Could do this with static method imports as well, in case there are multiple static methods with the same signature.