0

In a Java/Spring/C# project, I intend to have a list of returncodes which shall be available at both sides: Java and C#. First guess was to have a file which is available in both worlds and defines constants:

private static final int RC_NO_ERROR = 0;

Unfortunately, final is not known to C#, and the C# equivalents const, sealed and readonly are not known to Java. Is there any easy way like a preprocessor which helps with that? Can I "define" the keyword final to be at least tolerated if not recognized as const and friends?

My plan b woud be to let sed/awk do the job but I would prefer a solution which does not involve a tool chain step.

Twonky
  • 796
  • 13
  • 31
  • 2
    äh? what are you trying to do? are pasting code from java in VisualStudio? – ΦXocę 웃 Пepeúpa ツ Dec 09 '16 at 10:12
  • There´s no pre-processor as you may know from C that allows you to replace any content within the source-code by some other content. But it´s quite unclaer *why* you even need this. Why do you switch between C# and Java all the time? Are you writing a multi-language app? – MakePeaceGreatAgain Dec 09 '16 at 10:19
  • Try to read those answers [C# sealed vs Java final](http://stackoverflow.com/questions/10170633/c-sharp-sealed-vs-java-final) – krypru Dec 09 '16 at 10:26
  • Probably in near future You will ask about more than const compatible in two language protocol Java/C##. Read about multi-language protocols builders like Thrift, Protobuf, (old SOAP too) and few more – Jacek Cz Dec 09 '16 at 11:52

1 Answers1

0

Just dont use "final" in Java? Yes, then it is no constant, but since it is private, you can hold yourself back not to modify it later.

Thomas Philipp
  • 261
  • 1
  • 5