0

when I view java source code referenced from Intellij IDEA,I find some variables named like var+Number.

For example, below code is from org.springframework.context

public interface MessageSource {
  @Nullable
  String getMessage(String var1, @Nullable Object[] var2, @Nullable String var3, Locale var4);

  String getMessage(String var1, @Nullable Object[] var2, Locale var3) throws NoSuchMessageException;

  String getMessage(MessageSourceResolvable var1, Locale var2) throws NoSuchMessageException;
}

Logger in org.slf4j

public interface Logger {
  String ROOT_LOGGER_NAME = "ROOT";

  String getName();

  boolean isTraceEnabled();

  void trace(String var1);

  void trace(String var1, Object var2);

   ...
   ...
   ...
}

Can anybody tell me for what purpose?

Updated:
Thanks for your reply,according the responses, now I have known the reason. This is really IDE decompiled code. IDEA using fernflower decompile .class files. At the beginning, I am confused by variable names, I found some are readable names, some are formed like var{Number}, after checking fernflower source code, I realized that is the decompiling strategy.


Zack
  • 1
  • 1
  • what is your lang? edit tag and need more detail, ask about issue in one question. – A1Gard Feb 24 '21 at 11:12
  • Note: your IDE tells you that it *decompiled* the class files. What your IDE is showing you is NOT the "real" source code. But something un-compiled from class files. – GhostCat Feb 24 '21 at 13:06

1 Answers1

4

If this is indeed source code from the Spring framework, then it looks like you actually opened the compiled .class file, and your IDE decompiled it and shows this decompiled code. Bytecode usually doesn't contain the actual variable names, that were initially used in the real source code, so the decompiler needs to create them.

For reference, here: https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/springframework/context/MessageSource.java you can find the real source code, and as you can see the variables have proper names here (as well as the Javadocs, which are part of the sourcecode, but also missing in your example, which is another point to the decompiling direction, since compiled files also don't contain any Javadoc.

dunni
  • 43,386
  • 10
  • 104
  • 99