changeset 52933:03e5ab63f7b4 intrinsics

imported patch formatter-tests
author jlaskey
date Tue, 30 Oct 2018 13:53:26 -0300
parents ea53f37a1f64
children d8323e0e38af
files test/jdk/java/util/Formatter/Basic-X.java.template test/jdk/java/util/Formatter/BasicBigDecimal.java test/jdk/java/util/Formatter/BasicBigInteger.java test/jdk/java/util/Formatter/BasicBoolean.java test/jdk/java/util/Formatter/BasicBooleanObject.java test/jdk/java/util/Formatter/BasicByte.java test/jdk/java/util/Formatter/BasicByteObject.java test/jdk/java/util/Formatter/BasicChar.java test/jdk/java/util/Formatter/BasicCharObject.java test/jdk/java/util/Formatter/BasicDateTime.java test/jdk/java/util/Formatter/BasicDouble.java test/jdk/java/util/Formatter/BasicDoubleObject.java test/jdk/java/util/Formatter/BasicFloat.java test/jdk/java/util/Formatter/BasicFloatObject.java test/jdk/java/util/Formatter/BasicInt.java test/jdk/java/util/Formatter/BasicIntObject.java test/jdk/java/util/Formatter/BasicLong.java test/jdk/java/util/Formatter/BasicLongObject.java test/jdk/java/util/Formatter/BasicShort.java test/jdk/java/util/Formatter/BasicShortObject.java test/jdk/java/util/Formatter/EncodingTest.java test/jdk/java/util/Formatter/FormatLocale.java test/jdk/java/util/Formatter/JavacIntrinsicsSupport.java test/jdk/java/util/Formatter/NullArg.java
diffstat 24 files changed, 1698 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/java/util/Formatter/Basic-X.java.template	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/Basic-X.java.template	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 #if[datetime]
--- a/test/jdk/java/util/Formatter/BasicBigDecimal.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicBigDecimal.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicBigInteger.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicBigInteger.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicBoolean.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicBoolean.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicBooleanObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicBooleanObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicByte.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicByte.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicByteObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicByteObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicChar.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicChar.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicCharObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicCharObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicDateTime.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicDateTime.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicDouble.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicDouble.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicDoubleObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicDoubleObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicFloat.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicFloat.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicFloatObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicFloatObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicInt.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicInt.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicIntObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicIntObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicLong.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicLong.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicLongObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicLongObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicShort.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicShort.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/BasicShortObject.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/BasicShortObject.java	Tue Oct 30 13:53:26 2018 -0300
@@ -52,6 +52,9 @@
         f = new Formatter(new StringBuilder(), Locale.US);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args);
     }
 
     private static void test(Locale l, String fs, String exp, Object ... args)
@@ -63,6 +66,9 @@
         f = new Formatter(new StringBuilder(), l);
         f.format("foo " + fs + " bar", args);
         ck(fs, "foo " + exp + " bar", f.toString());
+
+        JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args);
+        JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args);
     }
 
     private static void test(String fs, Object ... args) {
@@ -110,6 +116,42 @@
                 fail(fs, ex.getClass());
             }
         }
+        testSysOutIntrinsic(fs, exp, args);
+    }
+
+    private static void testSysOutIntrinsic(String fs, String exp, Object ... args) {
+        FileOutputStream fos = null;
+        FileInputStream fis = null;
+        try {
+            PrintStream saveOut = System.out;
+            fos = new FileOutputStream("testSysOut");
+            System.setOut(new PrintStream(fos));
+            JavacIntrinsicsSupport.printStreamFormat(System.out, Locale.US, fs, args);
+            fos.close();
+
+            fis = new FileInputStream("testSysOut");
+            byte [] ba = new byte[exp.length()];
+            int len = fis.read(ba);
+            String got = new String(ba);
+            if (len != ba.length)
+                fail(fs, exp, got);
+            ck(fs, exp, got);
+
+            System.setOut(saveOut);
+        } catch (FileNotFoundException ex) {
+            fail(fs, ex.getClass());
+        } catch (IOException ex) {
+            fail(fs, ex.getClass());
+        } finally {
+            try {
+                if (fos != null)
+                    fos.close();
+                if (fis != null)
+                    fis.close();
+            } catch (IOException ex) {
+                fail(fs, ex.getClass());
+            }
+        }
     }
 
     private static void tryCatch(String fs, Class<?> ex) {
@@ -124,6 +166,8 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex);
     }
 
     private static void tryCatch(String fs, Class<?> ex, Object ... args) {
@@ -138,6 +182,36 @@
             fail(fs, ex);
         else
             pass();
+
+        tryCatchIntrinsic(fs, ex, args);
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail");
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
+    }
+
+    private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) {
+        boolean caught = false;
+        try {
+            JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args);
+        } catch (Throwable x) {
+            if (ex.isAssignableFrom(x.getClass()))
+                caught = true;
+        }
+        if (!caught)
+            fail(fs, ex);
+        else
+            pass();
     }
 
 
