Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.gui Subject: Re: Strange JTable issue in Sun's Java code Date: Tue, 17 Jan 2012 03:22:56 -0500 Organization: A noiseless patient Spider Lines: 90 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 17 Jan 2012 08:15:09 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="qwFw1g9RsQ6TkML5yezG9A"; logging-data="1915"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18P1bVAMvUTq/Ytbmxk3TP/hihRAs4dc5s=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11 In-Reply-To: Cancel-Lock: sha1:PTbO/pu+CADRVBx/sAXC8BEHhZQ= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4950 On 01/16/2012 08:48 PM, Novice wrote: > > I've just stepped through the whole removeEntries() method until it > crashed. OK, your program crashes inside the removeEntries method - just as the stack trace indicated. I should mention that I downloaded a Java 1.7 JDK and JRE and I'm > using _that_ version now. The code for this method looks the same but I > might be missing a subtle difference. Here's the code, along with what I > saw as I stepped through it: One way to decide on an update - I'm using Java 6. > > public void removeEntries(int start, int length) { > //Before executing the following line, start and length both show "cannot > //be resolved to a variable". When I tried setting them as expressions in > //the expressions monitor, I got "" for > //both variables Have you disabled debug information in your project build settings? > int sizes[] = getSizes(); > //getSizes() returns an int array of 45 items; each item has a value of > //21 > //when I inspect or inspect 'sizes' (without the brackets), I get "sizes > //cannot be resolved to a variable. It's not clear if the assignment has > //worked! > //Before this next line, 'start' and 'length' are still "cannot be > //resolved to a variable." > int end = start + length; > //After the assignment, 'end' "cannot be resolved to a variable" > //Before this next line, 'a' is an int array of 45 diverse integers and > //'a.length is 45. 'length' "cannot be resolved to a variable" > int n = a.length - length; > //After the preceding statement is executed, 'n' "cannot be resolved to a > //variable" > a = new int[n]; > //After the preceding statement is executed, 'a' has a value of "[]" (!!) > for (int i = 0; i< start; i++) { > //Before the following line is executed the first time, 'i' should be zero > //but Eclipse says "i cannot be resolved to a variable". 'sizes[i] cannot > //be resolved to a variable". > a[i] = sizes[i] ; > //Upon executing the preceding line the first time through the loop, we get > //the ArrayIndexOutOfBoundsException for an index value of 0 Using the SSCCE that I provided elsethread, I can get your method to crash at the above line also. I cannot remember with what combinations of values. > } > for (int i = start; i< n; i++) { > a[i] = sizes[i+length] ; > } > setSizes(a); > } > > > This seems REALLY messed up to me. I don't understand why all these > variables "cannot be resolved to a variable". If they really don't have > values, why doesn't it crash long before we get to the line where we get > the exception? But if the variables do have values, why can't Eclipse show > them to me? > > Since a newer JDK/JRE didn't resolve the problem and it happens > consistently, I'm leaning toward Eclipse as being the problem here. I can't > think of anything inappropriate that I'm doing in my code and I have to > believe that the Java team tests these methods pretty thoroughly before > putting them in a JDK. You could try another IDE, but that seems drastic. Another option, you could employ javac and jdb outside the IDE. > > Am I thinking along the right lines here? If so, what do I do next? I'd > like my program to work without getting this apparently inappropriate > exception but I'm not sure how to accomplish that.... I'd take a deep breath, relax, become intimate with my debugger, and enjoy. Really, try compiling and running the SSCCE I provided - do you get the variable not resolved? One question. Why arrays here, instead of ArrayLists? The answer would probably be obvious knowing the rest of your code.