diff options
17 files changed, 60 insertions, 146 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index 60360e222d..ecbe9aefb7 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -99,7 +99,7 @@ class Scalac extends MatchingTask { /** Defines valid values for the <code>target</code> property. */ object Target extends PermissibleValue { - val values = List("jvm-1.5", "jvm-1.4", "msil", "cldc") + val values = List("jvm-1.5", "msil", "cldc") } /** Defines valid values for the <code>deprecation</code> and diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 03c4920d4a..eefcc05b35 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -64,11 +64,8 @@ import Interpreter._ * @author Moez A. Abdel-Gawad * @author Lex Spoon */ -class Interpreter(val settings: Settings, out: PrintWriter) { - /* If running on pre-1.5 JVM, force target setting to 1.4 */ - private val major = System.getProperty("java.class.version").split("\\.")(0) - if (major.toInt < 49) this.settings.target.value = "jvm-1.4" - +class Interpreter(val settings: Settings, out: PrintWriter) +{ /** directory to save .class files to */ val virtualDirectory = new VirtualDirectory("(memory)", None) diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala index aa440adbf3..e31dcd38f9 100644 --- a/src/compiler/scala/tools/nsc/ScriptRunner.scala +++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala @@ -275,13 +275,6 @@ object ScriptRunner { : Boolean = { import Interpreter.deleteRecursively - /* If the script is running on pre-jvm-1.5 JVM, - it is necessary to force the target setting to jvm-1.4 */ - val major = System.getProperty("java.class.version").split("\\.")(0) - if (major.toInt < 49) { - settings.target.value = "jvm-1.4" - } - /** Compiles the script file, and returns * the directory with the compiled class files, * if the compilation succeeded. diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala index a05a6dd157..31261b87e6 100644 --- a/src/compiler/scala/tools/nsc/Settings.scala +++ b/src/compiler/scala/tools/nsc/Settings.scala @@ -602,7 +602,7 @@ trait ScalacSettings val XO = BooleanSetting ("-optimise", "Generates faster bytecode by applying optimisations to the program") val printLate = BooleanSetting ("-print", "Print program with all Scala-specific features removed") val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", "") - val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "jvm-1.4", "msil"), "jvm-1.5") + val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "msil"), "jvm-1.5") val unchecked = BooleanSetting ("-unchecked", "Enable detailed unchecked warnings") val uniqid = BooleanSetting ("-uniqid", "Print identifiers with unique names for debugging") val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing") diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index b412340372..283b381d5f 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -103,9 +103,7 @@ abstract class GenJVM extends SubComponent { var innerClasses: Set[Symbol] = ListSet.empty // referenced inner classes - val fjbgContext = - if (settings.target.value == "jvm-1.5") new FJBGContext(49, 0) - else new FJBGContext() + val fjbgContext = new FJBGContext(49, 0) val emitSource = settings.debuginfo.level >= 1 val emitLines = settings.debuginfo.level >= 2 @@ -419,9 +417,8 @@ abstract class GenJVM extends SubComponent { } def addGenericSignature(jmember: JMember, sym: Symbol, owner: Symbol) { - if (settings.target.value == "jvm-1.5" - && !sym.hasFlag(Flags.EXPANDEDNAME | Flags.SYNTHETIC) - && !(sym.isMethod && sym.hasFlag(Flags.LIFTED))) { + if (!sym.hasFlag(Flags.EXPANDEDNAME | Flags.SYNTHETIC) + && !(sym.isMethod && sym.hasFlag(Flags.LIFTED))) { val memberTpe = atPhase(currentRun.erasurePhase)(owner.thisType.memberInfo(sym)) // println("sym: " + sym.fullNameString + " : " + memberTpe + " sym.info: " + sym.info) erasure.javaSig(sym, memberTpe) match { @@ -572,11 +569,6 @@ abstract class GenJVM extends SubComponent { javaTypes(m.params map (_.kind)), javaNames(m.params map (_.sym))); - if (m.symbol.hasFlag(Flags.BRIDGE) && settings.target.value == "jvm-1.4") { - jmethod.addAttribute(fjbgContext.JOtherAttribute(jclass, jmethod, "Bridge", - new Array[Byte](0))) - } - addRemoteException(jmethod, m.symbol) if (!jmethod.isAbstract() && !method.native) { @@ -1697,9 +1689,7 @@ abstract class GenJVM extends SubComponent { && !sym.enclClass.hasFlag(Flags.INTERFACE) && !sym.isClassConstructor) ACC_FINAL else 0) jf = jf | (if (sym.isStaticMember) ACC_STATIC else 0) - - if (settings.target.value == "jvm-1.5") - jf = jf | (if (sym hasFlag Flags.BRIDGE) ACC_BRIDGE | ACC_SYNTHETIC else 0) + jf = jf | (if (sym hasFlag Flags.BRIDGE) ACC_BRIDGE | ACC_SYNTHETIC else 0) if (sym.isClass && !sym.hasFlag(Flags.INTERFACE)) jf = jf | ACC_SUPER diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 688aff8fd9..f337dac0ac 100755 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -424,7 +424,7 @@ trait JavaParsers extends JavaScanners { // privateWithin == nme.EMPTY.toTypeName || // privateWithin == nme.EMPTY_PACKAGE_NAME_tn // XXX I think this test should just be "if (defaultAccess)" - // but then many cases like pos5/t1176 fail because scala code + // but then many cases like pos/t1176 fail because scala code // with no package cannot access java code with no package. // if (defaultAccess && !isEmptyPkg) // flags |= Flags.PROTECTED // package private diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index a4dcdc8fee..033d3ba89d 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -696,7 +696,7 @@ abstract class ClassfileParser { val attrLen = in.nextInt attrName match { case nme.SignatureATTR => - if (!isScala && !isScalaRaw && global.settings.target.value == "jvm-1.5") { + if (!isScala && !isScalaRaw) { val sig = pool.getExternalName(in.nextChar) val newType = sigToType(sym, sig) sym.setInfo(newType) @@ -855,20 +855,16 @@ abstract class ClassfileParser { getScope(jflags).enter(innerClass) getScope(jflags).enter(innerModule) - // the 1.4 library misses entries in the InnerClasses attributes (see HashMap$Entry in LinkedHashMap) - // TODO: remove this test when we drop support for 1.4 - if (settings.target.value != "jvm-1.4") { - val decls = innerClass.enclosingPackage.info.decls - val e = decls.lookupEntry(className(entry.externalName)) - if (e ne null) { - //println("removing " + e) - decls.unlink(e) - } - val e1 = decls.lookupEntry(className(entry.externalName).toTypeName) - if (e1 ne null) { - //println("removing " + e1) - decls.unlink(e1) - } + val decls = innerClass.enclosingPackage.info.decls + val e = decls.lookupEntry(className(entry.externalName)) + if (e ne null) { + //println("removing " + e) + decls.unlink(e) + } + val e1 = decls.lookupEntry(className(entry.externalName).toTypeName) + if (e1 ne null) { + //println("removing " + e1) + decls.unlink(e1) } } @@ -897,7 +893,7 @@ abstract class ClassfileParser { val attrLen = in.nextInt attrName match { case nme.SignatureATTR => - if (!isScala && global.settings.target.value == "jvm-1.5") + if (!isScala) hasMeta = true in.skip(attrLen) case nme.JacoMetaATTR => diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index a3e2a2061d..2c0a10ecc8 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -253,10 +253,6 @@ abstract class UnPickler { val pre = readTypeRef() val sym = readSymbolRef() var args = until(end, readTypeRef) - if ((sym hasFlag JAVA) && sym.typeParams.isEmpty && global.settings.target.value != "jvm-1.5") { - // forget arguments, we are compiling for 1.4; see #1144 - args = List() - } rawTypeRef(pre, sym, args) case TYPEBOUNDStpe => mkTypeBounds(readTypeRef(), readTypeRef()) diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index bdf5bede41..f0eea1742b 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -723,10 +723,6 @@ abstract class CleanUp extends Transform { if ((isValueClass(tpe.typeSymbol) || tpe.typeSymbol == definitions.UnitClass) && !forCLDC) Select(gen.mkAttributedRef(javaBoxClassModule(tpe.typeSymbol)), "TYPE") - else if (settings.target.value != "jvm-1.5" && !forMSIL) - Apply( - gen.mkAttributedRef(classConstantMethod(tree.pos, signature(tpe))), - List()) else tree } } @@ -755,7 +751,7 @@ abstract class CleanUp extends Transform { /* Adds @serializable annotation to anonymous function classes */ case cdef @ ClassDef(mods, name, tparams, impl) => - if (settings.target.value == "jvm-1.4" || settings.target.value == "jvm-1.5") { + if (settings.target.value == "jvm-1.5") { val sym = cdef.symbol // is this an anonymous function class? if (sym.isAnonymousFunction && !sym.hasAttribute(SerializableAttr)) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 35442e10e7..41b6c61d74 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -69,11 +69,6 @@ trait Typers { self: Analyzer => private class NormalTyper(context : Context) extends Typer(context) // hooks for auto completion - /** when in 1.4 mode the compiler accepts and ignores useless - * type parameters of Java generics - */ - def onePointFourMode = true // todo changeto: settings.target.value == "jvm-1.4" - // Mode constants /** The three mode <code>NOmode</code>, <code>EXPRmode</code> @@ -2154,9 +2149,6 @@ trait Typers { self: Analyzer => error(annot.constr.pos, "attribute " + annType.typeSymbol.fullNameString + " is missing element " + name.name) } } - if (annType.typeSymbol.hasFlag(JAVA) && settings.target.value == "jvm-1.4") { - context.warning (annot.constr.pos, "Java annotation will not be emitted in classfile unless you use the '-target:jvm-1.5' option") - } if (attrError) annotationError else AnnotationInfo(annType, constrArgs, nvPairs) } @@ -3181,8 +3173,7 @@ trait Typers { self: Analyzer => }} TypeTree(owntype) setOriginal(tree) // setPos tree.pos } else if (tparams.length == 0) { - if (onePointFourMode && (tpt1.symbol hasFlag JAVA)) tpt1 - else errorTree(tree, tpt1.tpe+" does not take type parameters") + errorTree(tree, tpt1.tpe+" does not take type parameters") } else { //Console.println("\{tpt1}:\{tpt1.symbol}:\{tpt1.symbol.info}") if (settings.debug.value) Console.println(tpt1+":"+tpt1.symbol+":"+tpt1.symbol.info);//debug diff --git a/src/compiler/scala/tools/nsc/util/NameTransformer.scala b/src/compiler/scala/tools/nsc/util/NameTransformer.scala index 8a97afdbe2..0292e1c68a 100644 --- a/src/compiler/scala/tools/nsc/util/NameTransformer.scala +++ b/src/compiler/scala/tools/nsc/util/NameTransformer.scala @@ -59,16 +59,15 @@ object NameTransformer { } buf.append(op2code(c)) /* Handle glyphs that are not valid Java/JVM identifiers */ - } else if (!Character.isJavaIdentifierPart(c)) { - if (buf eq null) { - buf = new StringBuilder() - buf.append(name.substring(0, i)) - } - /* Annoying hack to format a hexadeciaml number with leading - zeros -- there does not appear to be any function pre-Java - 1.5 to do this. */ - buf.append("$u" + Integer.toHexString(c + 0x10000).substring(1).toUpperCase) - } else if (buf ne null) { + } + else if (!Character.isJavaIdentifierPart(c)) { + if (buf eq null) { + buf = new StringBuilder() + buf.append(name.substring(0, i)) + } + buf.append("$u%04X".format(c.toInt)) + } + else if (buf ne null) { buf.append(c) } i += 1 @@ -110,9 +109,9 @@ object NameTransformer { /* Handle the decoding of Unicode glyphs that are * not valid Java/JVM identifiers */ } else if ((len - i) >= 6 && // Check that there are enough characters left - ch1 == 'u' && + ch1 == 'u' && ((Character.isDigit(ch2)) || - ('A' <= ch2 && ch2 <= 'F'))) { + ('A' <= ch2 && ch2 <= 'F'))) { /* Skip past "$u", next four should be hexadecimal */ val hex = name.substring(i+2, i+6) try { @@ -137,9 +136,9 @@ object NameTransformer { buffer is non-empty, write the current character and advance one */ if ((ops eq null) && !unicode) { - if (buf ne null) + if (buf ne null) buf.append(c) - i += 1 + i += 1 } } //System.out.println("= " + (if (buf == null) name else buf.toString()));//DEBUG diff --git a/src/library/scala/Math.scala b/src/library/scala/Math.scala index 78d8b6c3fe..4b781c69eb 100644 --- a/src/library/scala/Math.scala +++ b/src/library/scala/Math.scala @@ -189,16 +189,15 @@ object Math { case y if y > 0 => 1} // from Java 1.5 -// def log10(x: Double): Double = java.lang.Math.log10(x) -// def cbrt(x: Double): Double = java.lang.Math.cbrt(x) - -// def ulp(x: Double): Double = java.lang.Math.ulp(x) -// def ulp(x: Float): Float = java.lang.Math.ulp(x) -// def sinh(x: Double): Double = java.lang.Math.sinh(x) -// def cosh(x: Double): Double = java.lang.Math.cosh(x) -// def tanh(x: Double):Double = java.lang.Math.tanh(x) -// def hypot(x: Double, y: Double): Double = java.lang.Math.hypot(x, y) -// def expm1(x: Double): Double = java.lang.Math.expm1(x) -// def log1p(x: Double): Double = java.lang.Math.log1p(x) - + // def log10(x: Double): Double = java.lang.Math.log10(x) + // def cbrt(x: Double): Double = java.lang.Math.cbrt(x) + // + // def ulp(x: Double): Double = java.lang.Math.ulp(x) + // def ulp(x: Float): Float = java.lang.Math.ulp(x) + // def sinh(x: Double): Double = java.lang.Math.sinh(x) + // def cosh(x: Double): Double = java.lang.Math.cosh(x) + // def tanh(x: Double):Double = java.lang.Math.tanh(x) + // def hypot(x: Double, y: Double): Double = java.lang.Math.hypot(x, y) + // def expm1(x: Double): Double = java.lang.Math.expm1(x) + // def log1p(x: Double): Double = java.lang.Math.log1p(x) } diff --git a/src/library/scala/StringBuilder.scala b/src/library/scala/StringBuilder.scala index 8329ae9216..3d06a96c0f 100644 --- a/src/library/scala/StringBuilder.scala +++ b/src/library/scala/StringBuilder.scala @@ -791,8 +791,8 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) val temp2 = value(n - j) if (!hasSurrogate) hasSurrogate = - (temp >= StringBuilder.MIN_SURROGATE && temp <= StringBuilder.MAX_SURROGATE) || - (temp2 >= StringBuilder.MIN_SURROGATE && temp2 <= StringBuilder.MAX_SURROGATE) + (temp >= Character.MIN_HIGH_SURROGATE && temp <= Character.MAX_LOW_SURROGATE) || + (temp2 >= Character.MIN_HIGH_SURROGATE && temp2 <= Character.MAX_LOW_SURROGATE) value(j) = temp2 value(n - j) = temp j -= 1 @@ -802,9 +802,9 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) var i = 0 while (i < count - 1) { val c2 = value(i) - if (StringBuilder.isLowSurrogate(c2)) { + if (Character.isLowSurrogate(c2)) { val c1 = value(i + 1) - if (StringBuilder.isHighSurrogate(c1)) { + if (Character.isHighSurrogate(c1)) { value(i) = c1; i += 1 value(i) = c2 } @@ -843,25 +843,8 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) } -object StringBuilder { - - private val MIN_HIGH_SURROGATE = '\uD800' - private val MAX_HIGH_SURROGATE = '\uDBFF' - - private val MIN_LOW_SURROGATE = '\uDC00' - private val MAX_LOW_SURROGATE = '\uDFFF' - - // constants <code>java.langCharacter.MIN-/MAX_SURROGATE</code> exist since 1.5 - private val MIN_SURROGATE = MIN_HIGH_SURROGATE - private val MAX_SURROGATE = MAX_LOW_SURROGATE - - // methods <code>java.langCharacter.isLow-/isHighSurrogate</code> exist since 1.5 - private def isLowSurrogate(ch: Char): Boolean = - MIN_LOW_SURROGATE <= ch && ch <= MAX_LOW_SURROGATE - - private def isHighSurrogate(ch: Char): Boolean = - MIN_HIGH_SURROGATE <= ch && ch <= MAX_HIGH_SURROGATE - +object StringBuilder +{ // method <code>java.util.Arrays.copyOf</code> exists since 1.6 private def copyOf(src: Array[Char], newLength: Int): Array[Char] = { val dest = new Array[Char](newLength) diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala index caa0f6f036..0fb6ee403e 100644 --- a/src/library/scala/runtime/RichString.scala +++ b/src/library/scala/runtime/RichString.scala @@ -185,11 +185,7 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char */ def stripMargin: String = stripMargin('|') - // NB. "\\Q" + '\\' + "\\E" works on Java 1.5 and newer, but not on Java 1.4 - private def escape(ch: Char): String = ch match { - case '\\' => "\\\\" - case _ => "\\Q"+ch+"\\E" - } + private def escape(ch: Char): String = "\\Q" + ch + "\\E" @throws(classOf[java.util.regex.PatternSyntaxException]) def split(separator: Char): Array[String] = self.split(escape(separator)) @@ -224,7 +220,7 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char /** <p> * Uses the underlying string as a pattern (in a fashion similar to * printf in C), and uses the supplied arguments to fill in the - * holes. Only works on Java 1.5 or higher! + * holes. * </p> * <p> * The interpretation of the formatting patterns is described in diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala index 07224fc29e..7a0d54ec36 100644 --- a/src/library/scala/runtime/StringAdd.scala +++ b/src/library/scala/runtime/StringAdd.scala @@ -21,7 +21,6 @@ final class StringAdd(self: Any) { /** Returns string formatted according to given <code>format</code> string. * Format strings are as for <code>String.format</code> * (@see java.lang.String.format). - * Only works on Java 1.5 or higher! */ def formatted(fmtstr: String): String = fmtstr format self } diff --git a/src/library/scalax/collection/mutable/StringBuilder.scala b/src/library/scalax/collection/mutable/StringBuilder.scala index 30aeba4aed..386f316f27 100755 --- a/src/library/scalax/collection/mutable/StringBuilder.scala +++ b/src/library/scalax/collection/mutable/StringBuilder.scala @@ -816,8 +816,8 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) val temp2 = array(n - j) if (!hasSurrogate) hasSurrogate = - (temp >= StringBuilder.MIN_SURROGATE && temp <= StringBuilder.MAX_SURROGATE) || - (temp2 >= StringBuilder.MIN_SURROGATE && temp2 <= StringBuilder.MAX_SURROGATE) + (temp >= Character.MIN_HIGH_SURROGATE && temp <= Character.MAX_LOW_SURROGATE) || + (temp2 >= Character.MIN_HIGH_SURROGATE && temp2 <= Character.MAX_LOW_SURROGATE) array(j) = temp2 array(n - j) = temp j -= 1 @@ -827,9 +827,9 @@ final class StringBuilder(initCapacity: Int, private val initValue: String) var i = 0 while (i < count - 1) { val c2 = array(i) - if (StringBuilder.isLowSurrogate(c2)) { + if (Character.isLowSurrogate(c2)) { val c1 = array(i + 1) - if (StringBuilder.isHighSurrogate(c1)) { + if (Character.isHighSurrogate(c1)) { array(i) = c1; i += 1 array(i) = c2 } @@ -857,23 +857,6 @@ object StringBuilder { type Array[T] = scala.Array[T] // !!! - private val MIN_HIGH_SURROGATE = '\uD800' - private val MAX_HIGH_SURROGATE = '\uDBFF' - - private val MIN_LOW_SURROGATE = '\uDC00' - private val MAX_LOW_SURROGATE = '\uDFFF' - - // constants <code>java.langCharacter.MIN-/MAX_SURROGATE</code> exist since 1.5 - private val MIN_SURROGATE = MIN_HIGH_SURROGATE - private val MAX_SURROGATE = MAX_LOW_SURROGATE - - // methods <code>java.langCharacter.isLow-/isHighSurrogate</code> exist since 1.5 - private def isLowSurrogate(ch: Char): Boolean = - MIN_LOW_SURROGATE <= ch && ch <= MAX_LOW_SURROGATE - - private def isHighSurrogate(ch: Char): Boolean = - MIN_HIGH_SURROGATE <= ch && ch <= MAX_HIGH_SURROGATE - // method <code>java.util.Arrays.copyOf</code> exists since 1.6 private def copyOf(src: Array[Char], newLength: Int): Array[Char] = { val dest = new Array[Char](newLength) diff --git a/src/library/scalax/runtime/BoxedString.scala b/src/library/scalax/runtime/BoxedString.scala index 67ba804576..ef5a8b43c7 100644 --- a/src/library/scalax/runtime/BoxedString.scala +++ b/src/library/scalax/runtime/BoxedString.scala @@ -151,11 +151,7 @@ class BoxedString(val self: String) extends StringVector[Char] with Proxy with P */ def stripMargin: String = stripMargin('|') - // NB. "\\Q" + '\\' + "\\E" works on Java 1.5 and newer, but not on Java 1.4 - private def escape(ch: Char): String = ch match { - case '\\' => "\\\\" - case _ => "\\Q"+ch+"\\E" - } + private def escape(ch: Char): String = "\\Q" + ch + "\\E" @throws(classOf[java.util.regex.PatternSyntaxException]) def split(separator: Char): Array[String] = self.split(escape(separator)) |