You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by va...@apache.org on 2007/02/07 12:18:54 UTC
svn commit: r504503 - in /harmony/enhanced:
classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java
drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java
Author: varlax
Date: Wed Feb 7 03:18:43 2007
New Revision: 504503
URL: http://svn.apache.org/viewvc?view=rev&rev=504503
Log:
Final fix for HARMONY-2470.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java
harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java?view=diff&rev=504503&r1=504502&r2=504503
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/PackageTest.java Wed Feb 7 03:18:43 2007
@@ -227,13 +227,15 @@
.isCompatibleWith("2.2"));
assertFalse("Package isCompatibleWith fails with higher version", p
.isCompatibleWith("2.2.0.0.1"));
- /*
- * RI throws NPE...
- */
try {
p.isCompatibleWith(null);
fail("Null version is illegal");
- } catch (NullPointerException ok) {}
+ } catch (NumberFormatException ok) {
+ } catch (NullPointerException compatible) {
+ /*
+ * RI throws NPE instead of NFE...
+ */
+ }
try {
p.isCompatibleWith("");
@@ -250,6 +252,14 @@
try {
p.isCompatibleWith(".9");
fail("'.9' version is illegal");
+ } catch (NumberFormatException ok) {}
+ try {
+ p.isCompatibleWith("2.4..5");
+ fail("'2.4..5' version is illegal");
+ } catch (NumberFormatException ok) {}
+ try {
+ p.isCompatibleWith("20.-4");
+ fail("'20.-4' version is illegal");
} catch (NumberFormatException ok) {}
}
Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java?view=diff&rev=504503&r1=504502&r2=504503
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Package.java Wed Feb 7 03:18:43 2007
@@ -14,10 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/**
- * @author Evgueni Brevnov, Alexey V. Varlamov, Serguei S. Zapreyev
- * @version $Revision: 1.1.2.2.4.4 $
- */
package java.lang;
@@ -263,22 +259,25 @@
init();
}
- /*
- * yes, it's not as performant as catching an NPE down below when
- * something blows up, but it's very clear to those that read this.
- * Spec says that an NFE is thrown if the current or desired version
- * is not of the correct dotted form. Lack of a version is such...
- */
- if (specVersion == null) {
- throw new NumberFormatException("No version defined for implementation");
+ if (specVersion == null || specVersion.length() == 0) {
+ throw new NumberFormatException(
+ "No specification version defined for the package");
}
- if (specVersion.startsWith(".") || specVersion.endsWith(".")) {
- throw new NumberFormatException("Wrong implementation version: should not start or end with '.'");
+ if (!specVersion.matches("[\\p{javaDigit}]+(.[\\p{javaDigit}]+)*")) {
+ throw new NumberFormatException(
+ "Package specification version is not of the correct dotted form : "
+ + specVersion);
+ }
+
+ if (desiredVersion == null || desiredVersion.length() == 0) {
+ throw new NumberFormatException("Empty version to check");
}
- if (desiredVersion.startsWith(".") || desiredVersion.endsWith(".")) {
- throw new NumberFormatException("Wrong version to check: should not start or end with '.'");
+ if (!desiredVersion.matches("[\\p{javaDigit}]+(.[\\p{javaDigit}]+)*")) {
+ throw new NumberFormatException(
+ "Desired version is not of the correct dotted form : "
+ + desiredVersion);
}
StringTokenizer specVersionTokens = new StringTokenizer(specVersion,
@@ -288,9 +287,6 @@
desiredVersion, ".");
try {
- if (!specVersionTokens.hasMoreElements() || !desiredVersionTokens.hasMoreElements()) {
- throw new NumberFormatException("Empty version string");
- }
while (specVersionTokens.hasMoreElements()) {
int desiredVer = Integer.parseInt(desiredVersionTokens
.nextToken());
@@ -300,11 +296,9 @@
}
}
} catch (NoSuchElementException e) {
-
- /*
- * ignore - this seems to be the case when we run out of tokens
- * for desiredVersion
- */
+ /*
+ * run out of tokens for desiredVersion
+ */
}
/*