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

Today's topics:

* Thread synchronization - 2 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1
* TVApplet - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d9741cf2145c0ed5
* Setting up Tomcat to run jsp/servlet's from USB keychain - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2e53192e39882732
* Help to find a package - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9283172d928fc5ca
* JSTL commands do not work - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/318f42abad9da29e
* Bah. Struts problem. Validation -- or lack thereof. - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d69560b1a7cfa47
* How to render JTable headers as icons? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/89bc5d9dd7a1c2a5
* Client Server socket behavior on XP different for 127.0.0.1 - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2c44a25c74b9f7e2
* Would like a preprocessor. - 4 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f8d589c27ece424e
* newbie servlet help - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50ef5e726a3bf788
* Applet steals focus... - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/59ad54d25b88280f
* Who can resist a compilable example? - JComboBox - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a964462dca846012
* sprintf - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/488e725956316480
* WANTED: SOFTWARE INVENTIONS - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/31f204232b3af08
* Does Sun's Windows JVM catch Win32 Structured Exceptions? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/210d1a596cd7c8ff
* Self-Mutation with Strategy Object - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7667c4e1519c515
* aspectj ant import not found - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e213e5fed0c81781
  
==========================================================================
TOPIC: Thread synchronization
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/172837b7b0667fd1
==========================================================================

== 1 of 2 ==
Date:   Wed,   Sep 1 2004 6:09 pm
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

Eric Sosman coughed up:
> Thomas G. Marshall wrote:
>> Eric Sosman coughed up:
>>
>>>     Synchronization is about protecting the object, not about
>>> protecting the code.
>>
>> uh....................  You seem to understand this issue very well,
>> but you've used a sentence that I'd never suggest anyone use.
>>
>> Synchronization is about protecting sections of code.  Whether or
>> not there is an object involved to be protected as such is
>> secondary.  The object used can merely be to "hold the lock".
>>
>> For example,
>>
>> public class YoiksAndAwayWham
>> {
>>     Object lock = new Object();
>>
>>     ...
>>
>>     void dangerousThingy()
>>     {
>>             ....lots of safe stuff...
>>             synchronized(lock)
>>             {
>>                     ...stuff not protecting current object, nor
>>                     protecting "lock" but meant to protect this
>>                     section of code from collision with other
>>                     similar methods.  Protecting YoiksAndAwayWham
>>                     instances may never even enter the picture...
>>             }
>>     }
>>
>>     void anotherDangerousThingy()
>>     {
>>             ....lots of safe stuff...
>>             synchronized(lock)
>>             {
>>                     ...stuff not protecting current object, nor
>>                     protecting "lock" but meant to protect this
>>                     section of code from collision with other
>>                     similar methods.  Protecting YoiksAndAwayWham
>>                     instances may never even enter the picture...
>>             }
>>     }
>> }
>
>      In what way can the synchronized blocks (in this example
> or in your follow-up with a static lock) "collide?"  The code
> is immutable whenever it's executable (that is, from the time
> it's been loaded to the time when it's unloaded, if ever), so
> it doesn't seem to be in need of much protection ...

And how on earth do you know what threads are involved here?

What if: The first method is called within one thread.  The 2nd in another.
Both of these access something that just cannot be accessed by more than
one.  This can involve something as innocuous as simple arithmetic on an
integer primitive.  Multiple threads doing very simple non-atomic things all
at once can result in unpredictable results.


>      The only kind of "collision" I can envision is if the two
> pieces of code both manipulate some kind of shared resource.
> Usually, that resource is a Java Object, and the Object is
> the thing that needs the protection.

It can be several objects, or simply an algorithm that cannot be
interrupted.  But it's not about saving the objects involved.  It's about
keeping multiple executions of segments of code blocked until one execution
is done.


>   Sometimes the resource
> is something outside Java, so Java cannot protect it: Java
> cannot synchronize access to an on-disk file, for example.
> But almost invariably any such extra-Java resource will have
> a Java Object acting as its "proxy," and you protect the
> actual resource by "protecting" its proxy: you synchronize
> on the File object that represents the file on disk.
>
>      Sometimes the shared resource has little physical reality.
> You might be generating output with System.out.print() calls,
> for example, and trying to ensure that the output from
> different threads doesn't get intermixed on a single line.
> The synchronized blocks in your example would contain several
> System.out.print() calls followed by System.out.println(),
> and synchronization would prevent intermixture.

