A compiler looks at source code from quite a different perspective that humans do. You gradually get to know what your compiler really means when it says baffling things like { expected.
Sometimes a single syntax error starts off an avalanche of baffling compiler error messages. As a general rule, look slightly earlier or later of where the compiler is complaining. Fix any problems there and recompile. Most of the time the other errors will disappear.
I repeat, don’t waste time trying to figure out arcane messages. Correct what you can and recompile. Most of the time the arcane ones will mysteriously disappear.
When you start using a compiler, it is a good idea to deliberately make some common errors and see what the compiler says. Then you can make a table to help you later when you inadvertently make that error. (That is how I created many of the entries in the tables run time error messages and compile time error messages.)
When you make an error, get a baffling error message and eventually figure out what it means, make a note to yourself to help in future when that error message appears again.
It also helps to have two or three compilers on tap. When you get a really baffling error message, try some other compilers. With three variants on the error message, you have extra clues what it really means. Jikes in particular offers additional insight since its error messages are quite different from Oracle’s. Conversely, if you use Jikes, Oracle’s messages can be enlightening.
This tables run time error messages and compile time error messages were constructed merging error messages from several compilers including Symantec Visual Café, IBM (International Business Machines) Visual Age, IBM Jikes, JBuilder 3 and various Sun JDKs (Java Development Kits). Please submit baffling messages from your favourite compiler. I also include run-time messages.
I make no attempt to keep track of which error messages came from which compilers. Take all advice with a grain of salt. There are many possible causes for any given error message. I would hope this is obvious, but only one of my listed conditions needs to be met for the error to occur, not all of them. Further, the appearance of an error message is no guarantee that any of the listed conditions apply. These are just hints as to what might be the matter.
Another general hint is to delete all class files and recompile. Sometimes the problem is caused by references to renamed or discontinued code. Until the class files are removed, references to them are still valid. You may be getting the old code instead of the new.
Don’t sweat every error message. When you correct some, the strange ones often mysteriously disappear. Only the authors of the compiler have any hope of understanding the chain of causality. Just fix what you can and recompile. If you have Jikes, you can fix just two three errors before recompiling in the hopes many cascaded errors will disappear.
For totally mysterious errors, look at your source code file with a hex viewer. There may be code way off screen to the right. There may be strange control characters embedded in your file.
If you don’t find the puzzling error message in thse tables run time error messages and compile time error messages tables, you can do two things:
If you first don’t find the error message. Skim the both tables for it. I may have filed it differently from the way you would. Use your browser find feature to look for key words in your error message. There is no totally obvious order in which to file them. It might be worth your while just to scan the entire list every once is a while to refresh your memory on what is in there.
Use search engines, Google Groups, the newsgroups such as comp.lang.java.programmer and the Java Developer Connection web pages to see if others have reported a similar bug.
You can report bugs in Microsoft’s SDK (Software Development Kit)
If you think you have found a new bug, build a small test case that clearly demonstrates the bug. Most reported bugs are not bugs at all, but coding errors. If you can keep your example small enough, you will be much more convincing that you truly have found a bug. Ask a friend to test the code on another platform to help decide if the problem is with the compiler or the JVM (Java Virtual Machine) or a native library.
You can see the complete list of 300 odd Java error messages in file lib/tools.jar in member sun/tools/javac/resources/javac.properties. Unfortunately, it contains only the raw text of the messages, not explanations of what the error messages mean or what can possibly cause the errors.
Finally, if you would just like to complain about the design of Java or its implementation, you can expound on the comp.lang.java.advocacy newsgroup or send email to feedback@java.sun.com.
This page is posted |
http://mindprod.com/jgloss/errormessages.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\errormessages.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[13.58.188.166] |
| |
Feedback |
You are visitor number | |