< prev index next >

test/jdk/java/util/Scanner/FailingConstructors.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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.

@@ -21,20 +21,21 @@
  * questions.
  */
 
 /**
  * @test
- * @bug 7000511
+ * @bug 7000511 8190577
  * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when
  *          exception thrown
  */
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.util.Scanner;
 
 public class FailingConstructors {
     static final String fileName = "FailingConstructorsTest";

@@ -63,11 +64,18 @@
         }
 
         check(exists, file);
 
         try {
-            new Scanner(file, null);
+            new Scanner(file, (String)null);
+            fail();
+        } catch(FileNotFoundException|NullPointerException e) {
+            pass();
+        }
+
+        try {
+            new Scanner(file, (Charset)null);
             fail();
         } catch(FileNotFoundException|NullPointerException e) {
             pass();
         }
 

@@ -82,11 +90,18 @@
         }
 
         check(exists, file);
 
         try {
-            new Scanner(file.toPath(), null);
+            new Scanner(file.toPath(), (String)null);
+            fail();
+        } catch(FileNotFoundException|NullPointerException e) {
+            pass();
+        }
+
+        try {
+            new Scanner(file.toPath(), (Charset)null);
             fail();
         } catch(FileNotFoundException|NullPointerException e) {
             pass();
         }
 
< prev index next >