Forums Register Login

Process of Compilation and Linkage

+Pie Number of slices to send: Send
Hi ranchers,

how the javac produces compiler errors. what is the process of
compilation of the source code.

Many of the answers include 'wont compile'.

Does it include only the syntax or any other process
involved.
+Pie Number of slices to send: Send
Sorry, but this question has to be moved to our beginner's forum: Java in General (Beginner).
+Pie Number of slices to send: Send
Welcome to the ranch, Mohan!

Compilers are pretty darned complex things, but we can talk about a few of the steps they go through. Among the first is a syntax check. The compiler makes sure you have used valid characters, keywords, variable names, punctuation and so on. If you're like me you've gotten a variety of compiler errors at this point like unmatched parens or missing semi-colons.

Then it builds an internal model of the program. I think JavaC builds an Abstract Sytax Tree that represents classes, methods, statements and so on down to the leaf operands of every clause. Now the compiler might find errors like casting or numeric truncation.

You mentioned linkage in the topic, but Java doesn't have an explicit LINK step like C or the mainframe COBOL I used to know. The compiler looks for references to other classes or interfaces and makes sure it can find them in other class files, jars, or wherever. In this phase you'll get errors like class not found or a method signature that doesn't match.

At run time the JVM looks for them all over again and may or may not find exactly the same ones the compiler found, which also leads to interesting error messages.

One could generate byte code right from the model, I think. Modern compilers examine the tree and/or the byte code and look for chances to optimize. This is pretty deep voodoo that I don't pretend to know but it often involves removing instructions that don't have any effect or maybe moving code around to eliminate calls or loops.

Any of that help?
[ October 26, 2005: Message edited by: Stan James ]
Looky! I'm being abducted by space aliens! Me and this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 532 times.
Similar Threads
a little jar problem
which way to import
Learning Servlet code
import statements
Include JSP/JSF pages into other JSP/JSF pages
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:21:54.