Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find a list of all the possible Java compile time errors?

Tags:

java

javac

So I'm trying to write a Java program that attempts to compile another Java project, and using any potential errors that come out of the compiler(in this case Javac) the program would attempt to repair the broken code. This is an extremely simplified view of what I'm trying to do, but my real problem is that I can't find any concrete list of errors that may come out of Javac. I don't want to turn this into a giant language war, but C#(of course) has an exact example of what I'm looking for

http://msdn.microsoft.com/en-us/library/ms228296%28v=vs.80%29.aspx

I have already found http://mindprod.com/jgloss/compileerrormessages.html, but as stated somewhere else on this site, this list includes errors from Jikes and other compilers.

If anyone has any info, I would certainly appreciate it.

Edit: If anyone else has ever wondered about this I eventually tore open the tools.jar file located in jdk(version_here)/lib. From there your going to sun/tools/javac/javac.properties if you want to actually read the messages. You will need to extract this folder/file. Hopefully this is hidden somewhere in documentation because I hate for solutions to be this manual. Thank you everyone who posted answers, I'm going to look through everything to get a better approach to this.

like image 263
tkordemon Avatar asked Aug 15 '11 20:08

tkordemon


1 Answers

Well I don't think you'll find anything definite about this. But compiler messages may be internationalized in which case they must be translated, which means that generally there should be only a handful files containing all the error messages.

So this should be useful I think. Seems like you should have a closer look at the compiler.properties file in the javac source - not perfect obviously but alas I don't think you'll get anything better.

At least this should get you every error they throw and you can then either google it or better grep through the source to find the locations where it is actually thrown to find out the exact reasons.

PS: The file is part of the jdk7 sources, so here's a small example - the complete file is ~1.5kloc

# 0: symbol, 1: string, 2: string
compiler.err.cant.inherit.diff.arg=\
    {0} cannot be inherited with different arguments: <{1}> and <{2}>

compiler.err.catch.without.try=\
    ''catch'' without ''try''

# 0: symbol kind, 1: symbol
compiler.err.clash.with.pkg.of.same.name=\
    {0} {1} clashes with package of same name
like image 73
Voo Avatar answered Sep 22 '22 05:09

Voo