comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* One swing application blocks another - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9e2f22843cf4018b
* Help to select a lightweight java ide with intellisense, debugging - 1 messages, 1 
author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6b6d23e24f796f53
* store whole InputStream in a String [OT] - 8 messages, 6 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9
* Hibernate, Tomcat, Ant Question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dfb68d876939af03
* Thread synchronization - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1
* Compiler trick - 7 messages, 5 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2992422eec9fe49
* What is Embedded Java? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bacf063e98ecf899
* How to figure out the width and height of an image? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/52ac3d93bff8088f
* Calling Overridden Methods without super - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b323ca46ffc0fc37
* How to use JTree with very large data? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/145516a872afaa18
* java splash window - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a18982f4ea35d6ef
* obj,fn,parms encapsulation in java - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/620957f075803b3
  
==========================================================================
TOPIC: One swing application blocks another
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9e2f22843cf4018b
==========================================================================

== 1 of 1 ==
Date:   Mon,   Sep 13 2004 7:56 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 13 Sep 2004 07:48:14 -0700, shenia_nim wrote:

> I have the following problem:

Given you posted the same questionon c.l.j.gui
less than two minutes later, I will assume your
problem is not having first realised the best 
group to which to post[1], rather than that you 
are multi-posting[2]..

[1] <http://www.physci.org/codes/javafaq.jsp#groups>
[2] <http://www.physci.org/codes/javafaq.jsp#xpost>

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: Help to select a lightweight java ide with intellisense, debugging
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6b6d23e24f796f53
==========================================================================

== 1 of 1 ==
Date:   Mon,   Sep 13 2004 8:13 am
From: [EMAIL PROTECTED] (Yakov) 

Try Eclipse (eclipse.org)- it works fine on 256MB of RAM, it's
intelligent, support refactoring, has a great debugger and it's free.


Regards,
Yakov




==========================================================================
TOPIC: store whole InputStream in a String [OT]
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d510835287103e9
==========================================================================

== 1 of 8 ==
Date:   Mon,   Sep 13 2004 8:19 am
From: Chris Smith <[EMAIL PROTECTED]> 

Andrew Thompson wrote:
> Just a note that Gravity ends to break long links, 
> even if they are wrapped in the '<' '>' chars..
> I might use it, excepting that.

Yes, it does.  However, it will not break quoted lines.  That's why 
you'll often see me use a quote character before a long URL.

-- 
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



== 2 of 8 ==
Date:   Mon,   Sep 13 2004 8:37 am
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"Paul Lutus" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

>
> http://www.cs.yorku.ca/eiffel/FAQ/gotos-loops-breaks.htm


Good lord, after all this time you give a reference, one that actually 
contains ideas and logic.  Perhaps there is hope for you after all. 





== 3 of 8 ==
Date:   Mon,   Sep 13 2004 9:05 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Chris Smith wrote:

> Paul Lutus wrote:
>> The only difference I see is in behavioral latitude (e.g. a question of
>> degree, not type). "goto" can go anywhere, "break" and "continue" can
>> only jump out of the immediate enclosing control structure, unless they
>> are accompanied by a label, then they can go nearly anywhere, which
>> pretty much makes them a substitute for "goto".
> 
> That's not the case, though.  It makes their behavior a little more
> flexible, but still constrains them to be used only for the purpose of
> exiting blocks.

Yes, I agree. My point was that one could create new entry points through a
liberal scattering of labels, as in my example.

> For example, the following C code could not be 
> rewritten in Java with even a labeled break or continue:
> 
>     int i = 41;
>     goto insane_location;
> 
>     for (i = 0; i < 5; i++)
>     {
>         j = get_valid_value_for_j();
> insane_location:
>         do_something_with(j);
>     }

Yes, it cannot be written in Java, because one cannot have forward
references to a label in Java. In any case, I wasn't suggesting that
break/continue and goto are precisely equivalent, only that break/continue
are capable of the same kind of mischief, in an attenuated form.

/ ... snip code example

> So your 'labelc' actually applies to the entire contents of the while
> loop, and the 'break labelc;' just causes you to quite trying to do the
> contents of the while loop.  If you intended to break only out of the
> conditional block of the if statement, then you should put your label
> directly prior to the open-brace of that block.

My sole point was that this ability to scatter labels about, if exercised by
a student or someone in a hurry, would quickly devolve into a jumble of
difficult-to-interpret code.

> In any case, you 
> haven't written a single break or continue that enters a block at
> multiple points or jumps around arbitrarily -- you have instead only
> used them to leave a block, which is their purpose.

Yes. Since the compiler accepted them, and assuming the compiler won't
accept an irrational label placement, each example exits its associated
block. The problem for the reader is in deciding where the block's
boundaries are.

