The formatter spec says of the 's' general conversion:
If the '#' flag is given and the argument is not a Formattable,
then a FormatFlagsConversionMismatchException will be thrown.
but the implementation fails to do that:
==========$ cat -n T.java
1 import java.util.*;
2 class T {
3 public static void main(String[] args) {
4 System.out.printf("%#s%n", 0);
5 }
6 }
==========$ /usr/j2sdk1.5.0/bin/javac T.java
==========$ /usr/j2sdk1.5.0/bin/java T
0
==========$
If the '#' flag is given and the argument is not a Formattable,
then a FormatFlagsConversionMismatchException will be thrown.
but the implementation fails to do that:
==========$ cat -n T.java
1 import java.util.*;
2 class T {
3 public static void main(String[] args) {
4 System.out.printf("%#s%n", 0);
5 }
6 }
==========$ /usr/j2sdk1.5.0/bin/javac T.java
==========$ /usr/j2sdk1.5.0/bin/java T
0
==========$
- duplicates
-
JDK-6344301 (fmt) java.util.Formatter specified exception is not thrown
- Closed
- relates to
-
JDK-7081794 java.util.Formatter fails to format numbers with legal pattern '%1$#8s'
- Closed
-
JDK-7007868 Regression for java.lang.String,format FormatFlagsConversionMismatchException: C
- Closed