Bug 284078 - ArrayIndexOutOfBounds error accessing array after split
Summary: ArrayIndexOutOfBounds error accessing array after split
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows Vista
: P3 minor (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2009-07-20 23:59 EDT by dave evartt CLA
Modified: 2009-08-05 01:16 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dave evartt CLA 2009-07-20 23:59:42 EDT
Get the above error sometimes after doing a simple split. Split a list with two elements. element 0 is always available, attempting to access element 1 throws the error. Only seems to happen when you use a number as the index. works if you do it in a loop, see below example. I haven't tried compiling against javac since this is really straight forward code. OF five places in the class where this is being done, it fails in three of them. I have tried split and stringTokenizer and where it fails, it fails for both. 

                        String parent="";
                        String test="";
			String dep = "35,==1";

			if (!dep.equals("")) {// found a dependency
				String[] Q = dep.split("\\,");

                                parent = Q[0]; // always works
                                test   = Q[1];// Fails depending on location in class

// The code below always works, proving that the split WAS accomplished

				for (int j = 0; j < Q.length; j++) {
					if (j == 0) {
						parent = Q[j];
					}

					if (j == 1) {
						test = Q[j];
					}
				}
Comment 1 Stephan Herrmann CLA 2009-07-21 04:30:39 EDT
If I paste your code into a main method it works just 
as expected. So my first guess would be that your 
program re-assigns dep somewhere down and later-on
split produces a 1-element array where Q[1] naturally
throws an AIOOBE, i.e., the bug would be in your program
not in Eclipse.
Comment 2 Olivier Thomann CLA 2009-07-22 13:37:30 EDT
Why this would be a JDT bug ?
Please provide a complete test case that works with javac and fails with Eclipse.
Comment 3 Olivier Thomann CLA 2009-07-22 16:03:09 EDT
Closing as INVALID.
Provide the data requested in comment 2 to reopen it.
Comment 4 Srikanth Sankaran CLA 2009-08-05 01:16:55 EDT
Verified for 3.6M1