That is the precise example I use when I teach java.


> You might want
> to think of this as protecting the code,

And you should.  "protection" has a great many meanings.  It seems that you
are comfortable saying that anything that allows an algorithm to stay
functional is protecting the objects.  But your statements go beyond that.
The object is not what is protected, it is a section of code.  That may
result in objects behaving properly.


> but to me it seems more
> useful to think of the lock object as a proxy for "the current
> line," a resource outside Java that Java manipulates through the
> System.out object.

This makes no sense whatsoever.


> (You could, I suppose, use the System.out
> object itself for this purpose -- I wouldn't, myself, but it
> "should" work, I think.)
>
>      One of the characteristics of object-oriented programming
> is that it has (duh...) an object-centric orientation rather
> than a code-centric orientation.

No, it has object orientation rather than /procedural/ orientation.  "code"
lives in both paradigms.  Wow, you're all over the map on this post.


>  That being the case, it seems
> far more natural to think about protecting the objects than
> about which disparate pieces of code are or are not running
> simultaneously.  It happens that I find this viewpoint helpful
> when thinking about synchronization in non-O-O languages, too --
> but for an O-O language it seems almost a foregone conclusion
> that one would think in this way.  YMMV.

It is not the object in total that is protected.  It is a section of code
that you specifically force blockage into.  If you instruct people to think
that synchronization is protecting objects, then you are misleading them
horribly.  The bottom line is not that they are objects.  The bottom line is
that a section of executable code is protected from re-entrance by another
thread.

-- 
"It's easier to be terrified by an enemy you admire."
-Thufir Hawat, Mentat and Master of Assassins to House Atreides





== 2 of 2 ==
Date:   Wed,   Sep 1 2004 6:19 pm
From: "Thomas G. Marshall" <[EMAIL PROTECTED]> 

Steve Horsley coughed up:
> Razvan wrote:
>> Hi
>>
> <snip>
>>
>>
>> I am synchronizing 2 threads on the Integer 'threadId'. Since the
>> code is trivial it seems to work. However, each thread class has its
>> own threadId. Since the object is not common for the 2 threads, that
>> means no synchronization is taking place in the method printData().
>>
>
> Right.
>
>> The only solution that I can think of is to make the threadId static.
>> Being static all the threads will share the same static object thus
>> synchronization should occur.
>>
>> If my observation is correct that means that you can only synchronize
>> on class (static) variables but not on member variables.
>>
>
> That's not strictly true. To make code blocks exclusive, they must
> synchronize on the same Object, but this need not be by a static
> reference. It could be an Object handed as a method argument, or
> returned from
> another Object.method, e.g. myHashMap.get("BackDoorLock");
>
> Actually, a dirty trick using interned String constants goes like
> this:
>
>     synchronized("BackDoorLock") {
>         ...
>     }
>
> Actually, I recommend not extending Thread, but always using Runnable
> objects instead. This is because it gets very confusing when you start
> to synchronize by having one Thread subclass trying to lock on a
> different Thread subclass's member Objects or call another Thread
> subclass's methods. It's simpler if there are just Runnables that may
> be visited by more than one thread than if a Thread is being visited
> by a different Thread's thread. If that makes any sense.
>
> Steve

For similar reasons I *strongly* recommend that a newbie not use
synchronized methods such as:

        public synchronized void hoohaa()
        {
            //...goblidy gook...
        }

but instead use

        public void hoohaa()
        {
            synchronized (myLock)
            {
                //...goblidy gook...
            }
        }

and have myLock be an Object instance devoted to nothing but holding the
lock.

The reason for this is important:

a. it keeps the confusion down in general about whether or not a lock is
held by the same instance as used elsewhere.

b. it keeps the following bug out.  This bug I've seen time and time again:
someone tries to add a synchronized method, but later makes it static for
some other reason.  But he forgets that synchronized then is locking on the
class object when used with static.  Two locks in that case.

<bug>
        public synchronized void hoohaa()
        {
        }

        //and then someday someone adds this:
        public static synchronized void anotherMethod()
        {
                // not protected against hoohaa() collisions...
        }
</bug>


-- 
"It's easier to be terrified by an enemy you admire."
-Thufir Hawat, Mentat and Master of Assassins to House Atreides






