This article has been confirmed to work in the following environments. However, I think that the content is valid for other versions and other vendors (´ ・ ω ・ `)
C:\jdk>java -version
openjdk version "12" 2019-03-19
OpenJDK Runtime Environment (build 12+33)
OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)
C:\jdk>javac -version
javac 12
For example, if you have the following code:
import java.util.List;
public class Sample {
public static void main(String[] args) {
List list001;
List list002;
List list003;
List list004;
List list005;
//Omitted because it is long
List list196;
List list197;
List list198;
List list199;
List list200;
}
}
Since it is complicated, some parts are omitted, but 200 List
s are declared as the prototype (Raw Type). So when I compile with the -Xlint
option, I want 200 warnings to be output, but in reality only 100 are output.
C:\jdk>javac -Xlint Sample.java
Sample.java:5:warning:[rawtypes]Raw type found: List
List list001;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:6:warning:[rawtypes]Raw type found: List
List list002;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:7:warning:[rawtypes]Raw type found: List
List list003;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
(Omitted because it is long as usual)
Sample.java:102:warning:[rawtypes]Raw type found: List
List list098;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:103:warning:[rawtypes]Raw type found: List
List list099;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:104:warning:[rawtypes]Raw type found: List
List list100;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
100 warnings
The maximum number of compile-time warnings can be set with the -Xmaxwarns
option. This value seems to be 100 by default, so in the above example only 100 warnings were output. Therefore, if you want to output 200 warnings, or if you want to output unlimited warnings, you can set a huge value in the -Xmaxwarns
option.
C:\jdk>javac -Xlint -Xmaxwarns 999999 Sample.java
Sample.java:5:warning:[rawtypes]Raw type found: List
List list001;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:6:warning:[rawtypes]Raw type found: List
List list002;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:7:warning:[rawtypes]Raw type found: List
List list003;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
(Omitted because it is long)
Sample.java:202:warning:[rawtypes]Raw type found: List
List list198;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:203:warning:[rawtypes]Raw type found: List
List list199;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
Sample.java:204:warning:[rawtypes]Raw type found: List
List list200;
^
Generic class List<E>No type argument for
If E is a type variable:
E extends Object declared in the interface List
200 warnings
--Bonus 1: Not only warnings, but also the maximum value of compilation errors can be specified with -Xmaxerrs
.
--Bonus 2: It seems that "default 100 is the maximum" is rare, but basically, if there is even one warning, it should be corrected immediately. Don't turn a blind eye to the warning just because the compilation was successful (self-advised)