You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2009/09/07 12:00:50 UTC
svn commit: r812067 - in
/harmony/enhanced/classlib/trunk/modules/text/src/main/java:
java/text/BreakIterator.java
org/apache/harmony/text/internal/nls/messages.properties
Author: tellison
Date: Mon Sep 7 10:00:50 2009
New Revision: 812067
URL: http://svn.apache.org/viewvc?rev=812067&view=rev
Log:
Part of HARMONY-6336 (ArrayIndexOutOfBoundsException thrown without index information; generally AIOBE is thrown without specifying the index)
Enhance exception messages in java.text package.
Modified:
harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java
harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties
Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java?rev=812067&r1=812066&r2=812067&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java Mon Sep 7 10:00:50 2009
@@ -19,6 +19,8 @@
import java.util.Locale;
+import org.apache.harmony.text.internal.nls.Messages;
+
/**
* Locates boundaries in text. This class defines a protocol for objects that
* break up a piece of natural-language text according to a set of criteria.
@@ -538,11 +540,10 @@
* greater than the length of {@code buf}.
*/
protected static long getLong(byte[] buf, int offset) {
- if (null == buf) {
- throw new NullPointerException();
- }
- if (offset < 0 || buf.length - offset < LONG_LENGTH) {
- throw new ArrayIndexOutOfBoundsException();
+ // Force a buf null check first!
+ if (buf.length - offset < LONG_LENGTH || offset < 0) {
+ // text.1E=Offset out of bounds \: {0}
+ throw new ArrayIndexOutOfBoundsException(Messages.getString("text.1E", offset)); //$NON-NLS-1$
}
long result = 0;
for (int i = offset; i < offset + LONG_LENGTH; i++) {
@@ -567,11 +568,10 @@
* greater than the length of {@code buf}.
*/
protected static int getInt(byte[] buf, int offset) {
- if (null == buf) {
- throw new NullPointerException();
- }
- if (offset < 0 || buf.length - INT_LENGTH < offset) {
- throw new ArrayIndexOutOfBoundsException();
+ // Force buf null check first!
+ if (buf.length - INT_LENGTH < offset || offset < 0) {
+ // text.1E=Offset out of bounds \: {0}
+ throw new ArrayIndexOutOfBoundsException(Messages.getString("text.1E", offset)); //$NON-NLS-1$
}
int result = 0;
for (int i = offset; i < offset + INT_LENGTH; i++) {
@@ -596,11 +596,10 @@
* greater than the length of {@code buf}.
*/
protected static short getShort(byte[] buf, int offset) {
- if (null == buf) {
- throw new NullPointerException();
- }
- if (offset < 0 || buf.length - SHORT_LENGTH < offset) {
- throw new ArrayIndexOutOfBoundsException();
+ // Force buf null check first!
+ if (buf.length - SHORT_LENGTH < offset || offset < 0) {
+ // text.1E=Offset out of bounds \: {0}
+ throw new ArrayIndexOutOfBoundsException(Messages.getString("text.1E", offset)); //$NON-NLS-1$
}
short result = 0;
for (int i = offset; i < offset + SHORT_LENGTH; i++) {
Modified: harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties?rev=812067&r1=812066&r2=812067&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/trunk/modules/text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties Mon Sep 7 10:00:50 2009
@@ -46,6 +46,4 @@
text.1B=MessageFormat.parseObject(String) parse failure
text.1C=Format.parseObject(String) parse failure
text.1D=Unparseable number: {0}
-
-
-
+text.1E=Offset out of bounds \: {0}