I am assuming that the operators must be defined somewhere in some sort of java file in the language, where could I find the implementation or definitions of the operators in the java language?
Asked
Active
Viewed 52 times
0
-
No they are not. – luk2302 Jul 18 '20 at 19:49
-
Just google "Java operators": https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html – DV82XL Jul 18 '20 at 22:41
2 Answers
5
They're not defined in Java, because otherwise you have an infinite regress. They're defined in the Java Language Specification (specifically section 3.12).

chrylis -cautiouslyoptimistic-
- 75,269
- 21
- 115
- 152
-
What do you mean by "infinite regress"? Why would (theoretical) operator definition lead to any such problems? – luk2302 Jul 20 '20 at 09:49
-
@luk2302 There has to be some base implementation somewhere that is not the language itself. Even Lisp has to have "base cases" of parentheses and `defun`. – chrylis -cautiouslyoptimistic- Jul 20 '20 at 13:44
1
The definition of the operators is in the Java Language Specification, in Chapter 15. Expressions, starting with sub-chapter 15.14.
The implementation of the operators is partly in the Java Compiler, which converts the operators to bytecode, and in the JVM, which executes the bytecode. Neither are written in Java, so your assumption about that is wrong.
See also:
Where is the source code for the java compiler?
Is JVM open source code?

Andreas
- 154,647
- 11
- 152
- 247