stevedlawrence closed pull request #120: Support more versions of Java URL: https://github.com/apache/incubator-daffodil/pull/120
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/.travis.yml b/.travis.yml index 2141afe7f..ea721d836 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,22 +22,22 @@ scala: - 2.12.6 - 2.11.12 jdk: + - oraclejdk7 - oraclejdk8 + - oraclejdk9 + - oraclejdk10 + - oraclejdk11 sudo: required dist: trusty before_script: - unset _JAVA_OPTIONS script: - - sbt -J-Xms7g -J-Xmx7g ++$TRAVIS_SCALA_VERSION - compile - test:compile - it:compile - debug:compile - test - it:test - daffodil-cli/universal:packageBin - daffodil-cli/universal:packageZipTarball - daffodil-cli/rpm:packageBin - daffodil-japi/genjavadoc:doc - daffodil-sapi/doc - ratCheck + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION compile test:compile it:compile debug:compile || travis_terminate 1 + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION test + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION it:test + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION daffodil-cli/universal:packageBin + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION daffodil-cli/universal:packageZipTarball + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION daffodil-cli/rpm:packageBin + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION daffodil-japi/genjavadoc:doc + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION daffodil-sapi/doc + - sbt -J-Xms1g -J-Xmx5g ++$TRAVIS_SCALA_VERSION ratCheck diff --git a/README.md b/README.md index 865cfe1ff..488d002c5 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ For more information about Daffodil, see https://daffodil.apache.org/. ## Build Requirements -* JDK 1.8 +* JDK 7 or higher * SBT 0.13.8 or higher ## Getting Started diff --git a/build.sbt b/build.sbt index 3b26f90da..6dd7afc87 100644 --- a/build.sbt +++ b/build.sbt @@ -119,12 +119,6 @@ lazy val commonSettings = Seq( mappings in (Compile, packageBin) += baseDirectory.value / ".." / "LICENSE" -> "META-INF/LICENSE", mappings in (Compile, packageBin) += baseDirectory.value / ".." / "NOTICE" -> "META-INF/NOTICE", homepage := Some(url("https://daffodil.apache.org")), - initialize := { - val _ = initialize.value - if (sys.props("java.specification.version") != "1.8") { - sys.error("Java 8 is required for this project.") - } - }, unmanagedBase := baseDirectory.value / "lib" / "jars", sourceManaged := baseDirectory.value / "src_managed", resourceManaged := baseDirectory.value / "resource_managed", diff --git a/daffodil-cli/README.md b/daffodil-cli/README.md index f54cbfe49..ccdb11276 100644 --- a/daffodil-cli/README.md +++ b/daffodil-cli/README.md @@ -25,7 +25,7 @@ For more information about Daffodil, see https://daffodil.apache.org/. ## Requirements -* JDK 1.8 +* JRE 7 or higher ## Getting Started diff --git a/daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala b/daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala index 0637cee5d..10e97ea92 100644 --- a/daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala +++ b/daffodil-cli/src/main/scala/org/apache/daffodil/Main.scala @@ -74,7 +74,6 @@ import org.apache.daffodil.processors.DataProcessor import org.apache.daffodil.processors.DataLoc import org.apache.daffodil.processors.HasSetDebugger import org.apache.daffodil.exceptions.UnsuppressableException -import org.apache.daffodil.util.InvalidJavaVersionException import org.apache.daffodil.infoset.XMLTextInfosetOutputter import org.apache.daffodil.infoset.NullInfosetOutputter import org.apache.daffodil.infoset.ScalaXMLInfosetOutputter @@ -1356,10 +1355,6 @@ object Main extends Logging { log(LogLevel.Error, "%s", e.getMessage()) 1 } - case e: InvalidJavaVersionException => { - log(LogLevel.Error, "%s", e.getMessage()) - 1 - } case e: Exception => { bugFound(e) } diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala b/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala index 002b5d7c9..0bd514037 100644 --- a/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala +++ b/daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala @@ -34,7 +34,7 @@ import org.apache.daffodil.processors.{ DataProcessor, Processor, SchemaSetRunti import org.apache.daffodil.processors.parsers.NotParsableParser import org.apache.daffodil.processors.unparsers.NotUnparsableUnparser import org.apache.daffodil.schema.annotation.props.gen.ParseUnparsePolicy -import org.apache.daffodil.util.{ CheckJavaVersion, InvalidJavaVersionException, LogLevel, Logging, Misc } +import org.apache.daffodil.util.{ LogLevel, Logging, Misc } import org.apache.daffodil.xml._ /** @@ -144,14 +144,6 @@ final class ProcessorFactory(val sset: SchemaSet) rootERD, variables, validationMode) - val versionErrorOpt = CheckJavaVersion.checkJavaVersion() - if (versionErrorOpt.isDefined) { - if (tunable.errorOnUnsupportedJavaVersion) { - throw new InvalidJavaVersionException(versionErrorOpt.get) - } else { - log(LogLevel.Warning, versionErrorOpt.get + " " + CheckJavaVersion.allowUnsupportedJavaMessage) - } - } val dataProc = new DataProcessor(ssrd) if (dataProc.isError) { // NO longer printing anything here. Callers must do this. @@ -273,14 +265,6 @@ class Compiler(var validateDFDLSchemas: Boolean = true) val dpObj = objInput.readObject() objInput.close() val dp = dpObj.asInstanceOf[SerializableDataProcessor] - val versionErrorOpt = CheckJavaVersion.checkJavaVersion() - if (versionErrorOpt.isDefined) { - if (dp.getTunables.errorOnUnsupportedJavaVersion) { - throw new InvalidJavaVersionException(versionErrorOpt.get) - } else { - log(LogLevel.Warning, versionErrorOpt.get + " " + CheckJavaVersion.allowUnsupportedJavaMessage) - } - } dp } catch { case ex: ZipException => { diff --git a/daffodil-core/src/main/scala/org/apache/daffodil/util/CheckJavaVersion.scala b/daffodil-core/src/main/scala/org/apache/daffodil/util/CheckJavaVersion.scala deleted file mode 100644 index 1a8f1d684..000000000 --- a/daffodil-core/src/main/scala/org/apache/daffodil/util/CheckJavaVersion.scala +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.daffodil.util - -import org.apache.daffodil.processors.charset.CharsetUtils - -class InvalidJavaVersionException(msg: String, cause: Throwable = null) extends Exception(msg, cause) - -object CheckJavaVersion { - - def checkJavaVersion(): Option[String] = { - val jVersion = scala.util.Properties.javaVersion - val errorStringOpt = - if (!scala.util.Properties.isJavaAtLeast("1.8")) { - Some("Daffodil requires Java 8 (1.8) or higher. You are currently running %s.".format(jVersion)) - } else if (CharsetUtils.hasJava7DecoderBug) { - Some("This Java JVM has the Java 7 Decoder Bug. Daffodil requires Java 8 or higher.") - } else { - None - } - errorStringOpt - } - - val allowUnsupportedJavaMessage = - "Due to the tunable value of errorOnUnsupportedJavaVersion, " + - "processing will continue with the understanding that this is not " + - "fully tested and may have unexpected behavior in some circumstances." -} diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala index e52d47d7c..6fcfee976 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala @@ -534,7 +534,7 @@ trait DataOutputStreamImplMixin extends DataStreamCommonState Assert.usage(bb.remaining() == numBytesForLengthInBits) - if (nFragBits > 0) bb.limit(bb.limit - 1) // last byte is the frag byte + if (nFragBits > 0) bb.limit(bb.limit() - 1) // last byte is the frag byte val nBytesWritten = putByteBuffer(bb, finfo) // output all but the frag byte if there is one. val nBitsWritten = nBytesWritten * 8 if (nBytesWritten < nWholeBytes) { @@ -542,8 +542,8 @@ trait DataOutputStreamImplMixin extends DataStreamCommonState } else { val isFragWritten = if (nFragBits > 0) { - bb.limit(bb.limit + 1) - var fragByte: Long = Bits.asUnsignedByte(bb.get(bb.limit - 1)) + bb.limit(bb.limit() + 1) + var fragByte: Long = Bits.asUnsignedByte(bb.get(bb.limit() - 1)) if (finfo.bitOrder eq BitOrder.MostSignificantBitFirst) { // we need to shift the bits. We want the most significant bits of the byte fragByte = fragByte >>> (8 - nFragBits) @@ -560,7 +560,7 @@ trait DataOutputStreamImplMixin extends DataStreamCommonState Assert.usage(isWritable) val nTransferred = if (bb.hasArray) { - putBytes(bb.array, bb.arrayOffset + bb.position, bb.remaining(), finfo) + putBytes(bb.array, bb.arrayOffset + bb.position(), bb.remaining(), finfo) } else { if (isEndOnByteBoundary) { val lengthInBytes = bb.remaining diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/Dump.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/Dump.scala index 61d45bcf8..c3400098b 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/io/Dump.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/Dump.scala @@ -485,7 +485,7 @@ class DataDumper { // // Either way, we got our one character // how many bytes did it consume? - val nConsumedBytes = bb.position + val nConsumedBytes = bb.position() Assert.invariant(nConsumedBytes > 0) val char = cb.get(0) val nCols = charNColumns(char) diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/FastAsciiToUnicodeConverter.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/FastAsciiToUnicodeConverter.scala index 37d99b905..cb52fb51d 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/io/FastAsciiToUnicodeConverter.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/FastAsciiToUnicodeConverter.scala @@ -25,18 +25,18 @@ import java.nio.ByteBuffer object FastAsciiToUnicodeConverter { def convert(bb: ByteBuffer) = { - val cb = ByteBuffer.allocate(2 * bb.limit) + val cb = ByteBuffer.allocate(2 * bb.limit()) val cbChar = cb.asCharBuffer() // // Go after data in the largest chunks we can (Long) // so as to eliminate per-byte/char bounds checks // - val bbBytesOfWholeLongWords = ((bb.limit >> 3) << 3).toLong - val numBytesTrailingFragment = bb.limit - bbBytesOfWholeLongWords + val bbBytesOfWholeLongWords = ((bb.limit() >> 3) << 3).toLong + val numBytesTrailingFragment = bb.limit() - bbBytesOfWholeLongWords val bLong = bb.asLongBuffer() val cbLong = cb.asLongBuffer() - 1 to bLong.limit foreach { i => + 1 to bLong.limit() foreach { i => val bbl = bLong.get() val long1: Int = (bbl >> 32).toInt & 0xFFFFFFFF val long2: Int = bbl.toInt & 0xFFFFFFFF @@ -47,7 +47,7 @@ object FastAsciiToUnicodeConverter { } 1 to numBytesTrailingFragment.toInt foreach { j => - val pos = bb.limit - j + val pos = bb.limit() - j val byte = bb.get(pos) val char = convertByte(byte) cbChar.put(pos, char) @@ -90,4 +90,4 @@ object FastAsciiToUnicodeConverter { res } -} \ No newline at end of file +} diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala index fa3477829..dbaf2cf03 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSource.scala @@ -431,7 +431,7 @@ class ByteBufferInputSource(byteBuffer: ByteBuffer) private val bb = byteBuffer.asReadOnlyBuffer - private val positionOffset = bb.position + private val positionOffset = bb.position() def areBytesAvailable(nBytes: Long): Boolean = { bb.remaining >= nBytes @@ -460,7 +460,7 @@ class ByteBufferInputSource(byteBuffer: ByteBuffer) } } - def position(): Long = bb.position - positionOffset + def position(): Long = bb.position() - positionOffset def position(bytePos0b: Long): Unit = bb.position((bytePos0b + positionOffset).toInt) diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala index 30f47d2fb..060c2a40d 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala @@ -565,13 +565,13 @@ final class InputSourceDataInputStream private (val inputSource: InputSource) while (keepMatching) { // set the position to the last place data stopped decoding and increase // the limit so we can fill more data - regexMatchBuffer.position(regexMatchBuffer.limit) + regexMatchBuffer.position(regexMatchBuffer.limit()) regexMatchBuffer.limit(regexMatchBufferLimit) - regexMatchBitPositionBuffer.position(regexMatchBitPositionBuffer.limit) + regexMatchBitPositionBuffer.position(regexMatchBitPositionBuffer.limit()) regexMatchBitPositionBuffer.limit(regexMatchBufferLimit) val numDecoded = finfo.decoder.decode(this, finfo, regexMatchBuffer, regexMatchBitPositionBuffer) - val potentiallyMoreData = regexMatchBuffer.position == regexMatchBuffer.limit + val potentiallyMoreData = regexMatchBuffer.position() == regexMatchBuffer.limit() regexMatchBuffer.flip regexMatchBitPositionBuffer.flip @@ -648,7 +648,7 @@ final class InputSourceDataInputStream private (val inputSource: InputSource) Assert.usage(nBytesRequested >= 0) if (nBytesRequested == 0) return ByteBuffer.allocate(0).asReadOnlyBuffer() - val savedBytePosition = inputSource.position + val savedBytePosition = inputSource.position() val bytesToRead = Math.min(savedBytePosition, nBytesRequested).toInt val newBytePosition = savedBytePosition - bytesToRead inputSource.position(newBytePosition) @@ -668,7 +668,7 @@ final class InputSourceDataInputStream private (val inputSource: InputSource) if (nBytesRequested == 0) return ByteBuffer.allocate(0).asReadOnlyBuffer() - val savedBytePosition = inputSource.position + val savedBytePosition = inputSource.position() // need to call areBytesAvailable first to ensure at least length bytes are // buffered if they exist val available = inputSource.areBytesAvailable(nBytesRequested) @@ -768,8 +768,8 @@ class InputSourceDataInputStreamCharIterator(dis: InputSourceDataInputStream) ex // we need to pick up decoding where we last left off if there are any // characters still cached. This location is found in the last element // of the bitPositions buffer - if (bitPositions.limit > 0) { - val lastFetchBitPositionEnd = bitPositions.get(bitPositions.limit - 1) + if (bitPositions.limit() > 0) { + val lastFetchBitPositionEnd = bitPositions.get(bitPositions.limit() - 1) dis.setBitPos0b(lastFetchBitPositionEnd) } @@ -804,7 +804,7 @@ class InputSourceDataInputStreamCharIterator(dis: InputSourceDataInputStream) ex val decodedChars = dis.cst.charIteratorState.decodedChars if (decodedChars.remaining >= 1) { - decodedChars.get(decodedChars.position) + decodedChars.get(decodedChars.position()) } else if (dis.cst.charIteratorState.moreDataAvailable) { fetch() peek() @@ -818,7 +818,7 @@ class InputSourceDataInputStreamCharIterator(dis: InputSourceDataInputStream) ex val decodedChars = dis.cst.charIteratorState.decodedChars if (decodedChars.remaining >= 2) { - decodedChars.get(decodedChars.position + 1) + decodedChars.get(decodedChars.position() + 1) } else if (dis.cst.charIteratorState.moreDataAvailable) { fetch() peek2() diff --git a/daffodil-io/src/main/scala/org/apache/daffodil/processors/charset/CharsetUtils.scala b/daffodil-io/src/main/scala/org/apache/daffodil/processors/charset/CharsetUtils.scala index 9359a7cf3..856762c96 100644 --- a/daffodil-io/src/main/scala/org/apache/daffodil/processors/charset/CharsetUtils.scala +++ b/daffodil-io/src/main/scala/org/apache/daffodil/processors/charset/CharsetUtils.scala @@ -57,8 +57,8 @@ object CharsetUtils { val cb = CharBuffer.allocate(1) val cr = decoder.decode(bb, cb, true) if (cr.isOverflow && // This is the bug! - cb.position == 0 && - bb.position == 0) true + cb.position() == 0 && + bb.position() == 0) true else if (cr.isError) false // no bug // else if (cr.isOverflow && // This is what *should* happen if CodingErrorAction.REPLACE is used. // cb.position == 1 && diff --git a/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDaffodilDataInputSource.scala b/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDaffodilDataInputSource.scala index d4876f79d..d5623fb4b 100644 --- a/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDaffodilDataInputSource.scala +++ b/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDaffodilDataInputSource.scala @@ -136,9 +136,9 @@ class TestBucketingInputSource { val bis = new BucketingInputSource(tis, 17) var i = 0 while (i < 100) { - assertEquals(i, bis.position) + assertEquals(i, bis.position()) assertEquals(i % 10, bis.get) - assertEquals(i + 1, bis.position) + assertEquals(i + 1, bis.position()) i += 1 } } @@ -159,7 +159,7 @@ class TestBucketingInputSource { assertEquals(i, b(i)) i += 1 } - assertEquals(20, bis.position) + assertEquals(20, bis.position()) } @Test def testBucketingInputSource3 { @@ -239,11 +239,11 @@ class TestBucketingInputSource { i += 1 } assertEquals(-1, bis.get) - assertEquals(17, bis.position) + assertEquals(17, bis.position()) bis.compact() // shouldn't do anything since first bucket is locked bis.position(2) - assertEquals(2, bis.position) + assertEquals(2, bis.position()) bis.releasePosition(2) bis.compact() // should'nt do anything since cur pos is at the first bucket i = 2 @@ -270,9 +270,9 @@ class TestByteBufferInputSource { val bis = new ByteBufferInputSource(bb) var i = 0 while (i < 30) { - assertEquals(i, bis.position) + assertEquals(i, bis.position()) assertEquals(i % 10, bis.get) - assertEquals(i + 1, bis.position) + assertEquals(i + 1, bis.position()) i += 1 } assertEquals(-1, bis.get) @@ -294,7 +294,7 @@ class TestByteBufferInputSource { assertEquals(i, b(i)) i += 1 } - assertEquals(20, bis.position) + assertEquals(20, bis.position()) } @Test def testByteBufferInputSource3 { @@ -370,11 +370,11 @@ class TestByteBufferInputSource { i += 1 } assertEquals(-1, bis.get) - assertEquals(17, bis.position) + assertEquals(17, bis.position()) bis.compact() // shouldn't do anything since first bucket is locked bis.position(2) - assertEquals(2, bis.position) + assertEquals(2, bis.position()) bis.releasePosition(2) bis.compact() // should'nt do anything since cur pos is at the first bucket i = 2 diff --git a/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDecoder.scala b/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDecoder.scala index 2470a088a..c4caaae04 100644 --- a/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDecoder.scala +++ b/daffodil-io/src/test/scala/org/apache/daffodil/io/TestDecoder.scala @@ -123,13 +123,13 @@ class TestDecoder { // assertTrue(decodeCR.isMalformed()) assertEquals(3, decodeCR.length()) - assertEquals(0, cb.position) - assertEquals(0, bb.position) + assertEquals(0, cb.position()) + assertEquals(0, bb.position()) // flushCR = decoder.flush(cb) assertEquals(CoderResult.UNDERFLOW, flushCR) - assertEquals(0, cb.position) - assertEquals(0, bb.position) + assertEquals(0, cb.position()) + assertEquals(0, bb.position()) } @Test def testDecoderWorkaround1 { @@ -160,12 +160,12 @@ class TestDecoder { decodeCR = decoder.decode(bb, tempCB, true) assertTrue(decodeCR.isError) - assertEquals(0, tempCB.position) - assertEquals(0, bb.position) + assertEquals(0, tempCB.position()) + assertEquals(0, bb.position()) val flushCR = decoder.flush(cb) - assertEquals(0, tempCB.position) - assertEquals(0, bb.position) + assertEquals(0, tempCB.position()) + assertEquals(0, bb.position()) assertEquals(CoderResult.UNDERFLOW, flushCR) // @@ -173,8 +173,8 @@ class TestDecoder { // assertTrue(decodeCR.isMalformed()) assertEquals(3, decodeCR.length()) - assertEquals(0, cb.position) - assertEquals(0, bb.position) + assertEquals(0, cb.position()) + assertEquals(0, bb.position()) // } @@ -200,8 +200,8 @@ class TestDecoder { // assertEquals(CoderResult.malformedForLength(1), decodeCR) // val flushCR = decoder.flush(cb) // assertEquals(CoderResult.UNDERFLOW, flushCR) - // assertEquals(0, cb.position) - // assertEquals(0, bb.position) + // assertEquals(0, cb.position()) + // assertEquals(0, bb.position()) // } // // @Test def testDecoder3 { @@ -222,8 +222,8 @@ class TestDecoder { // assertEquals(CoderResult.OVERFLOW, decodeCR) // val flushCR = decoder.flush(cb) // assertEquals(CoderResult.UNDERFLOW, flushCR) - // assertEquals(1, cb.position) - // assertEquals(1, bb.position) + // assertEquals(1, cb.position()) + // assertEquals(1, bb.position()) // cb.flip // assertEquals(decoder.unicodeReplacementChar, cb.get()) // } @@ -244,8 +244,8 @@ class TestDecoder { // assertEquals(CoderResult.UNDERFLOW, decodeCR) // val flushCR = decoder.flush(cb) // assertEquals(CoderResult.UNDERFLOW, flushCR) - // assertEquals(1, cb.position) - // assertEquals(3, bb.position) + // assertEquals(1, cb.position()) + // assertEquals(3, bb.position()) // cb.flip // assertEquals('日', cb.get()) // } diff --git a/daffodil-japi/build.sbt b/daffodil-japi/build.sbt index d8fdb539b..f9b0b9160 100644 --- a/daffodil-japi/build.sbt +++ b/daffodil-japi/build.sbt @@ -34,7 +34,6 @@ sources in JavaDoc := javacOptions in JavaDoc := Seq( "-Xdoclint:none", - "-quiet", "-windowtitle", "Apache Daffodil (incubating) " + version.value + " Java API", "-doctitle", "<h1>Apache Daffodil (incubating) " + version.value + " Java API</h1>" ) diff --git a/daffodil-japi/src/main/java/org/apache/daffodil/japi/infoset/package-info.java b/daffodil-japi/src/main/java/org/apache/daffodil/japi/infoset/package-info.java index 1cffa460d..0fb5304be 100644 --- a/daffodil-japi/src/main/java/org/apache/daffodil/japi/infoset/package-info.java +++ b/daffodil-japi/src/main/java/org/apache/daffodil/japi/infoset/package-info.java @@ -18,7 +18,7 @@ /** * Defines various classes used control the representation of the infoset for * parse and unparse. Classes that extend {@link org.apache.daffodil.japi.infoset.InfosetOutputter} are provided to - * the {@link org.apache.daffodil.japi.DataProcessor#parse(org.apache.daffodil.io.InputSourceDataInputStream, org.apache.daffodil.japi.infoset.InfosetOutputter)} method to deteremine how to output an infoset. + * the {@link org.apache.daffodil.japi.DataProcessor#parse(org.apache.daffodil.japi.io.InputSourceDataInputStream, org.apache.daffodil.japi.infoset.InfosetOutputter)} method to deteremine how to output an infoset. * These classes are not guaranteed to be thread-safe. Classes that extend * {@link org.apache.daffodil.japi.infoset.InfosetInputter} are provided to the {@link org.apache.daffodil.japi.DataProcessor#unparse(org.apache.daffodil.japi.infoset.InfosetInputter, java.nio.channels.WritableByteChannel)} method to * determine how to read in an infoset. A new InfosetOutputter is required for diff --git a/daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala b/daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala index a8568ed24..0ab4db6db 100644 --- a/daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala +++ b/daffodil-japi/src/main/scala/org/apache/daffodil/japi/Daffodil.scala @@ -119,6 +119,7 @@ class Compiler private[japi] () { * * @param schemaFile DFDL schema file used to create a [[ProcessorFactory]]. * @return [[ProcessorFactory]] used to create [[DataProcessor]](s). Must check [[ProcessorFactory#isError]] before using it. + * @throws java.io.IOException if an I/O error occurs while reading the schemaFile */ @throws(classOf[java.io.IOException]) def compileFile(schemaFile: File): ProcessorFactory = { @@ -132,6 +133,7 @@ class Compiler private[japi] () { * * @param uri URI of DFDL schema file used to create a [[ProcessorFactory]]. * @return [[ProcessorFactory]] used to create [[DataProcessor]](s). Must check [[ProcessorFactory#isError]] before using it. + * @throws java.io.IOException if an I/O error occurs while reading the uri */ @throws(classOf[java.io.IOException]) def compileSource(uri: URI): ProcessorFactory = { @@ -454,6 +456,7 @@ class DataProcessor private[japi] (dp: SDataProcessor) * Set validation mode * * @param mode mode to control validation + * @throws InvalidUsageException if mode is not a valid ValidateMode value */ @throws(classOf[InvalidUsageException]) def setValidationMode(mode: ValidationMode): Unit = { @@ -491,7 +494,7 @@ class DataProcessor private[japi] (dp: SDataProcessor) */ def save(output: WritableByteChannel): Unit = dp.save(output) - /* + /** * Parse input data with a specified length * * @param input data to be parsed @@ -510,7 +513,7 @@ class DataProcessor private[japi] (dp: SDataProcessor) new ParseResult(pr, Maybe(output)) } - /* + /** * Parse input data without specifying a length * * @param input data to be parsed diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/api/DaffodilTunables.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/api/DaffodilTunables.scala index 0f68c0b03..5aa3d334e 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/api/DaffodilTunables.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/api/DaffodilTunables.scala @@ -130,16 +130,10 @@ case class DaffodilTunables( // enabled when debugging is enabled. val allowExternalPathExpressions: Boolean = false, - // A bug exists in Java 7 that causes unexpected behavior when decode errors - // occur in the specific ways that Daffodil decodes data. For this reason, - // Daffodil throws an exception when it detects that Daffodil is not running - // under Java 8 or has this decoder bug. However, there are some cases where - // a user has no choice but to run on Java 7. Setting this tunable to false - // will cause Daffodil to log a warning rather than throw an exception so - // that a user can run Daffodil on unsupported Java versions, with the - // understanding that it is not fully tested and behavior may not be well - // defined. This boolean is experimental and should only be used by those - // that fully understand the risks. + // Daffodil supports Java 7+. This is essentially all version of java that + // are in use, so we no longer have any unsupported java versions. This + // tunable no longer has any affect and is only kept for backwards + // compatability. val errorOnUnsupportedJavaVersion: Boolean = true, val maximumSimpleElementSizeInCharacters: Int = 1024 * 1024, diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala index a9787303d..4117218b4 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/cookers/EntityReplacer.scala @@ -661,7 +661,7 @@ sealed abstract class ListOfStringLiteralBase( sealed trait ListOfSingleCharacterMixin { self: ListOfStringLiteralBase => - def cookCharacters(raw: String, context: ThrowsSDE, forUnparse: Boolean) = cook(raw, context, forUnparse).map { s => new JChar(s(0)) } + def cookCharacters(raw: String, context: ThrowsSDE, forUnparse: Boolean) = cook(raw, context, forUnparse).map { s => JChar.valueOf(s(0)) } } class ListOfStringLiteral(pn: String, allowByteEntities: Boolean) diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/ByHandMixins.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/ByHandMixins.scala index 77d2e16ab..566edcee8 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/ByHandMixins.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/schema/annotation/props/ByHandMixins.scala @@ -67,7 +67,7 @@ object AlignmentType extends Enum[AnyRef] { // Note: Was using AlignmentUnits mi // case AlignmentUnits.Bits => i // TODO: implement units * Units.bits // case AlignmentUnits.Bytes => i // * Units.bytes // } - new JInt(i) + JInt.valueOf(i) } else self.schemaDefinitionError("For property 'alignment', value must be a power of 2 (and fit in a 32 bit integer). Found: " + str) } } diff --git a/daffodil-lib/src/main/scala/org/apache/daffodil/util/Numbers.scala b/daffodil-lib/src/main/scala/org/apache/daffodil/util/Numbers.scala index d1bde2729..31fba638f 100644 --- a/daffodil-lib/src/main/scala/org/apache/daffodil/util/Numbers.scala +++ b/daffodil-lib/src/main/scala/org/apache/daffodil/util/Numbers.scala @@ -105,7 +105,7 @@ object Numbers { case _ => Assert.invariantFailed("Unsupported conversion to Int. %s of type %s".format( n, Misc.getNameFromClass(n))) } - new JInt(value) + JInt.valueOf(value) } def asByte(n: AnyRef): JByte = { val value = n match { @@ -122,7 +122,7 @@ object Numbers { case _ => Assert.invariantFailed("Unsupported conversion to Byte. %s of type %s".format( n, Misc.getNameFromClass(n))) } - new JByte(value) + JByte.valueOf(value) } def asShort(n: AnyRef): JShort = { val value = n match { @@ -139,7 +139,7 @@ object Numbers { case _ => Assert.invariantFailed("Unsupported conversion to Short. %s of type %s".format( n, Misc.getNameFromClass(n))) } - new JShort(value) + JShort.valueOf(value) } def asLong(n: AnyRef): JLong = { @@ -157,7 +157,7 @@ object Numbers { case _ => Assert.invariantFailed("Unsupported conversion to Long. %s of type %s".format( n, Misc.getNameFromClass(n))) } - new JLong(value) + JLong.valueOf(value) } /* @@ -225,7 +225,7 @@ object Numbers { case _ => Assert.invariantFailed("Unsupported conversion to Float. %s of type %s".format( n, Misc.getNameFromClass(n))) } - new JFloat(value) + JFloat.valueOf(value) } /* @@ -249,7 +249,7 @@ object Numbers { case _ => Assert.invariantFailed("Unsupported conversion to Double. %s of type %s".format( n, Misc.getNameFromClass(n))) } - new JDouble(value) + JDouble.valueOf(value) } /* @@ -307,7 +307,7 @@ object Numbers { def asBoolean(n: Any): JBoolean = { n match { case bool: JBoolean => return bool - case b: Boolean => new JBoolean(b) + case b: Boolean => JBoolean.valueOf(b) case _ => Assert.invariantFailed("Unsupported conversion to Boolean. %s of type %s".format( n, Misc.getNameFromClass(n))) } @@ -315,12 +315,12 @@ object Numbers { def asNumber(n: Any): JNumber = { n match { - case b: Byte => new JByte(b) - case s: Short => new JShort(s) - case i: Int => new JInt(i) - case l: Long => new JLong(l) - case f: Float => new JFloat(f) - case d: Double => new JDouble(d) + case b: Byte => JByte.valueOf(b) + case s: Short => JShort.valueOf(s) + case i: Int => JInt.valueOf(i) + case l: Long => JLong.valueOf(l) + case f: Float => JFloat.valueOf(f) + case d: Double => JDouble.valueOf(d) // case bi: BigInt => bi.bigInteger // case bd: BigDecimal => bd.bigDecimal case jn: JNumber => jn @@ -334,7 +334,7 @@ object Numbers { // case bi: BigInt => bi.bigInteger // case bd: BigDecimal => bd.bigDecimal case ar: AnyRef => ar - case b: Boolean => new JBoolean(b) + case b: Boolean => JBoolean.valueOf(b) case _ => asNumber(n) } } diff --git a/daffodil-lib/src/test/scala/org/apache/daffodil/functionality/icu/TestBigInteger.scala b/daffodil-lib/src/test/scala/org/apache/daffodil/functionality/icu/TestBigInteger.scala index af78b8e63..10bea487c 100644 --- a/daffodil-lib/src/test/scala/org/apache/daffodil/functionality/icu/TestBigInteger.scala +++ b/daffodil-lib/src/test/scala/org/apache/daffodil/functionality/icu/TestBigInteger.scala @@ -58,7 +58,7 @@ class TestBigInteger { val df = new DecimalFormat(pattern, dfs) df.setParseStrict(false) - df.setRoundingMode(java.math.BigDecimal.ROUND_UNNECESSARY) + df.setRoundingMode(java.math.RoundingMode.UNNECESSARY.ordinal()) df.setRoundingIncrement(0) df.setMaximumFractionDigits(0) df.setDecimalSeparatorAlwaysShown(false) diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/ConverterOps.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/ConverterOps.scala index 20e6d8193..283740d0e 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/ConverterOps.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/ConverterOps.scala @@ -25,7 +25,7 @@ import java.math.{ BigDecimal => JBigDecimal, BigInteger => JBigInt } import org.apache.daffodil.xml.XMLUtils case object BooleanToLong extends Converter { - override def computeValue(a: AnyRef, dstate: DState): AnyRef = new JLong(if (asBoolean(a) == true) 1L else 0L) + override def computeValue(a: AnyRef, dstate: DState): AnyRef = JLong.valueOf(if (asBoolean(a) == true) 1L else 0L) } case object BooleanToString extends Converter { diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/FNFunctions.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/FNFunctions.scala index 7ded89433..cdedb87ee 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/FNFunctions.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/FNFunctions.scala @@ -25,7 +25,8 @@ import org.apache.daffodil.util.Maybe import Maybe._ import org.apache.daffodil.exceptions._ import com.ibm.icu.util.Calendar -import scala.math.BigDecimal.RoundingMode +import java.math.RoundingMode +import java.math.MathContext import com.ibm.icu.util.TimeZone import org.apache.daffodil.util.Numbers._ import org.apache.daffodil.calendar.DFDLDateTime @@ -400,7 +401,7 @@ trait FNRoundHalfToEvenKind { } private def round(value: JBigDecimal, precision: Int): JBigDecimal = { - val rounded = value.setScale(precision, JBigDecimal.ROUND_HALF_EVEN) + val rounded: JBigDecimal = value.setScale(precision, RoundingMode.HALF_EVEN) rounded } @@ -683,8 +684,8 @@ case class FNCeiling(recipe: CompiledDPath, argType: NodeInfo.Kind) extends FNOn override def computeValue(value: AnyRef, dstate: DState) = argType match { case NodeInfo.Decimal => { - val bd = asBigDecimal(value).setScale(0, RoundingMode.CEILING) - bd.round(bd.mc) + val bd = asBigDecimal(value) + bd.round(new MathContext(0, RoundingMode.CEILING)) } case NodeInfo.Float => asAnyRef(asFloat(value).floatValue().ceil) case NodeInfo.Double => asAnyRef(asDouble(value).floatValue().ceil) @@ -697,8 +698,8 @@ case class FNFloor(recipe: CompiledDPath, argType: NodeInfo.Kind) extends FNOneA override def computeValue(value: AnyRef, dstate: DState) = argType match { case NodeInfo.Decimal => { - val bd = asBigDecimal(value).setScale(0, RoundingMode.FLOOR) - bd.round(bd.mc) + val bd = asBigDecimal(value) + bd.round(new MathContext(0, RoundingMode.FLOOR)) } case NodeInfo.Float => asAnyRef(asFloat(value).floatValue().floor) case NodeInfo.Double => asAnyRef(asDouble(value).doubleValue().floor) diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/MATHFunctions.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/MATHFunctions.scala index 5ccaa1151..0f0b3d60e 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/MATHFunctions.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/dpath/MATHFunctions.scala @@ -26,12 +26,12 @@ case class MATHPow(recipes: List[CompiledDPath]) extends FNTwoArgs(recipes) { val exp = asDouble(arg2).doubleValue() if (exp.isInfinite && (base == 1 || base == -1)) { // java pow(+-1, +-inf) returns NaN, XPath says it should be 1.0 - new JDouble(1.0) + JDouble.valueOf(1.0) } else if (exp.isNaN && base == 1) { // java pow(1, NaN) returns NaN, XPath says it should be 1.0 - new JDouble(1.0) + JDouble.valueOf(1.0) } else { - new JDouble(java.lang.Math.pow(base, exp)) + JDouble.valueOf(java.lang.Math.pow(base, exp)) } } } diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala index 25726cad7..fac552aef 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/EvElement.scala @@ -64,7 +64,7 @@ class ImplicitLengthEv(lengthValue: Long, rd: ElementRuntimeData) override val runtimeDependencies = Vector() - private val jLength = new JLong(lengthValue) + private val jLength = JLong.valueOf(lengthValue) override protected def compute(state: State): JLong = { jLength diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesTextNumber1.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesTextNumber1.scala index d98686f34..125dfeeca 100644 --- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesTextNumber1.scala +++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesTextNumber1.scala @@ -35,6 +35,7 @@ import org.apache.daffodil.util.MaybeDouble import org.apache.daffodil.util.MaybeDouble import java.lang.{ Number => JNumber } import java.math.{ BigDecimal => JBigDecimal, BigInteger => JBigInt } +import java.math.RoundingMode import org.apache.daffodil.infoset.DISimple import org.apache.daffodil.processors.Delimiter import org.apache.daffodil.processors.Dynamic @@ -514,20 +515,20 @@ abstract class NumberFormatFactoryBase[S](parserHelper: ConvertTextNumberParserU rounding match { case TextNumberRounding.Pattern => { - df.setRoundingMode(JBigDecimal.ROUND_HALF_EVEN) + df.setRoundingMode(RoundingMode.HALF_EVEN.ordinal()) } case TextNumberRounding.Explicit => { val rm = roundingMode.get match { - case TextNumberRoundingMode.RoundCeiling => JBigDecimal.ROUND_CEILING - case TextNumberRoundingMode.RoundFloor => JBigDecimal.ROUND_FLOOR - case TextNumberRoundingMode.RoundDown => JBigDecimal.ROUND_DOWN - case TextNumberRoundingMode.RoundUp => JBigDecimal.ROUND_UP - case TextNumberRoundingMode.RoundHalfEven => JBigDecimal.ROUND_HALF_EVEN - case TextNumberRoundingMode.RoundHalfDown => JBigDecimal.ROUND_HALF_DOWN - case TextNumberRoundingMode.RoundHalfUp => JBigDecimal.ROUND_HALF_UP - case TextNumberRoundingMode.RoundUnnecessary => JBigDecimal.ROUND_UNNECESSARY + case TextNumberRoundingMode.RoundCeiling => RoundingMode.CEILING + case TextNumberRoundingMode.RoundFloor => RoundingMode.FLOOR + case TextNumberRoundingMode.RoundDown => RoundingMode.DOWN + case TextNumberRoundingMode.RoundUp => RoundingMode.UP + case TextNumberRoundingMode.RoundHalfEven => RoundingMode.HALF_EVEN + case TextNumberRoundingMode.RoundHalfDown => RoundingMode.HALF_DOWN + case TextNumberRoundingMode.RoundHalfUp => RoundingMode.HALF_UP + case TextNumberRoundingMode.RoundUnnecessary => RoundingMode.UNNECESSARY } - df.setRoundingMode(rm) + df.setRoundingMode(rm.ordinal()) df.setRoundingIncrement(roundingIncrement.get) } } diff --git a/daffodil-sapi/src/main/scala/org/apache/daffodil/sapi/Daffodil.scala b/daffodil-sapi/src/main/scala/org/apache/daffodil/sapi/Daffodil.scala index 8342f7930..911e72651 100644 --- a/daffodil-sapi/src/main/scala/org/apache/daffodil/sapi/Daffodil.scala +++ b/daffodil-sapi/src/main/scala/org/apache/daffodil/sapi/Daffodil.scala @@ -466,7 +466,7 @@ class DataProcessor private[sapi] (dp: SDataProcessor) */ def save(output: WritableByteChannel): Unit = dp.save(output) - /* + /** * Parse input data with a specified length * * @param input data to be parsed @@ -485,7 +485,7 @@ class DataProcessor private[sapi] (dp: SDataProcessor) new ParseResult(pr, Maybe(output)) } - /* + /** * Parse input data without specifying a length * * @param input data to be parsed diff --git a/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/assertions/TestAssertionsDebug.scala b/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/assertions/TestAssertionsDebug.scala index cbc5118cb..ada730436 100644 --- a/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/assertions/TestAssertionsDebug.scala +++ b/daffodil-test/src/test/scala-debug/org/apache/daffodil/section07/assertions/TestAssertionsDebug.scala @@ -43,4 +43,9 @@ class TestAssertionsDebug { //DFDL-1210: This test should be removed, an assert failing will no longer show the value @Test def test_assertFailShowsValue() { runner.runOneTest("assertFailShowsValue") } + + //DFDL-2001 + @Test def test_testPatternX() { runner.runOneTest("testPatternX") } + @Test def test_testPatternUnicode() { runner.runOneTest("testPatternUnicode") } + } diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala index 424c82c1a..2cfc74559 100644 --- a/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala +++ b/daffodil-test/src/test/scala/org/apache/daffodil/section07/assertions/TestAssertions.scala @@ -82,10 +82,11 @@ class TestAssertions { @Test def test_assertMessage() { runner.runOneTest("assertMessage") } @Test def test_unparseAssertionIgnored() { runner.runOneTest("unparseAssertionIgnored") } - @Test def test_testPatternX() { runner.runOneTest("testPatternX") } + // DFDL-2001 + //@Test def test_testPatternX() { runner.runOneTest("testPatternX") } + //@Test def test_testPatternUnicode() { runner.runOneTest("testPatternUnicode") } @Test def test_testPatternHex() { runner.runOneTest("testPatternHex") } @Test def test_testPatternFreeFormat() { runner.runOneTest("testPatternFreeFormat") } - @Test def test_testPatternUnicode() { runner.runOneTest("testPatternUnicode") } @Test def test_testPatternUregexUword() { runner.runOneTest("testPatternUregexUword") } @Test def test_testPatternWordChar() { runner.runOneTest("testPatternWordChar") } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
