Search code examples
javagwtjsni

Benefit of private final native vs private native


I know the meaning of final.

Is there any reason or benefit to use private final native ... instead of private native ... when doing JSNI calls? The reason I ask is because I am not an expert in JSNI but I assume that adding final would be no different than if it were a non-native call. I have seen a lot of code use private final native .. and I am not sure of the motivation. Some code I am working on is using private final native .. and I am inclined to remove the final qualifier.


Solution

  • If we talk only about GWT, than final keyword is only required on native methods in JSO classes. Otherwise you should only follow standard Java practices, or your team specific practices. Some teams simply prefer to put final on anything that can be final (and usually IDE does this automatically for them) and there are good reasons to do so.