==========================================================================
TOPIC: TVApplet
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d9741cf2145c0ed5
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 6:09 pm
From: Sudsy <[EMAIL PROTECTED]> 

Jenny wrote:
> Hi,
> 
> I tried TVApplet from Sun.  It works with .avi file.  It can play
> audio out of .mov file but the screen is black.  It does not play
> .mpeg file.  So I think that JMF ( Java media framework ) only work
> with .avi.  If i am wrong, please tell what I need to make other movie
> types work.
<snip>

Jenny,
    No offence intended, but you've been asking a lot of questions on
this ng recently. Given the time lag between posting and possible
responses, you'd likely be better served by doing your own research.
There is a plethora of information available on-line. Get comfortable
with a search engine and go to town.
If you want to check the archives (to see if your question has already
been answered in the past) then start here:
<http://groups.google.com>
I use Yahoo! for most of my searching (but it's definitely a personal
taste issue) and so you could start here:
<http://www.yahoo.com>
Thankfully, most search engines have standardized on the query strings
(both of the above adhere to it) so all you have to do is specify the
keywords and prefix each with a plus sign.
To answer questions on Java software, go to the source:
<http://java.sun.com>
(ps. Their search engine also adheres to the common format.)
As far as the data format on a CD, why not ask the person who performed
the conversion from tape in the first place? If it's generated by Sony
software then just visit the Sony site (the URL is, quite naturally,
<http://www.sony.com>.)
But if you've encountered something really gnarly and have nowhere else
to turn then the people here might be able to help. Some of us love a
challenge!  :-)





==========================================================================
TOPIC: Setting up Tomcat to run jsp/servlet's from USB keychain
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2e53192e39882732
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 6:15 pm
From: "Murray" <[EMAIL PROTECTED]> 


"DiscoStu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thats right,
>
>      I've got this client program that runs as a series of JSP pages
> and a few servlets. I want to distribute just my web application on
> the keychains, and then have Tomcat5 installed on all the machines
> that will run the client program. I know I can setup a Tomcat context
> to point to a directory OTHER then in the /webapps folder. So I want
> to point to my webapp stored on the keychain drive, but when Tomcat
> loads the keychain wont be attached so it wont be able to load that
> context on startup. If a user plugs his/her keychain drive in and the
> directory then becomes valid, will tomcat know enough to then load-up
> the context? (Does it rescan the server.xml file, like it does the
> web.xml files?)
>
> Also, what would be the consequences of having the user pull out the
> keychain drive, thus making the web application unavailable to Tomcat.
> Will tomcat be able to recognize and gracefully handle that?
>
> Thanks everyone,
>
>      Greg

I doubt very much any of that will work in the way you want. Tomcat doesn't
rescan the server.xml for changes, and doesn't automagically retry to load
contexts after they fail. However, it does monitor the webapps directory and
will hot-deploy a new app if it finds one.

Instead of defining the Context in server.xml, you can use a separate xml
descriptor which might look something like this

        <Context path="/whatever" docBase="E:/myProject/war" debug="0"
reloadable="true">
          <Loader reloadable="true" checkInterval="5"/>
        </Context>

When the USB drive is connected, you could run a script that copies this XML
descriptor into the tomcat/webapps dir. Tomcat will detect the change and
deploy the app from the USB drive

As for removing the key, Tomcat will actually crash. I just tried it myself.
The entire server shuts down.






==========================================================================
TOPIC: Help to find a package
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9283172d928fc5ca
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 6:34 pm
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 1 Sep 2004 16:51:00 -0700, Jenny wrote:

> In the code, it used a package sun.audio.  Could you help to find it?

rt.jar!sun/audio/     ;-)

Java arrives in Zip files.  The sun.audio package
resides in the sun/audio/ directory of the Java rt.jar.

What I wrote above is how it might appear as
part of an URL to the sun.audio package..
the rt.jar tells the file name, followed !
to mean a Zip or Jar archive..

Or is it the JavaDocs you mean?  
There are none.   

Sun reserves the right to change any of 
those classes at any time.  They say *not*
to use them directly, but to use the documented
methods whaich call them instead.

Does that help?

-- 
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: JSTL commands do not work
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/318f42abad9da29e
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 6:36 pm
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 1 Sep 2004 16:32:24 -0700, Joop Kaashoek wrote:

>> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt"; prefix="fmt_rt" %>
> 
> Yes, we tried using
> 
> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt"; prefix="fmt_rt" %>

Is that a directory it refers to?
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt/"; prefix="fmt_rt" %>

-- 
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: Bah. Struts problem. Validation -- or lack thereof.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5d69560b1a7cfa47
==========================================================================

== 1 of 3 ==
Date:   Wed,   Sep 1 2004 7:39 pm
From: Steve Sobol <[EMAIL PROTECTED]> 

Sudsy wrote:

> Steve Sobol wrote:
> <snip>
> 
>> I think I found the problem. I initialized email and password to null 
>> instead of an empty string, and that fixed things. (Looks like it, 
>> anyhow; I'll report back here if it didn't.)
> 
> Doh! An empty string satisfies 'required'; a null string doesn't.
> You might also want to institute some sanity checking so that a
> user can't specify a string of spaces, for example.

In this case, not necessary for a login page, since a string of blanks won't 
match any username or password on my system anyhow. :)

OK, one more quick question. I figured out why my errors aren't printing out - 
they are listed in the message resource file as error.(whatever) or 
PropertyName.(whatever) but Struts is prepending locale information so that it 
looks for a resource named, for example, en_US.error.required instead of 
error.required. If I don't want to use i18n right now, is there any way to 
prevent the locale name from being prepended?

Thank you for your help. (Brice too)

**SJS

-- 
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / [EMAIL PROTECTED]
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California     Nothing scares me anymore. I have three kids.



== 2 of 3 ==
Date:   Wed,   Sep 1 2004 8:21 pm
From: Sudsy <[EMAIL PROTECTED]> 

Steve Sobol wrote:
<snip>
> OK, one more quick question. I figured out why my errors aren't printing 
> out - they are listed in the message resource file as error.(whatever) 
> or PropertyName.(whatever) but Struts is prepending locale information 
> so that it looks for a resource named, for example, en_US.error.required 
> instead of error.required. If I don't want to use i18n right now, is 
> there any way to prevent the locale name from being prepended?

That's a fall-back position, where the locale on the server doesn't
match the browser. I've played around with I18N and never had any real
problems. I hate to do this to you again, but offer another link to
an article in my Struts series:
<http://www.sudsy.net/technology/struts-messageresources.html>
If the default locale on the server side matches what is presented by
the browser then nothing will be prepended.
Let us know how things work out!




== 3 of 3 ==
Date:   Wed,   Sep 1 2004 8:33 pm
From: Sudsy <[EMAIL PROTECTED]> 

Sudsy wrote:
> Steve Sobol wrote:
> <snip>
> 
>> OK, one more quick question. I figured out why my errors aren't 
>> printing out - they are listed in the message resource file as 
>> error.(whatever) or PropertyName.(whatever) but Struts is prepending 
>> locale information so that it looks for a resource named, for example, 
>> en_US.error.required instead of error.required. If I don't want to use 
>> i18n right now, is there any way to prevent the locale name from being 
>> prepended?
> 
> 
> That's a fall-back position, where the locale on the server doesn't
> match the browser. I've played around with I18N and never had any real
> problems. I hate to do this to you again, but offer another link to
> an article in my Struts series:
> <http://www.sudsy.net/technology/struts-messageresources.html>
> If the default locale on the server side matches what is presented by
> the browser then nothing will be prepended.
> Let us know how things work out!

Postscript: I got to thinking about this after my reply as there was a
nagging memory about LC_ environment variables. If you're running some
variant of *NIX then there's probably a man page for setlocale(3) which
discusses some of these issues.
If everything is "in sync" then you shouldn't encounter problems... ;-)





==========================================================================
TOPIC: How to render JTable headers as icons?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/89bc5d9dd7a1c2a5
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 7:41 pm
From: BettyV <[EMAIL PROTECTED]> 

Hi All,

I'm trying to use a TableCellRenderer to render text and icons in my column 
headers.

I setup a vector of strings and ImageIcons for my JTable constructor.
When my TableCellRenderer goes to render them, they are all instanceof 
String whether they were originally ImageIcons, or Strings.

Do I have to setup different renderers for each column?

Thanks,

-Betty





==========================================================================
TOPIC: Client Server socket behavior on XP different for 127.0.0.1
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2c44a25c74b9f7e2
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 8:14 pm
From: [EMAIL PROTECTED] (Tim) 