--- a/test/jdk/java/util/Formatter/EncodingTest.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/EncodingTest.java	Tue Oct 30 13:53:26 2018 -0300
@@ -91,6 +91,26 @@
                 Files.readAllLines(Paths.get(file2.getPath()), charset));
     }
 
+
+    /**
+     * Verifies that the overloading constructor behaves the same as the existing
+     * one.
+     * @param type the type of the constructor
+     * @param file1 file1 written with the name of a charset
+     * @param file2 file2 written with a charset
+     * @param csn the charset name
+     * @param charset the charset
+     * @throws IOException
+     */
+    @Test(dataProvider = "parameters")
+    public void testConstructorIntrinsic(ConstructorType type, File file1, File file2,
+                                String csn, Charset charset) throws Exception {
+        formatIntrinsic(getFormatter(type, file1.getPath(), csn, null));
+        formatIntrinsic(getFormatter(type, file2.getPath(), null, charset));
+        Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset),
+                Files.readAllLines(Paths.get(file2.getPath()), charset));
+    }
+
     void format(Formatter formatter)
             throws IOException {
         formatter.format("abcde \u00FA\u00FB\u00FC\u00FD");
@@ -99,6 +119,14 @@
         formatter.close();
     }
 
+    void formatIntrinsic(Formatter formatter)
+            throws IOException {
+        JavacIntrinsicsSupport.format(formatter, "abcde \u00FA\u00FB\u00FC\u00FD");
+        JavacIntrinsicsSupport.format(formatter, "Java \uff08\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\uff09");
+        formatter.flush();
+        formatter.close();
+    }
+
 
     Formatter getFormatter(ConstructorType type, String path, String csn, Charset charset)
             throws IOException {
--- a/test/jdk/java/util/Formatter/FormatLocale.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/FormatLocale.java	Tue Oct 30 13:53:26 2018 -0300
@@ -107,6 +107,19 @@
                                 "'. Expected: " + expectedWithDefaultLocale.get(i) +
                                 " Returned: " + sb.toString());
             }
+
+            sb.setLength(0);
+            JavacIntrinsicsSupport.format(new Formatter(sb), conversions.get(i), src.get(i));
+            if (!sb.toString().equals(expectedWithDefaultLocale.get(i))) {
+                throw new RuntimeException(
+                        "Wrong uppercasing while using Formatter.format(" +
+                                "\"" + conversions.get(i) + "\"" +
+                                ") with the default locale: '"
+                                + defaultLocale.get(i) +
+                                "'. Expected: " + expectedWithDefaultLocale.get(i) +
+                                " Returned: " + sb.toString());
+            }
+
         });
 
         // checks whether upper casing uses the locale set during creation of
@@ -125,6 +138,18 @@
                                 "'. Expected: " + expectedWithFormatLocale.get(i) +
                                 " Returned: " + sb.toString());
             }