> 
>> The important thing to remember at this point is that any algorithm that
>> can be created using break/continue and labels can also be created
>> without them.
> 
> The same thing is true of loops and conditionals, which could easily be
> replaced with recursion and polymorphism.  However, I wouldn't want to
> program without them.  The thing to remember is not whether it's
> possible to without break/continue, but rather whether they are
> worthwhile tools for programming.

Which brings us back to the original questions: whether break/continue is in
Java what goto is in other languages, in whole or in part, and whether goto
erodes structure and maintainability with little or not compensating
advantage. I think the latter issue has been decided.

> Writing code without break or continue often results in more levels of
> nesting, more -- and more visible -- loop and conditional structures,
> and the introduction of more local variables to hold temporary flags
> that are only there to get the control flow right.  These are not
> benefits to be aimed for; they increase the complexity of code.

I think structured programming purists would argue that it may take longer
to design an algorithm without break/continue, but the resulting code will
be more comprehensible, not less. One often sees college coursework in
which the use of break/continue is simply forbidden, presumably in the hope
that this will produce a lifelong bias against them.

> 
>> I personally think the inclusion of break/continue was made after a
>> failure of nerve at Sun, who wanted Java ot be adopted by people not
>> terribly crazy about, or particularly adept at, structured programming.
> 
> Yes, you seem to have a number of strong opinions.

True about me, but the bias against break/continue I've been putting forward
is not my opinion. I can't take credit for it.

> This one isn't very 
> viable, though, and you may be well-advised to drop it.

To do so, I would have to disregard a lot of technical literature that makes
the same point in varying ways. I think it is viable.

> Why would Sun 
> go out of their way to design and implement a new extension to a
> language feature, when they've only included it as a concession to non-
> structured programmers?

Why indeed? Since break/continue can be dispensed with and still allow any
algorithm to be designed, since there have been any number of reasoned
objections to arbitrary jumps in otherwise well-structured languages, one
wonders why they did it. I think my explanation is plausible if
hypoerbolic.

> No, it's clear that the engineers at Sun 
> considered break and continue to be acceptable structured alternatives
> to many uses of goto, and strengthened them so that they could handle
> more situations than they could before, but still in a structured way.

I would describe them as a crippled form of goto, and I would say they erode
the degree to which Java is a language based solely on principles of
structured programming.

Also there is the issue of how they are used. They can easily be misused, as
in my example, so one could argue instead that the circumstances of their
use, not their presence in the language, is the real issue. Naturally
enough this makes me wish they were not present, thus preventing their use,
but I wasn't responsible for meeting a shipping date or answering
objections such a yours.

>> What is surprising is this idiom apparantly doesn't occur to students
>> naturally. I noticed this in C and C++ programming discussions also, in
>> years past. It seems to be accepted as a last resort, after every
>> alternative has been found wanting.
> 
> Yep.  The reason for this is that in the course of trying to teach
> students to write readable code, many universities have began
> promulgating the idea that code should be verbose.  Using the expression
> result of assignment operators in C-family languages is one of those
> things that is under attack -- so even universal idioms that do so are
> pressured to be abandoned.

Admirable in principle on the part of the university computer science
departments, but this particular construction seems to be necessary. In
fact, its apparent unreadability has been the main objection in this
thread.

-- 
Paul Lutus
http://www.arachnoid.com




== 4 of 8 ==
Date:   Mon,   Sep 13 2004 9:21 am
From: Alex Hunsley <[EMAIL PROTECTED]> 

ak wrote:
>>>>>>code you write are may be ok, but comments you write are not ok.
>>>>>>Explain me one thing please - if you writing so reliable code,
>>>>>>why your last arachnofillia after click on "Clear file list below"
>>>>>>clears complete File menu?
>>>>>
>>>>>File menu behavior it pretty strange:
>>>>>    File ist is not not below, it is above.
>>>>
>>>>As I expected, you have mucked up your menus. Re-install Arachnophilia,
>>>
>>>and
>>>
>>>>use the customization features more carefully.
>>>
>>>consider to provide "Reset menus" button
>>
>>Already true! How long is this going to take, exactly? Please read the
>>documentation.
> 
> 
> no, [GetRescueMacroSet] is not the same thing as "Reset menus" button.
> 
> This is the biggest problem of free software - programmers does not think
> about user.

Thanks for that HUGE laugh you just gave me, ak. Do you realise how funny what 
you just said was?

So tell me, who are the writers of free software thinking of, if not their users?
I would argue that people selling commerical software are primarily thinking of 
themselves - i.e. their profits - and are *less* likely to think of the end user.

> Users have to do this and other things instead of one simple click.