Steve Horsley <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Any data sensitivity is due entirely to your code - not the TCP stack.
> 
> Firstly, you are probably using different character set conversions 
> between the sender and the receiver, because DataOutputStream.writeBytes()
> just takes the lower 8 bits of the character (effectively using ISO8859-1
> encoding), but new InputStreamReader(InputStream) creats a Reader that uses
> the platform default characterset encoding. So you cannot at the moment
> be sure that the characters you send are the characters you receive. 
> It may be that your (char)14 is being converted to a questionmark.
> 
> Secondly, beware that TCP does not respect message boundaries - it can 
> split or concatenate chunks of data that are sent in separate write()
> calls. This splitting and concatenating is affected by network 
> timing, so may behave differently locally to the same machine than
> over a network. If you assume that a read() will always get exactly
> what one write() sent, you will eventually go wrong.
> You seem to be using explicit message boundaries here 
> (using '\n', '\r' or "\r\n" as the separator), but bear this
> in mind for the future.
> 
> Thirdly, if you use a buffered writer, remember to call flush() at
> the end.
> 
> I don't know why you would get an exception - there is nothing in
> the code you posted that ever closes the connection.
> 
> I don't know why using the loopback address should change behaviour.
> 
> Steve

Thanks for the response, here is a little more info and more questions
:)

The error message/traceback from the server log file is as follows:
ERROR::Mon Aug 30 10:33:53 2004::thread=Thread-6::SendThread.run():0
to null::java.net.SocketException: Software caused connection abort:
socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:105)
at java.io.DataOutputStream.writeBytes(DataOutputStream.java:256)
at SendThread.run(SendThread.java:24)
at java.lang.Thread.run(Thread.java:536)

Is it possible that (char)14 would really come through as something
other than 14 when treated as a number?  How could using 127.0.0.1 vs
real IP affect the char set used?  Any advice on how to specify char
set in both client and server to correct this issue?

I do not think network latency is a factor, as the linux machines the
server has run on have been in Texas and California with clients
connecting from as far away as Lithuania.  This issue only happens on
XP.  The server gets the same exception it would get for a client
machine being unplugged from the network.  And the client gets the
same error it would get if the server machine just went away.  The
really odd part is that some of the messages get through.  Users can
login, or create a new account, but once the password has been
entered/verified, the client gets no more messages.  This points to
something in the code, but I am having trouble seeing what it is.

The complete source for client and server is available here:
http://prdownloads.sourceforge.net/duskrpg/sourceFiles.zip?download

Are you saying that
stmOut.writeBytes(""+(char)3+"client message\n");
could get split up into multiple writes?  How would stmIn.readLine()
react to that?  I am assuming it waits for the \n.

Thanks again for the help!
Tim




==========================================================================
TOPIC: Would like a preprocessor.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f8d589c27ece424e
==========================================================================

== 1 of 4 ==
Date:   Wed,   Sep 1 2004 9:02 pm
From: Paul Lutus <[EMAIL PROTECTED]> 

Christopher Barber wrote:

/ ...

>> So what, indeed. Read the articles I posted again. These devices
>> undermine structured programming.
> 
> I did.  The articles do not explain why labeled break or continue are
> bad.

They do exactly that. It created unclear code that undermines the most basic
ides of structured programming and produces code that is more difficult to
debug, modify, or understand.

> Perhaps you can offer a concrete example.

The articles do this also, very clearly.

/ ...

> So far, your side of the argument ...

So somehow the bedrock principles of structured programming have become my
side of an argument? How post-modern.

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




== 2 of 4 ==
Date:   Wed,   Sep 1 2004 9:10 pm
From: Paul Lutus <[EMAIL PROTECTED]> 

Christopher Barber wrote:

/ ...

>> Did you read what I said? Did you try to find out whether it is so? By
>> definition, an efficient compiler will create an optimal object file
>> regardless of the legal source syntax required to create it.
> 
> But the compiler still cannot ignore the real semantic differences between
> try/throw and break/continue.

That would produce different algorithms, so you in fact did not read what I
said.

You are missing a very fundamental point.