+
+            sb.setLength(0);
+            JavacIntrinsicsSupport.format(new Formatter(sb, formatLocale.get(i)), conversions.get(i), src.get(i));
+            if (!sb.toString().equals(expectedWithFormatLocale.get(i))) {
+                throw new RuntimeException(
+                        "Wrong uppercasing while using Formatter.format(" +
+                                "\"" + conversions.get(i) + "\"" +
+                                ") with the locale specified during instance" +
+                                " creation: '" + formatLocale.get(i) +
+                                "'. Expected: " + expectedWithFormatLocale.get(i) +
+                                " Returned: " + sb.toString());
+            }
         });
 
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Formatter/JavacIntrinsicsSupport.java	Tue Oct 30 13:53:26 2018 -0300
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.PrintStream;
+import java.lang.invoke.CallSite;
+import java.lang.invoke.FormatterBootstraps;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Formatter;
+import java.util.List;
+import java.util.Locale;
+
+public class JavacIntrinsicsSupport extends Basic {
+
+
+    static void formatAndCheck(String fs, String exp, Locale l, Object... args) {
+        try {
+
+            CallSite cs = FormatterBootstraps.formatterBootstrap(MethodHandles.lookup(), "format",
+                    getFormatterFormatMethodType(args), fs, false, false);
+            Formatter f = new Formatter(new StringBuilder(), l);
+            List<Object> invokeArgs = new ArrayList<>();
+            invokeArgs.add(f);
+            if (args != null) {
+                Collections.addAll(invokeArgs, args);
+            } else {
+                invokeArgs.add(null);
+            }
+            cs.dynamicInvoker().invokeWithArguments(invokeArgs);
+            ck(fs, exp, f.toString());
+
+        } catch (RuntimeException rt) {
+            throw rt;
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    static void format(Formatter f, String fs, Object... args) {
+        try {
+
+            CallSite cs = FormatterBootstraps.formatterBootstrap(MethodHandles.lookup(), "format",
+                    getFormatterFormatMethodType(args), fs, false, false);
+            List<Object> invokeArgs = new ArrayList<>();
+            invokeArgs.add(f);
+            if (args != null) {
+                Collections.addAll(invokeArgs, args);
+            } else {
+                invokeArgs.add(null);
+            }
+            cs.dynamicInvoker().invokeWithArguments(invokeArgs);
+
+        } catch (RuntimeException rt) {
+            throw rt;
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    static String stringFormat(String fs, Object... args) {
+        try {
+
+            CallSite cs = FormatterBootstraps.formatterBootstrap(MethodHandles.lookup(), "format",
+                    getStringFormatMethodType(args), fs, true, false);
+            List<Object> invokeArgs = new ArrayList<>();
+            if (args != null) {
+                Collections.addAll(invokeArgs, args);
+            } else {
+                invokeArgs.add(null);
+            }
+            return (String) cs.dynamicInvoker().invokeWithArguments(invokeArgs);
+
+        } catch (RuntimeException rt) {
+            throw rt;
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    static PrintStream printStreamFormat(PrintStream ps, Locale l, String fs, Object... args) {
+        try {
+
+            CallSite cs = FormatterBootstraps.formatterBootstrap(MethodHandles.lookup(), "format",
+                    getPrintStreamFormatMethodType(args), fs, false, true);
+            List<Object> invokeArgs = new ArrayList<>();
+            invokeArgs.add(ps);
+            invokeArgs.add(l);
+            if (args != null) {
+                Collections.addAll(invokeArgs, args);
+            } else {
+                invokeArgs.add(null);
+            }
+            return (PrintStream) cs.dynamicInvoker().invokeWithArguments(invokeArgs);
+
+        } catch (RuntimeException rt) {
+            throw rt;
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    private static MethodType getFormatterFormatMethodType(Object... args) {
+        MethodType mt = MethodType.methodType(Formatter.class, Formatter.class);
+        if (args != null) {
+            for (Object arg : args) {
+                mt = mt.appendParameterTypes(arg == null ? Object.class : arg.getClass());
+            }
+        } else {
+            mt = mt.appendParameterTypes(Object[].class);
+        }
+        return mt;
+    }
+
+    private static MethodType getStringFormatMethodType(Object... args) {
+        MethodType mt = MethodType.methodType(String.class);
+        if (args != null) {
+            for (Object arg : args) {
+                mt = mt.appendParameterTypes(arg == null ? Object.class : arg.getClass());
+            }
+        } else {
+            mt = mt.appendParameterTypes(Object[].class);
+        }
+        return mt;
+    }
+
+    private static MethodType getPrintStreamFormatMethodType(Object... args) {
+        MethodType mt = MethodType.methodType(PrintStream.class, PrintStream.class, Locale.class);
+        if (args != null) {
+            for (Object arg : args) {
+                mt = mt.appendParameterTypes(arg == null ? Object.class : arg.getClass());
+            }
+        } else {
+            mt = mt.appendParameterTypes(Object[].class);
+        }
+        return mt;
+    }
+}
--- a/test/jdk/java/util/Formatter/NullArg.java	Tue Oct 30 13:53:26 2018 -0300
+++ b/test/jdk/java/util/Formatter/NullArg.java	Tue Oct 30 13:53:26 2018 -0300
@@ -27,7 +27,6 @@
  * @summary Basic test for null argument
  */
 
-import java.util.Formatter;
 import java.util.Locale;
 
 public class NullArg {
@@ -52,11 +51,17 @@
                     if (!String.format("%" + c + ct, null).equals(expected)) {
                         throw new RuntimeException("%t" + ct + "null check failed.");
                     }
+                    if (!JavacIntrinsicsSupport.stringFormat("%" + c + ct, null).equals(expected)) {
+                        throw new RuntimeException("%t" + ct + "null check failed. " + JavacIntrinsicsSupport.stringFormat("%" + c + ct, null) + " // " + expected);
+                    }
                 }
             } else {
                 if (!String.format("%" + c , null).equals(expected)) {
                     throw new RuntimeException("%" + c + "null check failed.");
                 }
+                if (!JavacIntrinsicsSupport.stringFormat("%" + c , null).equals(expected)) {
+                    throw new RuntimeException("%" + c + "null check failed. " + JavacIntrinsicsSupport.stringFormat("%" + c , null) + " // " + expected);
+                }
             }
         }
     }