Awww, boo for you. I would ask for a refund of the money you paid then.
What? You paid nothing for it? It was free? Well, I'd be thanking Paul for 
writing it, instead of whining.
Freeware authors are the first to be interested in feedback on their programs, 
but what they *don't* want to hear is feedback encroached in whining from 
ungrateful users who think freeware authors *owe* them something.

> Just because programmers does not become money for their products,
> they build a big wall between GREAT programmers and LAZY users.
> Stupid users have to read here and there and possibly don't ask any
> questions.

So I suppose you'd have paul wipe your behind for you? Put a bib on you for 
when you eat, in case you spill some food? Hold your hand?

Remember, if it's freeware, that's a big bonus right there - and a little more 
reading about and less laziness isn't going to hurt.

The fact that you readily try to blame Paul for messing up the program menus 
that *you* reconfigured badly speaks volumes. I suppose you think the program 
shouldn't be configurable at all in case you break it?

If you use, and try to configure, a free program, then you do so at your own 
risk. No satisfaction is guaranteed at all. If you think something is wrong 
with it, you could try telling the author - politely - or you could just stop 
using the program.

alex














== 5 of 8 ==
Date:   Mon,   Sep 13 2004 9:37 am
From: Alex Potter <[EMAIL PROTECTED]> 

Gary Labowitz wrote:

> Make me a few suggestions (for the reader, not OS -- I'd go linux for
> that) but I have heard good things about Free Agent (?). More research
> to do, I'm afraid.

Mozilla Thunderbird?

-- 
Regards
Alex
The email address above is a spamtrap. To reply by email use alexp@ the
above domain.



== 6 of 8 ==
Date:   Mon,   Sep 13 2004 10:18 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Mon, 13 Sep 2004 09:19:22 -0600, Chris Smith wrote:

