--- old/test/jdk/java/util/Scanner/ScanTest.java 2019-03-18 15:37:08.000000000 +0100 +++ new/test/jdk/java/util/Scanner/ScanTest.java 2019-03-18 15:37:07.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2019, 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 @@ -49,19 +49,23 @@ private static File inputFile = new File(System.getProperty("test.src", "."), "input.txt"); public static void main(String[] args) throws Exception { - - Locale reservedLocale = Locale.getDefault(); - String lang = reservedLocale.getLanguage(); + final List supportedLocales = List.of( + Locale.US, + Locale.UK, + Locale.CHINA, + Locale.KOREA, + Locale.JAPAN, + Locale.GERMANY); + Locale defaultLocale = Locale.getDefault(); try { - if (!"en".equals(lang) && - !"zh".equals(lang) && - !"ko".equals(lang) && - !"ja".equals(lang)) { + if (!supportedLocales.contains(defaultLocale)) { //Before we have resource to improve the test to be ready for //arbitrary locale, force the default locale to be "English" //for now. First we check whether the "English" locale is //available on the system as it could be absent due to varying //configurations. + System.out.println("Default locale " + defaultLocale + + " is not supported in this test, trying to change to ENGLISH."); if (!Arrays.asList(Locale.getAvailableLocales()) .contains(Locale.ENGLISH)) { throw new RuntimeException @@ -128,7 +132,7 @@ System.err.println("OKAY: All tests passed."); } finally { // restore the default locale - Locale.setDefault(reservedLocale); + Locale.setDefault(defaultLocale); } }