1. The only way to justify goto, break, continue, et al.. is to show that
these constructs create the same logic, the same algorithm, as the more
structured alternatives. If, on the other hand, these methods changed the
basic algorithm, rather than merely the style of the source file, they
would be immediately disallowed, because the point -- design of a specific
algorithm with a specific outcome -- would be undermined.

2. Given all of (1) above, and given that the algorithm is the same in all
syntactically acceptable styles of programming it, an optimal compiler will
produce the same object code file for all the variations.

> The designers of Java intended try/throw to 
> be used for "exceptional" conditions, not regular control flow, and most
> compiler
> writers only try to optimize for the case in which no exception is thrown.
>  I think if you actually do the measurement on this "efficient compiler"
> you speak of, you will almost certianly find that there is indeed a
> performance difference.

Not for an optimally efficient compiler, unless two different algorithms
were intended. Surely you see this -- for each algorithm, there is ONE
optimal object file, just as there is ONE optimal outcome for each
Traveling Salesman problem.

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




== 3 of 4 ==
Date:   Thurs,   Sep 2 2004 12:40 am
From: [EMAIL PROTECTED] (Malcolm Dew-Jones) 

Paul Lutus ([EMAIL PROTECTED]) wrote:

: Not for an optimally efficient compiler, unless two different algorithms
: were intended. Surely you see this -- for each algorithm, there is ONE
: optimal object file, 

Ignoring the fact that there is more than one meaning for "optimal", I
don't see how you can assert that there is only one possible object file
that is optimal.  How can you be sure that there are not two possible
arrangements of low level intructions that both result in the same high
level result, and that both are not optimal in the same way, such as the
size of the code or the time required for the code to process identical
inputs?

The simple re-ordering of some assignments to variables that are not used
until some undeterminable later time sounds like the sort of thing that
would produce different object files that provide the same high level
result and which would, in at least some examples, contain code that is
identical in every way except for the reordering of some instructions.  
(I am of course talking about a compiler re-ordering the code.)


: just as there is ONE optimal outcome for each : Traveling Salesman
problem.

I don't see that either.  Let's travel through the following net.


                                Town two.
        Town one.                                       Town four.
                                Town three.


I think that    Town one.=>Town two.=>Town three.=>Town four.
and             Town one.=>Town three.=>Town two.=>Town four.

are both optimum routes.




== 4 of 4 ==
Date:   Thurs,   Sep 2 2004 12:16 am
From: Paul Lutus <[EMAIL PROTECTED]> 

Malcolm Dew-Jones wrote:

> Paul Lutus ([EMAIL PROTECTED]) wrote:
> 
> : Not for an optimally efficient compiler, unless two different algorithms
> : were intended. Surely you see this -- for each algorithm, there is ONE
> : optimal object file,
> 
> Ignoring the fact that there is more than one meaning for "optimal",

No, there is just one in this context.

> I 
> don't see how you can assert that there is only one possible object file
> that is optimal.

That is because you don't know the meaning of optimal. There is only one
optimal object file for a given algorithm.

> How can you be sure that there are not two possible 
> arrangements of low level intructions that both result in the same high
> level result, and that both are not optimal in the same way, such as the
> size of the code or the time required for the code to process identical
> inputs?

Study the classic Traveling Salesman and similar problems, and note that the
problem is one of producing the same algorithm using two or more syntax
variations in a source file. Trivial reorderings aside, either the result
is the same or the compiler is not optimal.

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





==========================================================================
TOPIC: newbie servlet help
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50ef5e726a3bf788
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 9:05 pm
From: [EMAIL PROTECTED] (sparrow) 

Hi 

I cant compile my servlets, I think I have somthing missing ( :) ), 
I'm geting this error when I try to compile a servlet (command line
javac HelloWorld.java is this right ?)

C:\Program Files\lws-3.0.3\webapps\hall\HelloWorld.java:4: package
javax.servlet does not exist
import javax.servlet.*;

however compiling a test class (none servelet) gives me this error 

C:\j2sdk1.4.2_04\java\net\URI.java:2572: warning: as of release 1.4,
assert is a keyword, and may not be used as an identifier
            assert false; 

can anyone help ?
Thanks 
Simon




==========================================================================
TOPIC: Applet steals focus...
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/59ad54d25b88280f
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 9:11 pm
From: Andrew Thompson <[EMAIL PROTECTED]> 

> Some time ago I noticed an irritating quirk in
> applets, they tend to 'steal the focus' of a web
> page and prevent scrolling using the keyboard.

