-
Bug
-
Resolution: Unresolved
-
P4
-
8
For some errors and warnings, JSR199 Javac gives a vague diagnostic code for the problem, and hides the more detailed information about the diagnostic.
For instance, for a field declaration such as: List<String> list = new ArrayList();, Javac, when using -Xlint:unchecked, gives a warning with code: compiler.warn.prob.found.req. This is a vague, meaningless warning code and not useful for tools using JSR199 Javac who are trying to act upon diagnostics.
When you look in the diagnostic Object itself, you'll see it has a 'lintCategory' of 'Unchecked' and it has an 'arg' with another Diagnostic that has the code 'compiler.misc.unchecked.assign' which is the code the warning should actually have. Note that both 'lintCategory' and the 'args' are not accessible through JSR199.
Some possible solutions to make sure tools using JSR199 Javac can understand diagnostics better:
1) Make sure the diagnostic code uniquely identifies the problem. Use the code of the Diagnostic in the args, if it's there, which is usually more informative, OR make both codes available.
2) Give access to lintCategory if it's a warning
3) Give access to Diagnostics in the 'args' if they are there.
You can use the attached source to display the warning code.
For instance, for a field declaration such as: List<String> list = new ArrayList();, Javac, when using -Xlint:unchecked, gives a warning with code: compiler.warn.prob.found.req. This is a vague, meaningless warning code and not useful for tools using JSR199 Javac who are trying to act upon diagnostics.
When you look in the diagnostic Object itself, you'll see it has a 'lintCategory' of 'Unchecked' and it has an 'arg' with another Diagnostic that has the code 'compiler.misc.unchecked.assign' which is the code the warning should actually have. Note that both 'lintCategory' and the 'args' are not accessible through JSR199.
Some possible solutions to make sure tools using JSR199 Javac can understand diagnostics better:
1) Make sure the diagnostic code uniquely identifies the problem. Use the code of the Diagnostic in the args, if it's there, which is usually more informative, OR make both codes available.
2) Give access to lintCategory if it's a warning
3) Give access to Diagnostics in the 'args' if they are there.
You can use the attached source to display the warning code.