Mercurial > hg > release > icedtea7-2.0
changeset 2153:1a1a1952c309
Allow building on systems with a version of GNU Classpath without java.util.Scanner.
2010-05-17 Andrew John Hughes <ahughes@redhat.com>
* patches/boot/icedtea-dbcs.patch,
* patches/boot/icedtea-sbcs.patch,
* patches/boot/icedtea-spp.patch:
Renamed to relate to java.util.Scanner.
* Makefile.am: Fix paths above and add
new patch.
* patches/boot/scanner-charsets.patch:
New patch to remove Scanner usage in
charsetmapping tool.
* patches/boot/scanner-dbcs.patch,
* patches/boot/scanner-sbcs.patch,
* patches/boot/scanner-spp.patch:
Collect together all patches to avoid use
of java.util.Scanner.
author | Andrew John Hughes <ahughes@redhat.com> |
---|---|
date | Mon, 17 May 2010 22:32:12 +0100 |
parents | 8e94f2afbe5f |
children | a8b1c8bb75b9 |
files | ChangeLog Makefile.am patches/boot/icedtea-dbcs.patch patches/boot/icedtea-sbcs.patch patches/boot/icedtea-spp.patch patches/boot/scanner-charsets.patch patches/boot/scanner-dbcs.patch patches/boot/scanner-sbcs.patch patches/boot/scanner-spp.patch |
diffstat | 9 files changed, 233 insertions(+), 146 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon May 17 19:28:25 2010 +0100 +++ b/ChangeLog Mon May 17 22:32:12 2010 +0100 @@ -1,3 +1,20 @@ +2010-05-17 Andrew John Hughes <ahughes@redhat.com> + + * patches/boot/icedtea-dbcs.patch, + * patches/boot/icedtea-sbcs.patch, + * patches/boot/icedtea-spp.patch: + Renamed to relate to java.util.Scanner. + * Makefile.am: Fix paths above and add + new patch. + * patches/boot/scanner-charsets.patch: + New patch to remove Scanner usage in + charsetmapping tool. + * patches/boot/scanner-dbcs.patch, + * patches/boot/scanner-sbcs.patch, + * patches/boot/scanner-spp.patch: + Collect together all patches to avoid use + of java.util.Scanner. + 2010-05-17 Andrew John Hughes <ahughes@redhat.com> * Makefile.am:
--- a/Makefile.am Mon May 17 19:28:25 2010 +0100 +++ b/Makefile.am Mon May 17 22:32:12 2010 +0100 @@ -420,9 +420,10 @@ # Patches for when java.util.Scanner is missing # or has the bug #40630 (all these classes rely # on Scanner#hasNextLine() looping behaviour) -SCANNER_PATCHES = patches/boot/icedtea-spp.patch \ - patches/boot/icedtea-sbcs.patch \ - patches/boot/icedtea-dbcs.patch +SCANNER_PATCHES = patches/boot/scanner-spp.patch \ + patches/boot/scanner-sbcs.patch \ + patches/boot/scanner-dbcs.patch \ + patches/boot/scanner-charsets.patch if LACKS_JAVA_UTIL_SCANNER ICEDTEA_BOOT_PATCHES += $(SCANNER_PATCHES)
--- a/patches/boot/icedtea-dbcs.patch Mon May 17 19:28:25 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -diff -Nru openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java ---- openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java 2010-05-04 14:24:56.000000000 +0100 -+++ openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java 2010-05-04 14:34:01.000000000 +0100 -@@ -27,7 +27,6 @@ - import java.io.*; - import java.util.Arrays; - import java.util.ArrayList; --import java.util.Scanner; - import java.util.Formatter; - import java.util.regex.*; - import java.nio.charset.*; -@@ -39,9 +38,8 @@ - - public static void genClass(String args[]) throws Exception { - -- Scanner s = new Scanner(new File(args[0], args[2])); -- while (s.hasNextLine()) { -- String line = s.nextLine(); -+ BufferedReader s = new BufferedReader(new FileReader(new File(args[0], args[2]))); -+ for (String line = s.readLine(); line != null; line = s.readLine()) { - if (line.startsWith("#") || line.length() == 0) - continue; - String[] fields = line.split("\\s+"); -@@ -188,14 +186,13 @@ - String b2cNR = b2cNRSB.toString(); - String c2bNR = c2bNRSB.toString(); - -- Scanner s = new Scanner(new File(srcDir, template)); -+ BufferedReader s = new BufferedReader(new FileReader(new File(srcDir, template))); - PrintStream ops = new PrintStream(new FileOutputStream( - new File(dstDir, clzName + ".java"))); - if (hisName == null) - hisName = ""; - -- while (s.hasNextLine()) { -- String line = s.nextLine(); -+ for (String line = s.readLine(); line != null; line = s.readLine()) { - if (line.indexOf("$") == -1) { - ops.println(line); - continue;
--- a/patches/boot/icedtea-sbcs.patch Mon May 17 19:28:25 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -diff -Nru openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java ---- openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java 2010-05-04 14:09:01.000000000 +0100 -+++ openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java 2010-05-04 14:17:47.000000000 +0100 -@@ -28,7 +28,6 @@ - import java.io.*; - import java.util.Arrays; - import java.util.ArrayList; --import java.util.Scanner; - import java.util.Formatter; - import java.util.regex.*; - import java.nio.charset.*; -@@ -38,9 +37,8 @@ - - public static void genClass(String args[]) throws Exception { - -- Scanner s = new Scanner(new File(args[0], args[2])); -- while (s.hasNextLine()) { -- String line = s.nextLine(); -+ BufferedReader s = new BufferedReader(new FileReader(new File(args[0], args[2]))); -+ for (String line = s.readLine(); line != null; line = s.readLine()) { - if (line.startsWith("#") || line.length() == 0) - continue; - String[] fields = line.split("\\s+"); -@@ -208,12 +206,11 @@ - String b2cNR = b2cNRSB.toString(); - String c2bNR = c2bNRSB.toString(); - -- Scanner s = new Scanner(new File(srcDir, template)); -+ BufferedReader s = new BufferedReader(new FileReader(new File(srcDir, template))); - PrintStream out = new PrintStream(new FileOutputStream( - new File(dstDir, clzName + ".java"))); - -- while (s.hasNextLine()) { -- String line = s.nextLine(); -+ for (String line = s.readLine(); line != null; line = s.readLine()) { - int i = line.indexOf("$"); - if (i == -1) { - out.println(line);
--- a/patches/boot/icedtea-spp.patch Mon May 17 19:28:25 2010 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -diff -Nru openjdk-boot.orig/jdk/make/tools/src/build/tools/spp/Spp.java openjdk-boot/jdk/make/tools/src/build/tools/spp/Spp.java ---- openjdk-boot.orig/jdk/make/tools/src/build/tools/spp/Spp.java 2008-09-11 08:44:09.000000000 +0100 -+++ openjdk-boot/jdk/make/tools/src/build/tools/spp/Spp.java 2008-09-12 21:34:38.000000000 +0100 -@@ -25,6 +25,10 @@ - - package build.tools.spp; - -+import java.io.BufferedReader; -+import java.io.InputStreamReader; -+import java.io.IOException; -+ - import java.util.*; - import java.util.regex.*; - -@@ -83,7 +87,7 @@ - } - - StringBuffer out = new StringBuffer(); -- new Spp().spp(new Scanner(System.in), -+ new Spp().spp(new BufferedReader(new InputStreamReader(System.in)), - out, "", - keys, vars, be, - false); -@@ -104,12 +108,12 @@ - Matcher ifkey = Pattern.compile("^#if\\[(!)?" + KEY + "\\]").matcher(""); - Matcher elsekey = Pattern.compile("^#else\\[(!)?" + KEY + "\\]").matcher(""); - Matcher endkey = Pattern.compile("^#end\\[(!)?" + KEY + "\\]").matcher(""); -- Matcher vardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$").matcher(""); -+ Pattern pvardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$"); - Matcher vardef2 = Pattern.compile("\\$" + VAR + "\\$").matcher(""); - - void append(StringBuffer buf, String ln, - Set<String> keys, Map<String, String> vars) { -- vardef.reset(ln); -+ Matcher vardef = pvardef.matcher(ln); - while (vardef.find()) { - String repl = ""; - if (vardef.group(GN_VAR) != null) -@@ -133,19 +137,20 @@ - } - - // return true if #end[key], #end or EOF reached -- boolean spp(Scanner in, StringBuffer buf, String key, -+ boolean spp(BufferedReader in, StringBuffer buf, String key, - Set<String> keys, Map<String, String> vars, -- boolean be, boolean skip) { -- while (in.hasNextLine()) { -- String ln = in.nextLine(); -+ boolean be, boolean skip) throws IOException { -+ while (true) { -+ String ln = in.readLine(); -+ if (ln == null) -+ break; - if (be) { - if (ln.startsWith("#begin")) { - buf.setLength(0); //clean up to this line - continue; - } - if (ln.equals("#end")) { -- while (in.hasNextLine()) -- in.nextLine(); -+ do { } while (in.readLine() != null); - return true; //discard the rest to EOF - } - }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/boot/scanner-charsets.patch Mon May 17 22:32:12 2010 +0100 @@ -0,0 +1,69 @@ +diff -r 5d5ee1c92a1b make/tools/src/build/tools/charsetmapping/EUC_TW.java +--- openjdk.orig/jdk/make/tools/src/build/tools/charsetmapping/EUC_TW.java Fri May 14 14:06:33 2010 +0100 ++++ openjdk/jdk/make/tools/src/build/tools/charsetmapping/EUC_TW.java Mon May 17 20:40:10 2010 +0100 +@@ -27,7 +27,6 @@ + + import java.io.*; + import java.util.ArrayList; +-import java.util.Scanner; + import java.util.Formatter; + import java.util.regex.*; + import java.nio.charset.*; +diff -r 5d5ee1c92a1b make/tools/src/build/tools/charsetmapping/HKSCS.java +--- openjdk.orig/jdk/make/tools/src/build/tools/charsetmapping/HKSCS.java Fri May 14 14:06:33 2010 +0100 ++++ openjdk/jdk/make/tools/src/build/tools/charsetmapping/HKSCS.java Mon May 17 20:40:10 2010 +0100 +@@ -28,7 +28,6 @@ + import java.io.*; + import java.util.Arrays; + import java.util.ArrayList; +-import java.util.Scanner; + import java.util.Formatter; + import java.util.regex.*; + import java.nio.charset.*; +diff -r 5d5ee1c92a1b make/tools/src/build/tools/charsetmapping/Main.java +--- openjdk.orig/jdk/make/tools/src/build/tools/charsetmapping/Main.java Fri May 14 14:06:33 2010 +0100 ++++ openjdk/jdk/make/tools/src/build/tools/charsetmapping/Main.java Mon May 17 20:40:10 2010 +0100 +@@ -25,9 +25,6 @@ + + package build.tools.charsetmapping; + +-import java.io.*; +-import java.util.Scanner; +- + public class Main { + + public static void main(String args[]) throws Exception { +diff -r 5d5ee1c92a1b make/tools/src/build/tools/charsetmapping/Utils.java +--- openjdk.orig/jdk/make/tools/src/build/tools/charsetmapping/Utils.java Fri May 14 14:06:33 2010 +0100 ++++ openjdk/jdk/make/tools/src/build/tools/charsetmapping/Utils.java Mon May 17 20:40:10 2010 +0100 +@@ -26,6 +26,7 @@ + package build.tools.charsetmapping; + + import java.io.File; ++import java.io.FileInputStream; + import java.io.InputStream; + import java.io.InputStreamReader; + import java.io.OutputStream; +@@ -33,7 +34,6 @@ + import java.io.IOException; + import java.util.regex.Matcher; + import java.util.regex.Pattern; +-import java.util.Scanner; + import java.util.Formatter; + + public class Utils { +@@ -206,10 +206,11 @@ + } + + public static String getCopyright(File f) throws IOException { +- Scanner s = new Scanner(f, "ISO-8859-1"); ++ InputStreamReader r = new InputStreamReader(new FileInputStream(f), ++ "ISO-8859-1"); ++ BufferedReader s = new BufferedReader(r); + StringBuilder sb = new StringBuilder(); +- while (s.hasNextLine()) { +- String ln = s.nextLine(); ++ for (String ln = s.readLine(); ln != null; ln = s.readLine()) { + sb.append(ln + "\n"); + // assume we have the copyright as the first comment + if (ln.matches("^\\s\\*\\/$"))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/boot/scanner-dbcs.patch Mon May 17 22:32:12 2010 +0100 @@ -0,0 +1,40 @@ +diff -Nru openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java +--- openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java 2010-05-04 14:24:56.000000000 +0100 ++++ openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/DBCS.java 2010-05-04 14:34:01.000000000 +0100 +@@ -27,7 +27,6 @@ + import java.io.*; + import java.util.Arrays; + import java.util.ArrayList; +-import java.util.Scanner; + import java.util.Formatter; + import java.util.regex.*; + import java.nio.charset.*; +@@ -39,9 +38,8 @@ + + public static void genClass(String args[]) throws Exception { + +- Scanner s = new Scanner(new File(args[0], args[2])); +- while (s.hasNextLine()) { +- String line = s.nextLine(); ++ BufferedReader s = new BufferedReader(new FileReader(new File(args[0], args[2]))); ++ for (String line = s.readLine(); line != null; line = s.readLine()) { + if (line.startsWith("#") || line.length() == 0) + continue; + String[] fields = line.split("\\s+"); +@@ -188,14 +186,13 @@ + String b2cNR = b2cNRSB.toString(); + String c2bNR = c2bNRSB.toString(); + +- Scanner s = new Scanner(new File(srcDir, template)); ++ BufferedReader s = new BufferedReader(new FileReader(new File(srcDir, template))); + PrintStream ops = new PrintStream(new FileOutputStream( + new File(dstDir, clzName + ".java"))); + if (hisName == null) + hisName = ""; + +- while (s.hasNextLine()) { +- String line = s.nextLine(); ++ for (String line = s.readLine(); line != null; line = s.readLine()) { + if (line.indexOf("$") == -1) { + ops.println(line); + continue;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/boot/scanner-sbcs.patch Mon May 17 22:32:12 2010 +0100 @@ -0,0 +1,38 @@ +diff -Nru openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java +--- openjdk-boot.orig/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java 2010-05-04 14:09:01.000000000 +0100 ++++ openjdk-boot/jdk/make/tools/src/build/tools/charsetmapping/SBCS.java 2010-05-04 14:17:47.000000000 +0100 +@@ -28,7 +28,6 @@ + import java.io.*; + import java.util.Arrays; + import java.util.ArrayList; +-import java.util.Scanner; + import java.util.Formatter; + import java.util.regex.*; + import java.nio.charset.*; +@@ -38,9 +37,8 @@ + + public static void genClass(String args[]) throws Exception { + +- Scanner s = new Scanner(new File(args[0], args[2])); +- while (s.hasNextLine()) { +- String line = s.nextLine(); ++ BufferedReader s = new BufferedReader(new FileReader(new File(args[0], args[2]))); ++ for (String line = s.readLine(); line != null; line = s.readLine()) { + if (line.startsWith("#") || line.length() == 0) + continue; + String[] fields = line.split("\\s+"); +@@ -208,12 +206,11 @@ + String b2cNR = b2cNRSB.toString(); + String c2bNR = c2bNRSB.toString(); + +- Scanner s = new Scanner(new File(srcDir, template)); ++ BufferedReader s = new BufferedReader(new FileReader(new File(srcDir, template))); + PrintStream out = new PrintStream(new FileOutputStream( + new File(dstDir, clzName + ".java"))); + +- while (s.hasNextLine()) { +- String line = s.nextLine(); ++ for (String line = s.readLine(); line != null; line = s.readLine()) { + int i = line.indexOf("$"); + if (i == -1) { + out.println(line);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/boot/scanner-spp.patch Mon May 17 22:32:12 2010 +0100 @@ -0,0 +1,65 @@ +diff -Nru openjdk-boot.orig/jdk/make/tools/src/build/tools/spp/Spp.java openjdk-boot/jdk/make/tools/src/build/tools/spp/Spp.java +--- openjdk-boot.orig/jdk/make/tools/src/build/tools/spp/Spp.java 2008-09-11 08:44:09.000000000 +0100 ++++ openjdk-boot/jdk/make/tools/src/build/tools/spp/Spp.java 2008-09-12 21:34:38.000000000 +0100 +@@ -25,6 +25,10 @@ + + package build.tools.spp; + ++import java.io.BufferedReader; ++import java.io.InputStreamReader; ++import java.io.IOException; ++ + import java.util.*; + import java.util.regex.*; + +@@ -83,7 +87,7 @@ + } + + StringBuffer out = new StringBuffer(); +- new Spp().spp(new Scanner(System.in), ++ new Spp().spp(new BufferedReader(new InputStreamReader(System.in)), + out, "", + keys, vars, be, + false); +@@ -104,12 +108,12 @@ + Matcher ifkey = Pattern.compile("^#if\\[(!)?" + KEY + "\\]").matcher(""); + Matcher elsekey = Pattern.compile("^#else\\[(!)?" + KEY + "\\]").matcher(""); + Matcher endkey = Pattern.compile("^#end\\[(!)?" + KEY + "\\]").matcher(""); +- Matcher vardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$").matcher(""); ++ Pattern pvardef = Pattern.compile("\\{#if\\[(!)?" + KEY + "\\]\\?" + TEXT + "(:"+ TEXT + ")?\\}|\\$" + VAR + "\\$"); + Matcher vardef2 = Pattern.compile("\\$" + VAR + "\\$").matcher(""); + + void append(StringBuffer buf, String ln, + Set<String> keys, Map<String, String> vars) { +- vardef.reset(ln); ++ Matcher vardef = pvardef.matcher(ln); + while (vardef.find()) { + String repl = ""; + if (vardef.group(GN_VAR) != null) +@@ -133,19 +137,20 @@ + } + + // return true if #end[key], #end or EOF reached +- boolean spp(Scanner in, StringBuffer buf, String key, ++ boolean spp(BufferedReader in, StringBuffer buf, String key, + Set<String> keys, Map<String, String> vars, +- boolean be, boolean skip) { +- while (in.hasNextLine()) { +- String ln = in.nextLine(); ++ boolean be, boolean skip) throws IOException { ++ while (true) { ++ String ln = in.readLine(); ++ if (ln == null) ++ break; + if (be) { + if (ln.startsWith("#begin")) { + buf.setLength(0); //clean up to this line + continue; + } + if (ln.equals("#end")) { +- while (in.hasNextLine()) +- in.nextLine(); ++ do { } while (in.readLine() != null); + return true; //discard the rest to EOF + } + }