Some time after that, I mentioned it 
and followed it up in the thread of 
this title..  That was January.

I may finally have found a fix!
<http://www.physci.org/test/focus/index6.jsp> *

You can test to see whether your browser/OS/VM 
combination is susceptible, here..
<http://www.physci.org/test/focus/>

* If the applet takes longer than 5
second to load, this simple fix will not
be effective.  

If that happens, please refresh the page.  
As soon as I can confirm this works in 
principle, I will work it into a more 
robust form with the help of the 
Javascript folks..  ;-)

Hoping for some positive results.

-- 
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: Who can resist a compilable example? - JComboBox
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a964462dca846012
==========================================================================

== 1 of 2 ==
Date:   Wed,   Sep 1 2004 10:14 pm
From: "Mike Schilling" <[EMAIL PROTECTED]> 

Me!





== 2 of 2 ==
Date:   Wed,   Sep 1 2004 10:35 pm
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Thu, 02 Sep 2004 05:14:52 GMT, Mike Schilling wrote:

> Me!

..Are you working your way up to, 'I! Me! Mine!'? 

You're almost there, just two words to go.  
Come on, ..you can do it.    ;-)

-- 
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: sprintf
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/488e725956316480
==========================================================================

== 1 of 3 ==
Date:   Wed,   Sep 1 2004 11:40 pm
From: shea martin <[EMAIL PROTECTED]> 

I know all about the bad things that sprintf in C/C++ can cause. My 
question is, is there a way in java to achieve similar results?

i.e,

sprintf(str, "%10s: %.5f\n", var, value);

I could probably use NumberFormat for the %.5f, but I didn't see 
anything in API's for the %10s. or a %-10s.

Thanks,

~S



== 2 of 3 ==
Date:   Thurs,   Sep 2 2004 12:11 am
From: Paul Lutus <[EMAIL PROTECTED]> 

shea martin wrote:

> I know all about the bad things that sprintf in C/C++ can cause. My
> question is, is there a way in java to achieve similar results?

Yes, several.

> 
> i.e,
> 
> sprintf(str, "%10s: %.5f\n", var, value);
> 
> I could probably use NumberFormat for the %.5f, but I didn't see
> anything in API's for the %10s. or a %-10s.

Simple justified strings? Why not pad a StringBuffer with spaces to achieve
the results you want?

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




== 3 of 3 ==
Date:   Thurs,   Sep 2 2004 12:27 am
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

shea martin <[EMAIL PROTECTED]> writes:

> I know all about the bad things that sprintf in C/C++ can cause. My
> question is, is there a way in java to achieve similar results?

Yes, if you use 1.5:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html




==========================================================================
TOPIC: WANTED: SOFTWARE INVENTIONS
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/31f204232b3af08
==========================================================================

== 1 of 1 ==
Date:   Wed,   Sep 1 2004 11:47 pm
From: Paul Lutus <[EMAIL PROTECTED]> 

Marcello do Guzman wrote:

> I will be making my first of several mid-month visits to several
> investors and venture capital firms beginning September.

Here is the latest stunt this parasite has gotten himself involved in
(combine the next two lines in your browser's address bar to see the search
result):

http://groups.google.com/groups?safe=images&ie=UTF-8
&[EMAIL PROTECTED]&as_scoring=d&lr=&hl=en

(click the first link in the resulting list)

A quote:

"Customer X buys my application.  He installs the application on his
computer and opens the workbook. This sends an email to me with the
message.  'User X opened TestMarket.xls'"

"This is a sneaky way for me to know who is using my application. Is it
also possible to tell OUTLOOK and/or OUTLOOK EXPRESS not to save a
copy of the sent email?"

This is absolutely unbelievable. Apart from being a felony if the purchaser
is not made aware of the "feature", we can see the regard this fraud has
for what people naively think of as civil rights.

It has become clear that this person is simply mental. There's no other word
for his behavior.

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





==========================================================================
TOPIC: Does Sun's Windows JVM catch Win32 Structured Exceptions?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/210d1a596cd7c8ff
==========================================================================

== 1 of 2 ==
Date:   Thurs,   Sep 2 2004 12:45 am
From: [EMAIL PROTECTED] (Barney) 

Hi

I have a java program running on a windows platform which makes calls
to an external product (dll, .NET) through JNI.

