以下是使用JRE1.6运行时环境并在64位服务器服务器2008 R2中运行的非常简单的代码块:.
cntr = 0;
while (cntr < localheaders.size()) {
String tempText = textstring.toUpperCase();
int pos = 0;
int lastindx = 0;
int lendPos;
int tendPos = 0;
while ((pos > -1) && (tempText.length() > 0)) {
int headerLengthbeforeUpper = localheaders.get(cntr).header.length();
String aHeader = localheaders.get(cntr).header.toUpperCase();
int headerLengthafterUpper = aHeader.length();
pos = tempText.indexOf(aHeader);
// 10_21_2010
if (pos > 0) { // ef 07-10-2011
char c;
try {
c = tempText.charAt(pos - 1);
if (Character.isLetterOrDigit(c))
pos = -1;
} catch (Exception e) {
System.out.println("Value of pos->" + pos);
System.out.println("Length of the string->"
+ tempText.length());
System.out.println("header length before->"+headerLengthbeforeUpper);
System.out.println("header length after->"+headerLengthafterUpper);
e.printStackTrace();
}
}
........我发现,语句pos = tempText.toUpperCase().indexOf(aHeader); (大约向下10行)被间歇地设置为字符串tempText中大于字符串长度的值。这导致了一个java.lang.StringIndexOutOfBoundsException。索引总是在字符串实际长度的100以内。例如,在我今晚运行的一个测试中,对于长度为24404的字符串,pos变量设置为24432。标题长度在大写前后是相同的,以解决下面的注释之一。注意,如果我连续两次在同一文件上重新运行代码,则不会发生第二次错误。
一些补充资料:
Java版本"1.6.0_20“Jav(TM) SE运行时环境(build 1.6.0_20-b02) Java HotSpot(TM) 64位服务器VM (build 16.3-b01,混合模式)
测试环境正在VMware工作站中运行。
我认为这是一个环境问题,给出奇怪的错误和事实,它只出现在我的64位测试环境。我在努力找出问题的根源。有没有人,曾经犯过这样的错误?是否有人知道与这个特定的java构建相关的错误可能会导致这种错误?
对如何解决这个问题有什么想法吗?
谢谢,
艾略特
发布于 2012-10-16 08:39:37
看起来这个bug可能与您的问题有关:
id=6942326
https://stackoverflow.com/questions/12908192
复制相似问题