-
Bug
-
Resolution: Cannot Reproduce
-
P5
-
None
-
6
-
generic
-
generic
JavacTool will not take compiler options with .java file but are allowed with arg file.
Please see the following test case:
<code>
import java.io.*;
import javax.tools.*;
public class Test5 {
public static final String sourceFile1 = "-Xlint /home/sa151881/javatrails/SWarnings/unchecked/Test16.java";
public static final String sourceFile2 = "-Xlint:unchecked /home/sa151881/javatrails/SWarnings/unchecked/Test16.java";
public static final String sourceFile3 = "@/home/sa151881/javatrails/SWarnings/unchecked/filelist";
public static void test(String... args) {
try{
JavacTool javac = com.sun.tools.javac.Tool.create();
DiagnosticListener dl = new DiagnosticListener() {
public void problemFound(DiagnosticMessage message) {
System.out.println(new File(message.getSourceName().toString()).getName()+":"+
message.getStartPosition()+":"+message.getStartPosition()
+":"+message.getPosition());
System.out.println(message.toString());
System.out.flush();
}
};
PrintWriter writer = new PrintWriter(new OutputStream(){
public void write(int b) {}
});
javac.run((InputLocator)null, null, dl, writer, args);
}catch(Exception ex){
ex.printStackTrace();
}
}
public static void main(String... arg){
try{
Test5 test = new Test5();
System.err.println("With '-Xlint'");
test.test(Test5.sourceFile1);
System.err.println("With '-Xlint:unchecked'");
test.test(Test5.sourceFile2);
System.err.println("With arg file");
test.test(Test5.sourceFile3);
}catch(Exception ex){
ex.printStackTrace();
}
}
}
</code>
Test16.java, Test1.java and filelist are attached.
Output of the code:
<output>
bash-2.05b$ $b/java Test5
With '-Xlint'
__input:-1:-1:-1
error: cannot read: -Xlint /home/sa151881/javatrails/SWarnings/unchecked/Test16.java
With '-Xlint:unchecked'
With arg file
Test16.java:119:119:119
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:7: name clash: TestConstructor(K) and TestConstructor(T) have the
same erasure
Test16.java:201:201:201
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:11: name clash: TestConstructor(T) and TestConstructor(K) have th
e same erasure
Test16.java:284:284:284
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:15: name clash: setT(T) and setT(K) have the same erasure
Test16.java:356:356:356
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:19: name clash: setT(K) and setT(T) have the same erasure
Test16.java:567:567:567
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:31: incompatible types
found : T
required: T
Test16.java:684:684:684
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:37: setT(java.lang.Object) in TestC cannot be applied to ()
Test16.java:722:722:722
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:38: reference to TestConstructor is ambiguous, both method TestCo
nstructor(K) in TestConstructor and method TestConstructor(T) in TestConstructor match
Test16.java:722:722:722
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:38: warning: [unchecked] unchecked call to TestConstructor(K) as
a member of the raw type TestConstructor
Test16.java:761:761:761
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:39: reference to setT is ambiguous, both method setT(T) in TestCo
nstructor and method setT(K) in TestConstructor match
Test16.java:766:766:766
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:39: warning: [unchecked] unchecked call to setT(T) as a member of
the raw type TestConstructor
Test16.java:805:805:805
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:40: warning: [unchecked] unchecked conversion
found : TestC
required: TestC<java.lang.Integer>
Test1.java:379:379:379
/home/sa151881/javatrails/SWarnings/unchecked/Test1.java:14: warning: [unchecked] unchecked call to add(E) as a member of t
he raw type java.util.List
Test1.java:415:415:415
/home/sa151881/javatrails/SWarnings/unchecked/Test1.java:15: warning: [unchecked] unchecked call to add(E) as a member of t
he raw type java.util.List
Test1.java:478:478:478
/home/sa151881/javatrails/SWarnings/unchecked/Test1.java:17: warning: [unchecked] unchecked call to add(E) as a member of t
he raw type java.util.List
</output>
With -Xlint option the output is
__input:-1:-1:-1
error: cannot read: -Xlint .......\Test16.java
and with -Xlint:unchecked no output. When the same files are given in arg file then JavacTool will workfine and enables unchecked warnings also as expected.
###@###.### 2005-04-22 07:33:55 GMT
Please see the following test case:
<code>
import java.io.*;
import javax.tools.*;
public class Test5 {
public static final String sourceFile1 = "-Xlint /home/sa151881/javatrails/SWarnings/unchecked/Test16.java";
public static final String sourceFile2 = "-Xlint:unchecked /home/sa151881/javatrails/SWarnings/unchecked/Test16.java";
public static final String sourceFile3 = "@/home/sa151881/javatrails/SWarnings/unchecked/filelist";
public static void test(String... args) {
try{
JavacTool javac = com.sun.tools.javac.Tool.create();
DiagnosticListener dl = new DiagnosticListener() {
public void problemFound(DiagnosticMessage message) {
System.out.println(new File(message.getSourceName().toString()).getName()+":"+
message.getStartPosition()+":"+message.getStartPosition()
+":"+message.getPosition());
System.out.println(message.toString());
System.out.flush();
}
};
PrintWriter writer = new PrintWriter(new OutputStream(){
public void write(int b) {}
});
javac.run((InputLocator)null, null, dl, writer, args);
}catch(Exception ex){
ex.printStackTrace();
}
}
public static void main(String... arg){
try{
Test5 test = new Test5();
System.err.println("With '-Xlint'");
test.test(Test5.sourceFile1);
System.err.println("With '-Xlint:unchecked'");
test.test(Test5.sourceFile2);
System.err.println("With arg file");
test.test(Test5.sourceFile3);
}catch(Exception ex){
ex.printStackTrace();
}
}
}
</code>
Test16.java, Test1.java and filelist are attached.
Output of the code:
<output>
bash-2.05b$ $b/java Test5
With '-Xlint'
__input:-1:-1:-1
error: cannot read: -Xlint /home/sa151881/javatrails/SWarnings/unchecked/Test16.java
With '-Xlint:unchecked'
With arg file
Test16.java:119:119:119
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:7: name clash: TestConstructor(K) and TestConstructor(T) have the
same erasure
Test16.java:201:201:201
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:11: name clash: TestConstructor(T) and TestConstructor(K) have th
e same erasure
Test16.java:284:284:284
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:15: name clash: setT(T) and setT(K) have the same erasure
Test16.java:356:356:356
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:19: name clash: setT(K) and setT(T) have the same erasure
Test16.java:567:567:567
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:31: incompatible types
found : T
required: T
Test16.java:684:684:684
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:37: setT(java.lang.Object) in TestC cannot be applied to ()
Test16.java:722:722:722
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:38: reference to TestConstructor is ambiguous, both method TestCo
nstructor(K) in TestConstructor and method TestConstructor(T) in TestConstructor match
Test16.java:722:722:722
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:38: warning: [unchecked] unchecked call to TestConstructor(K) as
a member of the raw type TestConstructor
Test16.java:761:761:761
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:39: reference to setT is ambiguous, both method setT(T) in TestCo
nstructor and method setT(K) in TestConstructor match
Test16.java:766:766:766
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:39: warning: [unchecked] unchecked call to setT(T) as a member of
the raw type TestConstructor
Test16.java:805:805:805
/home/sa151881/javatrails/SWarnings/unchecked/Test16.java:40: warning: [unchecked] unchecked conversion
found : TestC
required: TestC<java.lang.Integer>
Test1.java:379:379:379
/home/sa151881/javatrails/SWarnings/unchecked/Test1.java:14: warning: [unchecked] unchecked call to add(E) as a member of t
he raw type java.util.List
Test1.java:415:415:415
/home/sa151881/javatrails/SWarnings/unchecked/Test1.java:15: warning: [unchecked] unchecked call to add(E) as a member of t
he raw type java.util.List
Test1.java:478:478:478
/home/sa151881/javatrails/SWarnings/unchecked/Test1.java:17: warning: [unchecked] unchecked call to add(E) as a member of t
he raw type java.util.List
</output>
With -Xlint option the output is
__input:-1:-1:-1
error: cannot read: -Xlint .......\Test16.java
and with -Xlint:unchecked no output. When the same files are given in arg file then JavacTool will workfine and enables unchecked warnings also as expected.
###@###.### 2005-04-22 07:33:55 GMT
- duplicates
-
JDK-6362759 bogus -Xlint suboption is ignored by compiler
- Closed