(long URL's break)
> ..That's why 
> you'll often see me use a quote character before a long URL.

How does that look?  Does it preserve the 
URL or simply inform the reader?

I had a quick look back through your 
posts but did not see any links to 
longer URL's.

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology



== 7 of 8 ==
Date:   Mon,   Sep 13 2004 10:37 am
From: Chris Smith <[EMAIL PROTECTED]> 

Andrew Thompson wrote:
> > ..That's why 
> > you'll often see me use a quote character before a long URL.
> 
> How does that look?  Does it preserve the 
> URL or simply inform the reader?

Well, the URL is there.  It just doesn't do the line break.  Here's an 
example:

> http://groups.google.com/groups?q=java+group:comp.lang.java.*&hl=en&lr=&ie=UTF-8&c2coff=1&safe=active&selm=c89pka%24psq%241%40newstree.wise.edt.ericsson.se&rnum=1

-- 
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



== 8 of 8 ==
Date:   Mon,   Sep 13 2004 10:54 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Mon, 13 Sep 2004 11:37:14 -0600, Chris Smith wrote:

> Andrew Thompson wrote:

>>> ..That's why 
>>> you'll often see me use a quote character before a long URL.
>> 
>> How does that look?  
..
> ..Here's an example:
> 
>> http://groups.google.com/groups?q=java+group:comp.lang.java.*&hl=en&lr=&ie=UTF-8&c2coff=1&safe=active&selm=c89pka%24psq%241%40newstree.wise.edt.ericsson.se&rnum=1

That's brill., I'll have to suggest it to 
the Gravity user I know who gives lots 
of long links.  I may even reconsider 
using Gravity, myself.

Tah.

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: Hibernate, Tomcat, Ant Question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dfb68d876939af03
==========================================================================

== 1 of 1 ==
Date:   Mon,   Sep 13 2004 8:25 am
From: "IchBin" <[EMAIL PROTECTED]> 

 Hi All,

I just downloaded hibernate-3.0alpha. I ran the build. After entering 
issuing ant, for the build, I recieved the following message:

C:\Program Files\hibernate-3.0alpha>ant
Buildfile: build.xml
BUILD FAILED
C:\Program Files\hibernate-3.0alpha\build.xml:110: taskdef A class needed by 
class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be 
found: junit/framework/Test
Total time: 5 seconds

I do not know where this ant package is? Does anybody know whick jar I can 
find it in?

I have apache-ant-1.6.2, Tomcat 5.5 running and trying to install the 
hibernate-3.0alpha version.

I have looked at some of the ant jars but can't seem to find it.

-- 


Thanks in Advance...
IchBin
__________________________________________________________________________

'Laughter is inner jogging'
- Norman Cousins, editor and author (1915-1990) 






==========================================================================
TOPIC: Thread synchronization
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1
==========================================================================

== 1 of 2 ==
Date:   Mon,   Sep 13 2004 8:34 am
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"Chris Uppal" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Mike Schilling wrote:
>
>> You've snipped the context.  I was replying to your point that you prefer
>>
>>     synchronized(this) {}
>>
>> to
>>
>>     private Object lock = new Object();
>>     synchronized(lock) {}
>>
>> and explaining the dangers of the former.
>>
>> This idea isn't peculiar to me, by the way.  Bloch makes the same point 
>> in
>> _Effective Java_.
>
> I'm still not sure I'm following you.  Is your objection that without a
> "hidden" lock object, it is possible for an arbitrary bit of foreign code 
> to
> execute a synchronised block on the object in question, thus potentially
> preventing it from making further progress in its real task ?

No, it's that any class C can do a

    synchronized(o)

on any object o it has access to.  If that object is also synchronizing on 
itself, this can play havoc with its internal synchronization logic.   Note 
that this is independent of how well the internal synchronization is 
encapsulated, or of whether the object's class is visible  to C.


>
> If so then I think the reasoning is backwards, maybe even circular.  It 
> seems
> to me that the only reason "someone else" is likely to lock "your" object
> inappropriately is that the practice of taking out locks on 
> other-than-self is
> being followed.  What I call spaghetti synchronisation (I admit the term 
> is
> loaded).

Agreed that this can be a bad practice.  So can calling random methods in 
other classes that aren't specifically esigned to be called by outsiders. 
However, rather than depend upon convention and good manners to avoid this, 
Java defines access modifiers for methods to prevent it.
>
> If you consider that in the normal case (and overwhelming majority at 
> that), an
> object will hold a lock only on itself, then the "danger" is obviously
> chimerical.  But, in order to avoid it, you (if I'm interpreting you 
> correctly)
> throwing away the obvious benefits to comprehension of allowing the 
> objects to
> carry the conceptual load.

I don't think

    private Object lock_object();

    synchronized(lock_object)

differs in concept from

    synchronized(this)

particularly when you understand the reason for it.

>
> That's how I see it anyway.
>
> (I haven't read "Effective Java"; I remember looking at it in a bookshop 
> and
> thinking "nah", but I can't now remember whether that's because I thought 
> it
> misguided -- as in this case -- or just that it was telling me stuff I 
> already
> knew.  I shall have to check it out again.)

I recommend it.  My experience was that some of it was well-known and 
obvious, while other parts were new and valuable. 





== 2 of 2 ==
Date:   Mon,   Sep 13 2004 9:06 am
From: Babu Kalakrishnan <[EMAIL PROTECTED]> 

Chris Uppal wrote:
> Mike Schilling wrote:
> 
> I'm still not sure I'm following you.  Is your objection that without a
> "hidden" lock object, it is possible for an arbitrary bit of foreign code to
> execute a synchronised block on the object in question, thus potentially
> preventing it from making further progress in its real task ?
> 
> If so then I think the reasoning is backwards, maybe even circular.  It seems
> to me that the only reason "someone else" is likely to lock "your" object
> inappropriately is that the practice of taking out locks on other-than-self is
> being followed.  What I call spaghetti synchronisation (I admit the term is
> loaded).
> 
> If you consider that in the normal case (and overwhelming majority at that), an
> object will hold a lock only on itself, then the "danger" is obviously
> chimerical.  But, in order to avoid it, you (if I'm interpreting you correctly)
> throwing away the obvious benefits to comprehension of allowing the objects to
> carry the conceptual load.
> 

You're oversimplifying the case - Chris. What you're saying is perfectly fine as 
long as the object in question is a simple one you've created - possibly 
descending from java.lang.Object. However, in a real life scenario, you very 
often extend existing library classes, and you don't know (and shouldn't really 
depend on) the implementation specifics. Unfortunately, the synchronization 
behaviour of a class is almost always never specified in the API, and you end up 
not knowing if some of the methods implemented in the superclass synchronize on 
itself or not - with the result that one is never very sure if you can get into 
a deadlock situation if you synchronize on "this".

If you recollect, there was a thread about a week ago when a poster was 
surprised that he was getting unexpected notifications when he was "wait()"ing 
on a Thread object. The fact is that the Thread object is probably sending out 
notifies (which obviously means it has synchronized blocks on itself), but it is 
never specified anywhere. In such a scenario, would you say that 
synchronized(this) is safe to do in the case of an object descending from 
java.lang.Thread ?

I recall a situation where some GUI classes that people from my organization 
wrote suddenly started deadlocking when a new version of JDK was released (IIRC 
it was a switch from JDK 1.1.4 to JDK 1.1.5) - We were really surprised because 
our code didn't have any synchronized blocks at all (or so we thought). 
Eventually the problem was traced to some code introduced by Visual Cafe (which 
we used in those days for building the GUI) - where it would override the show() 
method of a java.awt.Dialog to do some vague thing (I think setting the dialog 
position to the centre of the screen or something), and the method was declared 
"public synchronized void show()" (I suppose they declared it synchronized 
because the original show method was synchronized also till JDK 1.1.4). So when 
the implementation of the libary class changed, it introduced a deadlock !

I notice that most classes in the Swing library now use internal private monitor 
objects - but in spite of that, I always tell the programmers to never really 
depend on these implementation specific - so in the code produced in our 
company, you will never find a synchronized method unless the Object was built 
from scratch by you - and it wasn't meant to be extended. Maybe overkill, but 
then seeing production code break due to a change in the library implementation 
isn't something I want to see if at all possible.

BK





==========================================================================
TOPIC: Compiler trick
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2992422eec9fe49
==========================================================================

== 1 of 7 ==
Date:   Mon,   Sep 13 2004 9:03 am
From: [EMAIL PROTECTED] (Razvan) 

> Andrew Thompson wrote:
> 
> > /** Your second CDummy class did not compile. */
> 
> I think Razvan's point is that it doesn't compile.

          Yes, indeed that was my point. My innitial prediction was
that the second code would also compile and print the same result, but
it did not. The Java compiler should be more consistent: it should
detect both cases ('if else' and 'if if') or it should complain on
both. I saw this code on a Java test; for such questions your only
solution is to remember how the compiler behaves. I don't like things
that you just have to remember.



Regards,
Razvan



== 2 of 7 ==
Date:   Mon,   Sep 13 2004 9:16 am
From: [EMAIL PROTECTED] (Razvan) 

Hi Andrew,



> I replaced your code (the second of which  does not compile), with this version that 
> is self contained and does compile.

        I have mentioned that you should not try to run/compile.
Indeed, the second class is not compilable. It seems that you did not
anticipated that.




Razvan



== 3 of 7 ==
Date:   Mon,   Sep 13 2004 9:25 am
From: Joona I Palaste <[EMAIL PROTECTED]> 

Razvan <[EMAIL PROTECTED]> scribbled the following:
>> Andrew Thompson wrote:
>> > /** Your second CDummy class did not compile. */
>> 
>> I think Razvan's point is that it doesn't compile.

>           Yes, indeed that was my point. My innitial prediction was
> that the second code would also compile and print the same result, but
> it did not. The Java compiler should be more consistent: it should
> detect both cases ('if else' and 'if if') or it should complain on
> both. I saw this code on a Java test; for such questions your only
> solution is to remember how the compiler behaves. I don't like things
> that you just have to remember.

I disagree. The rules for "if else" are far easier, more deterministic,
and allow for less loopholes than your artificially constructed "if if"
scenario. When you have an "if else" construct, it is a fact that
*always* *exactly one* of the "if" and "else" branches shall be
followed.
However, in your "if if" case, you have to separate "if" statements,
which happen to coincide by having exactly opposite criteria. A human
will be able to look at both at the same time, understand that the
value of an int variable is *always* *either* more than 10 *or* less
than or equal to 10 (paraphrasing your original code), but
automatically deducing this from a set of program statements requires
quite an advanced algorithm, when done by an automaton that can only
ever do what it is told to do, with no intuition or bright ideas of
its own. Here's a rough outline of what it would have to do:
- Note the first "if" statement and store both operands of its
criterion to memory for late comparison,
- Note the execution branch of the "if" statement as a currently open
execution path,
- Note that there is no code between the two "if" statements that might
diverge program flow away from the second "if" statement,
- Note the second "if" statement and store both operands of its
criterion to memory,
- Note the execution branch of the "if" statement as a currently open
execution path,
- Compare the operands of both "if" statements, seeing that the first
operand is the same variable, the second operand is the same constant,
and the operators are directly opposite,
- Deduce that the criteria of the two "if" statements are directly
opposite,
- Use this information to close both open execution paths,
And only then proceed as it would have done *straight away* in the
"if else" case.
What if the variable in the second "if" statement was not i, but j, and
j was assigned a value from i? What if that assignment was done not in
the normal execution path, but an "if" statement whose criterion just
happened to be always true? What if there was a reassignment to j later,
but in a "for" loop that iterates exactly 0 times? What if j was first
decremented by two, then incremented by one, then again incremented by
one?
Go on, *you* try to write a formal, deterministic algorithm to take
care of all this. I suppose there are highly-paid research groups in a
couple of universities working on it. If you produce successful reports,
you could write an article about it in a computing magazine.
The issue gets even more interesting when the criteria for the "if"
statements come from methods in different objects. Sooner or later the
Java compiler will essentially have to run the program in order to find
out if it can compile it.
But for the "if else" case, there is only one simple rule: In every
"if else", no matter where it appears or what its criterion or
background state are, *exactly one* of its branches will *always*
execute. Not both, not neither, *exactly one*. All the compiler has to
do is to spot an "if" with an "else" and instantly arrive at this
conclusion.

-- 
/-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Stronger, no. More seductive, cunning, crunchier the Dark Side is."
   - Mika P. Nieminen



== 4 of 7 ==
Date:   Mon,   Sep 13 2004 10:02 am
From: Jacob <[EMAIL PROTECTED]> 

Chris Uppal wrote:

> We are cleverer than the compiler, so we can see that it /is/ initialised on
> every path.  

I'm not a thread expert, but in general:

   if (clause)
     statement1;
   if (!clause)
     statement2;

couldn't some external factor (i.e. a thread) cause
_none_ of the two tests to be true; If the premises
of "clause" is changed just after the first test?

This could never be the case for

   if (clause)
     statement1;
   else
     statement2;





== 5 of 7 ==
Date:   Mon,   Sep 13 2004 9:55 am
From: "P.Hill" <[EMAIL PROTECTED]> 

Jacob wrote:
> couldn't some external factor (i.e. a thread) cause
> _none_ of the two tests to be true; If the premises
> of "clause" is changed just after the first test?

The particular example only included local variables, but as
pointed out by Joona P. such analysis requires complete understanding of all
expressions and paths which is not a very practicle approach for a compiler.

-Paul




== 6 of 7 ==
Date:   Mon,   Sep 13 2004 10:24 am
From: "Raza S. Ali" <[EMAIL PROTECTED]> 


So the problem here, is the way java handle's Control Flow.  When it sees 
an if statement, it will ignore all code before that.
This stems from the fact that java is *mostly* a structural programming 
language, and that it compiles the entire program before
evaluating one line at a time.

It looks at the first if, and says, ok here is something that clause can 
see.

At this point the first if statement is over, so it looks at the second 
one.  Even though every possibillity appears to
accounted for, it turns out that instead, the comiler doesn't hold enough 
state to know this.  So you must either explicitly
initilize, or use if - else instead.  Just a caveat of java.

   -Raza


On Mon, 13 Sep 2004, P.Hill wrote:

> Jacob wrote:
>> couldn't some external factor (i.e. a thread) cause
>> _none_ of the two tests to be true; If the premises
>> of "clause" is changed just after the first test?
>
> The particular example only included local variables, but as
> pointed out by Joona P. such analysis requires complete understanding of all
> expressions and paths which is not a very practicle approach for a compiler.
>
> -Paul
>
>



== 7 of 7 ==
Date:   Mon,   Sep 13 2004 10:39 am
From: Joona I Palaste <[EMAIL PROTECTED]> 

Raza S. Ali <[EMAIL PROTECTED]> scribbled the following:
> So the problem here, is the way java handle's Control Flow.  When it sees 
> an if statement, it will ignore all code before that.
> This stems from the fact that java is *mostly* a structural programming 
> language, and that it compiles the entire program before
> evaluating one line at a time.

This part is true enough.

> It looks at the first if, and says, ok here is something that clause can 
> see.

> At this point the first if statement is over, so it looks at the second 
> one.  Even though every possibillity appears to
> accounted for, it turns out that instead, the comiler doesn't hold enough 
> state to know this.  So you must either explicitly
> initilize, or use if - else instead.  Just a caveat of java.

"Just a caveat of java"? I challenge you to implement *any* compiled
programming language that can do this automatic verification of every
condition of every branch of execution code without actually running
the problem. I wrote some theoretical aspects about it another reply,
you might want to read it.
It's not that *JAVA* explicitly refuses to do a full control flow
analysis at compile time. It's that such an analysis is inherently
extremely difficult to design, let alone implement.

-- 
/-- Joona Palaste ([EMAIL PROTECTED]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"My absolute aspect is probably..."
   - Mato Valtonen




==========================================================================
TOPIC: What is Embedded Java?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bacf063e98ecf899
==========================================================================

== 1 of 1 ==
Date:   Mon,   Sep 13 2004 9:06 am
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> 

> J2ME is the only technology I've looked at. I've run some
> tutorials and it all look good. However, it is hard to
> assess when I don't know the alternatives.


Some alternatives are:

gcj

- This is a an ahead of time compiler. Can be adapted to an embedded
system with some effort, but this is some real cool technology.

applix jblend
savaje
esmertec

- The above three companies were into the embedded java arena but are
now concentrating on 'wireless'

aicas, JamaicaVM

- This is some cool technology because of how they do garbage
collection.

JX
Jnode

- These are java operating systems/VMs that can be adapted to embedded
systems.

The rest of the bunch:

apogee software, aphelion
New Monics, PERC
Skelmir, cee-j
NSIcom
Acunia, WONKA
OneEighty Software





==========================================================================
TOPIC: How to figure out the width and height of an image?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/52ac3d93bff8088f
==========================================================================

== 1 of 2 ==
Date:   Mon,   Sep 13 2004 9:07 am
From: "Zsolt" <[EMAIL PROTECTED]> 

Hi,

how can I figure out the height and width of an image (gif,jpeg, png etc.)
file?

Zsolt





== 2 of 2 ==
Date:   Mon,   Sep 13 2004 10:08 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Mon, 13 Sep 2004 18:07:49 +0200, Zsolt wrote:

> how can I figure out the height and width of an image (gif,jpeg, png etc.)
> file?

  Image image = Toolkit.getDefaultToolkit().getImage("pretty.gif");
  int width = image.getWidth(null);
  int height = image.getHeight(null);

HTH

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: Calling Overridden Methods without super
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b323ca46ffc0fc37
==========================================================================

== 1 of 1 ==
Date:   Mon,   Sep 13 2004 9:38 am
From: Alex Hunsley <[EMAIL PROTECTED]> 

Marco wrote:

> Can I call the overridden version of an object's foo() method 
> outside that object's class, without using super? EG:
> 

This is really not a good idea. No idea what your situation or constraint is, 
but the fact you're trying to do this suggests to me that you should rethink 
the design or find a different way around things.

As someone else suggested, it should be up to the target class whether it uses 
its own code, calls super, or whatever. Inheritence of class A should be 
transparent as far as anotehr class, B, that uses A is concerned.

alex





==========================================================================
TOPIC: How to use JTree with very large data?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/145516a872afaa18
==========================================================================

== 1 of 2 ==
Date:   Mon,   Sep 13 2004 9:40 am
From: [EMAIL PROTECTED] (Sorin Gherman) 

Hi,
I have the following problem: I have this large amount of data, stored
internally in some custom data structures (hierarchical ones, given
the nature of the data - I am using some custom, tree-like structurs
for this).
I have to show the different relations within this data using several
JTrees - one per "viewpoint". (The good news is that I only have to
show one type of view at a time.)

The first implementation I came up with is just creating a tree model
(using DefaultMutableTreeNodes) for each view, and displaying it using
JTree.
Problem: memory consumption is very high (due to the duplication of
the tree structures in memory, and the fact that the user may toggle
between views fast, thus trees are created and thrown away - again,
memory is an issue so I cannot affort to store them).

I read about the possibility to have my own internal data implement
the TreeNode interface, and have the JTree uses the internal data
directly - thus avoiding the creation of extra trees.
Problem: the implementation gets very complicated very fast due to the
different views. I can still live with that, but then I realized that
due to TreeNode.getParent() method, I would still have to duplicate,
in memory, for each view, at least the "parent" references. (This is
due to the fact that most of the internal nodes in my data structures
have different parents in different views...). Which means it doesn't
save that much memory after all... (well, it still saves the child
references and the node duplication).

So I am wondering: is there any well-know "cure" for these type of
problems?

Thanks in advance,
Sorin Gherman



== 2 of 2 ==
Date:   Mon,   Sep 13 2004 10:18 am
From: Babu Kalakrishnan <[EMAIL PROTECTED]> 

Sorin Gherman wrote:
> Hi,
> I have the following problem: I have this large amount of data, stored
> internally in some custom data structures (hierarchical ones, given
> the nature of the data - I am using some custom, tree-like structurs
> for this).
> I have to show the different relations within this data using several
> JTrees - one per "viewpoint". (The good news is that I only have to
> show one type of view at a time.)
> 
> The first implementation I came up with is just creating a tree model
> (using DefaultMutableTreeNodes) for each view, and displaying it using
> JTree.
> Problem: memory consumption is very high (due to the duplication of
> the tree structures in memory, and the fact that the user may toggle
> between views fast, thus trees are created and thrown away - again,
> memory is an issue so I cannot affort to store them).
> 
> I read about the possibility to have my own internal data implement
> the TreeNode interface, and have the JTree uses the internal data
> directly - thus avoiding the creation of extra trees.
> Problem: the implementation gets very complicated very fast due to the
> different views. I can still live with that, but then I realized that
> due to TreeNode.getParent() method, I would still have to duplicate,
> in memory, for each view, at least the "parent" references. (This is
> due to the fact that most of the internal nodes in my data structures
> have different parents in different views...). Which means it doesn't
> save that much memory after all... (well, it still saves the child
> references and the node duplication).
> 

The TreeModel interface never assumes that each node implements the TreeNode 
interface, they can be objects of any type, so strictly speaking, a getParent() 
method never needs to be implemented.

All you require in the model is the definition of a root object, and the ability 
to provide a list of children for a given node - I would assume that your data 
structure would allow at least this to be available somewhere (or at least 
computable on the fly) since you say the structure is tree-like in nature.

Yes - implementing the event releated methods can be a little bit tricky, but if 
you look carefully, all the related classes (such as TreePath) also require only 
objects, and as long as you can define the tree from top down, you should be 
able to create the appropriate events. (Of course it would be very much easier 
if the tree weren't mutable at all).

BK




==========================================================================
TOPIC: java splash window
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a18982f4ea35d6ef
==========================================================================

== 1 of 2 ==
Date:   Mon,   Sep 13 2004 10:28 am
From: "slawek" <[EMAIL PROTECTED]> 

This is for you
public class Powitanie extends JWindow
{


    public Powitanie( int czas)
    {
        JPanel panelObrazu = new JPanel(new BorderLayout());
        ImageIcon obraz= new ImageIcon("d:\\development\\ObrazekStart.gif");
        panelObrazu.add(new JLabel(obraz, SwingConstants.CENTER));

        getContentPane().add(panelObrazu);

        pack();
        wysrodkuj();
        show();
        if(czas !=0)
        {
            try
            {
                Thread.sleep(czas);
                dispose();
            }
            catch(InterruptedException e)
            {

            }
        }
    }
    public void wysrodkuj()
    {
        Toolkit monitor= Toolkit.getDefaultToolkit();
        Dimension srodek=monitor.getScreenSize();
     //   int wysEkranu=srodek.height;
     //   int szerEkranu=srodek.width;
        int wysEkranu=(int)  ((srodek.getHeight()- getHeight())/2);
        int szerEkranu=(int) ((srodek.getWidth()- getWidth())/2);
  //      setLocation(wysEkranu/4, szerEkranu/4);
         setLocation( szerEkranu,wysEkranu);
    }

}



Uzytkownik "Roy Ratcliffe" <[EMAIL PROTECTED]> napisal w wiadomosci
news:[EMAIL PROTECTED]
> gino wrote:
> > can anybody show me how to show a splash window before my program
formally
> > starts for 10 seconds. The splash window should show only color
image/logo,
> > without any window frame, title bar, etc.
> >
> > how to use Java to implement this?
>
> Dear Gino,
>
> Maybe a little too late, but see what you think of this one
> http://www.aqss05.dsl.pipex.com/
> It tries to avoid cruft with useful compromises, and makes use of
> asynchronous image loading---particularly useful in multiprocessor hosts
> when available.
>
> Regards,
> Roy
> [EMAIL PROTECTED] (work)
> [EMAIL PROTECTED] (study)





== 2 of 2 ==
Date:   Mon,   Sep 13 2004 10:51 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Mon, 13 Sep 2004 19:28:38 +0200, slawek wrote:

> This is for you
> public class Powitanie extends JWindow ...

A *Swing* component for a splash screen?
You must be pulling our chains.

But that reminds me, I must put up the
code of my variant of Roy's version.
Special considerations were, both
1.1 and applet compatibility.

[ F'Ups set to c.l.j.gui ]

-- 
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology




==========================================================================
TOPIC: obj,fn,parms encapsulation in java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/620957f075803b3
==========================================================================

== 1 of 1 ==
Date:   Mon,   Sep 13 2004 10:47 am
From: [EMAIL PROTECTED] (Tim Jowers) 

i repeatedly see this pattern:

    {   TBaseType ret = TBaseType.Factory.newInstance();
        try{ 
             // start some call //
             dbControl.deleteSearchLog(logId);
             // after some call //

           } catch(SQLException sqe)
           {    // return error code
                ret.setErrorCode( "1" );
                ret.setErrorMessage( sqe.toString() );
                Log(""); ...
           }
        return ret;
    }

where I have a method or segment of code that is 90% identical except
for a line or a few lines. What pattern makes this easy to work with?

The only idea I have is to create a class that takes an object, method
name, and parameter array and makes the call. Is that the typical
solution? It seems very contrived and hard to work with versus just
typing the code like
dbControl.deleteSearchLog(logId);
And seems to totally break if I have several statements. Then I have
to make a new method to hold each of the statements and somehow pass
all the required parameters...

Thanks,
TimJowers



=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/BCfwlB/TM
--------------------------------------------------------------------~-> 

<a href=http://English-12948197573.SpamPoison.com>Fight Spam! Click Here!</a> 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/kumpulan/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to