In most cases where an exception is generated in the external code,
the JVM catches it and exits with a mesage "an exception has occurred
in native code outside the VM", and an hs_err_pid file is created.

However, recently I have had cases where the VM exits abruptly, with
no error message and no hs_err_pid file.

After such a crash, by typing "echo %ERRORLEVEL" at the windows
command prompt, the code -529697949 is reported. In hex, this is
0xE06D7363, which from what I have read on the web indicates that the
exception was generated within C++ code when a Win32 Structured
Exception occured.

So it is likely that the exception is occuring somewhere external dll.
The java program's logs lend some support to this theory, but not
conclusive support.

It is possible that when the exception occurs, a C++ abort() is being
called somewhere in the dll, or a dll underneath it.

Another possibility that the exception is being thrown back to the
JVM, but not handled here, causing the abrupt crash. Does Sun's
Windows JVM catch Win32 Structured Exceptions?

Ta,

Barney



== 2 of 2 ==
Date:   Thurs,   Sep 2 2004 1:00 am
From: Gordon Beaton <[EMAIL PROTECTED]> 

On 2 Sep 2004 00:45:44 -0700, Barney wrote:
> I have a java program running on a windows platform which makes
> calls to an external product (dll, .NET) through JNI.
> 
> In most cases where an exception is generated in the external code,
> the JVM catches it and exits with a mesage "an exception has
> occurred in native code outside the VM", and an hs_err_pid file is
> created.
> 
> However, recently I have had cases where the VM exits abruptly, with
> no error message and no hs_err_pid file.
>
> After such a crash, by typing "echo %ERRORLEVEL" at the windows
> command prompt, the code -529697949 is reported. In hex, this is
> 0xE06D7363, which from what I have read on the web indicates that
> the exception was generated within C++ code when a Win32 Structured
> Exception occured.

Most likely these are not exceptions invoked explicitely by the native
code, rather they are caused by errors in the code and caught by the
operating system, which then kills the process.

Typically, attempting to read or write memory that you had no business
accessing will cause the JVM to crash in the manner you describe. Look
for things like sloppy use of pointers, uninitialized variables, etc.

/gordon

-- 
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e




==========================================================================
TOPIC: Self-Mutation with Strategy Object
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7667c4e1519c515
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Sep 2 2004 12:49 am
From: Daniel Bonniot <[EMAIL PROTECTED]> 

> Or is this perfectly legal, because the collector will not collect an
> object which is still executing code?

Correct.

More precisely, an object is not executing code. The method is in the class, 
and exists independently of instances of the class. The object is a parameter 
(this) of the method. This means threre is a link to the instance, and 
therefore the instance cannot be garbage collected before the end of the method.

Daniel

The Nice programming language: http://nice.sf.net




==========================================================================
TOPIC: aspectj ant import not found
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e213e5fed0c81781
==========================================================================

== 1 of 1 ==
Date:   Thurs,   Sep 2 2004 1:28 am
From: [EMAIL PROTECTED] (tmaus) 

hi there .. have a small problem with ant - aspectj generation..
aspectj is telling me that it is not able to import libraries..

my aspect looks like:

import org.aspectj.lang.*;
import foo.bar.Home;

public aspect LoggerAspect {
..
..

my class looks like:

package foo.bar;

public class Home  {
..
..


the foo.bar package is available as source as well as a compiled directory. 

my build.xml snipplet looks like:
<path id="build.dir.classes">
 <pathelement location="${build.cls.dir}"/> 
</path>
                
<iajc   destdir="${build.aspect.dir}"  
                verbose="on" 
                aspectpath="${build.jar.dir}/aspects.jar"
                sourceroots="${src.dir}/java"
                incremental="true">                                                    
 
                        
        <classpath>
                <path refid="project.class.path"/>
                <path refid="build.dir.classes"/>
        </classpath>
</iajc>
..
..
the build.cls.dir contains my precompiled sources .. ( the foo.bar package )
the build.jar.dir contains my prcompiled aspects
the build.aspect.dir will contain the weaved binaries
project.class.path contains all project related libraries .. 

the aspectj compiler is telling me constantly that it cannot find the import 
foo.bar

any idea ???
help would be appreciated ..



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

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/prefs

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 --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/BCfwlB/TM
--------------------------------------------------------------------~-> 

 
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