comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * J2EE Security - Allow if user is in ALL roles rather than ANY role? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/98b25bc6c1b7c8d2 * Is instanceof dirty? - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/395347a70489adef * who uses algorithms learned in cs studies? - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf * Execute problem with JCreator - 4 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b864ab013f6b9085 * Simple question: manifest.mf - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/110ae3b5be82f131 * Making the switch in html page reader from header info to gzip main content - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/784c97b0dd5bc696 * swt ole - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ce8281a1fe92cb9b * JNI , shared stubs, CFunction (not CFunc) ? - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7e1c6074e9e71a98 * Java client connected to non-Java server problems - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9dcb548fa77a4b46 * optimizeit: how to workaround/minimize wrong cput time in Object.wait() - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/567c06e241a81e28 * jar question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e00c9cb51a3d4eea * Regular Expression in Python - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50cba468c291c4d2 * How to tell if a java application was invoked with 'java' or 'javaw' - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e4cc744d7674421 * How to translate Japanese String into UTF-32 encoded using Java APIs ? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5c01f1e464ef13e3 * Problem building jdk 1.3 from source for Windows - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127339514e54c614 * Thread-question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa * What is the best way to exit a Runnable thread immediately? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/934dba84dd994004 * Sockets and TCP Data Segments - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af31f913a137c3ea * returning a subclass through an interface - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4 * class design need help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8f96c289e7ec780d * call perl programm from java - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/46e3606311661fde * How to send an email with an attachment? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/154f0f65b6851d8b ========================================================================== TOPIC: J2EE Security - Allow if user is in ALL roles rather than ANY role? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/98b25bc6c1b7c8d2 ========================================================================== == 1 of 2 == Date: Wed, Nov 10 2004 4:11 am From: [EMAIL PROTECTED] (David) I am using J2EE security to restrict what roles are allowed to access certain URLs. ie 'Managers' and 'Buyer' are allowed to access '/viewdetails' but only 'Managers' are allowed to access '/delete' details. This is simple to acheive via the web.xml, but in effect what it is saying for '/viewdetails' is 'allow access if user is in EITHER of the roles.' ...what I need to be able to do (for a different more complex app) is restrict access to only people who are in BOTH roles. Is this possible? If so how? ...I thought it would be a simple case of including two security constraints, both for the same URI, but one including 'Managers' and the other including 'Buyers' and that a user would have to pass both security constraints to be allowed access - But this was still treated as an Either/Or. Does anyone know how to restrict access in this way? Thanks for any help! David Bevan http://www.davidbevan.co.uk == 2 of 2 == Date: Wed, Nov 10 2004 4:39 am From: "Andy Flowers" <[EMAIL PROTECTED]> Perhaps you could have a new role, ManagerBuyer and use that ? It may increase your admin overhead though. "David" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am using J2EE security to restrict what roles are allowed to access > certain URLs. ie 'Managers' and 'Buyer' are allowed to access > '/viewdetails' but only 'Managers' are allowed to access '/delete' > details. > > This is simple to acheive via the web.xml, but in effect what it is > saying for '/viewdetails' is 'allow access if user is in EITHER of the > roles.' > > ...what I need to be able to do (for a different more complex app) is > restrict access to only people who are in BOTH roles. > > Is this possible? > > If so how? > > ...I thought it would be a simple case of including two security > constraints, both for the same URI, but one including 'Managers' and > the other including 'Buyers' and that a user would have to pass both > security constraints to be allowed access - But this was still treated > as an Either/Or. > > Does anyone know how to restrict access in this way? > > > Thanks for any help! > > David Bevan > > http://www.davidbevan.co.uk ========================================================================== TOPIC: Is instanceof dirty? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/395347a70489adef ========================================================================== == 1 of 4 == Date: Wed, Nov 10 2004 4:11 am From: "Stefan Schulz" <[EMAIL PROTECTED]> On Wed, 10 Nov 2004 11:07:16 -0000, Chris Uppal <[EMAIL PROTECTED]> wrote: > John C. Bollinger wrote: > >> The one place where I find myself frequently using instanceof in Java is >> in equals() methods, > [...] > Actually, I /think/[*] I prefer to express the class-test in equals() as: > > this.getClass() == anObject.getClass() > > rather than hardwiring a reference to "my" class into the code (and that > also > avoids the potential problem, or at least ambiguity, with subclasses). > But it > comes down to pretty-much the same thing. > > ([*] I can't remember ever implementing equals() in Java, which may be > significant in itself -- or maybe I'm just in denial ;-) This will fail if you get an Object of a subclass of your own... one you could compare (and which would be an instanceof your class= -- Whom the gods wish to destroy they first call promising. == 2 of 4 == Date: Wed, Nov 10 2004 5:54 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Chris Uppal wrote: > John C. Bollinger wrote: > > >>The one place where I find myself frequently using instanceof in Java is >>in equals() methods, > But equals() is such a very odd method. That's to say, the concept of > "equality" as used in programming is so very odd -- I don't think there's > anything specifically odd about the Java equals() method. > > It /looks/ innocous enough, but it's really very strange. [...] Agreed. Unfortunately, there is no getting around it. It is much too deeply ingrained in the language and class libraries. >>Do you have a preferred idiom to suggest? > > > Not really. > > Actually, I /think/[*] I prefer to express the class-test in equals() as: > > this.getClass() == anObject.getClass() > > rather than hardwiring a reference to "my" class into the code (and that also > avoids the potential problem, or at least ambiguity, with subclasses). But it > comes down to pretty-much the same thing. I tend to fall on the other side of the question of equality with instances of subclasses, so instanceof usually expresses my intent accurately. There is a reflective solution that would mirror instanceof perfectly, but I really don't see the point of doing that in such a case. > There's an idiom (widely used in the Smalltalk class hierarchy, for instance) > which is slightly more flexible than the class-test. I'm not sure I like it > myself -- it doesn't really cure the equals() problems, although it does help. > The idiom is that an object has a 'species' which is normally its own class, > but may be some other class (usually a superclass), and the equals() method > can > compare species rather than classes: > > return this.getSpecies() == anObject.getSpecies() > && // ... rest of comparison > > The idea is that it is testing /type/ not class, and doing so idiomatically by > nominating (slightly arbitrarily) a specific class which is then taken to > exemplify the type shared by a whole category of concrete classes. I like that. It perfectly expresses the answer to the relevant question, including providing a clean solution for the subclass issue. > It's not something you could use directly in Java, since that would require > getSpecies() to be defined by java.lang.Object, though you could use > instanceof > to emulate it. Which is more or less where we started, I think. At least, substituting an instanceof test for the equality test in your example results in the Java idiom that I normally use in these cases. > An elegant variant would be to use an interface as the > nominated (paradigmatic) class. Come to think of it, maybe that's how you > /are/ using instanceof in your applications ? I wish I could lay claim to such elegance, but sadly, no, my typical usage is more mundane. Thanks for the comments. Cheers, John Bollinger [EMAIL PROTECTED] == 3 of 4 == Date: Wed, Nov 10 2004 5:41 am From: "Chris Uppal" <[EMAIL PROTECTED]> Stefan Schulz wrote: > > this.getClass() == anObject.getClass() > This will fail if you get an Object of a subclass of your own... one you > could > compare (and which would be an instanceof your class= Well, that's my point isn't it -- or part of my point anyway ? Whether, and why, an object could be considered to be equal() to an instance of a subclass of its own class is not well-defined. Maybe it should, maybe it shouldn't. It's probably context dependent. It's certainly application dependent. But I think it's worse than that: Consider two classes Super and Sub, where Sub extends Super. Consider two objects aSuper and aSub. Now if (as may be reasonable) you want it to be true that: aSuper.equals(aSub) then it should also be true that: aSub.equals(aSuper) In which case the 'instanceof' test in Sub.equals() must be allowing instances of its superclass. (This could be thought of as an application of the 'species' pattern I mentioned.) In such cases we are essentially saying that not only can Subs be substituted for Supers (in the sense of the Liskov Substitution Principle), but also that Supers can be substituted for Supers -- that they are interchangable (modulo polymorphically differing behaviour). Class hierarchies that have that property are certainly not ill-formed (I'd argue that they are exceptionally well-formed), but they are not the general rule. Normally substitutability only runs in one direction. So we see another oddness (in OO terms) about equals(). It must either (in the general case) fail to be symmetric (an abomination) or it must fail to be compatible with the LSP. Continuing a thought from my earlier post. Considering the shear oddness of equals(), and the extaordinary wide contract that it is supposed to fulfill, it's not surprising that it is forced to employ "unusual" techniques like reflection. -- chris == 4 of 4 == Date: Wed, Nov 10 2004 7:09 am From: Andrea Desole <[EMAIL PROTECTED]> Stefan Schulz wrote: > On Wed, 10 Nov 2004 11:07:16 -0000, Chris Uppal > <[EMAIL PROTECTED]> wrote: > >> John C. Bollinger wrote: >> >>> The one place where I find myself frequently using instanceof in Java is >>> in equals() methods, >> >> [...] >> Actually, I /think/[*] I prefer to express the class-test in equals() as: >> >> this.getClass() == anObject.getClass() >> >> rather than hardwiring a reference to "my" class into the code (and >> that also >> avoids the potential problem, or at least ambiguity, with >> subclasses). But it >> comes down to pretty-much the same thing. >> >> ([*] I can't remember ever implementing equals() in Java, which may be >> significant in itself -- or maybe I'm just in denial ;-) > > > This will fail if you get an Object of a subclass of your own... one > you could > compare (and which would be an instanceof your class= > I think Chris is right. The equals method has to be symmetric, according to the documentation. This means that superclass.equals(subclass) must return false ========================================================================== TOPIC: who uses algorithms learned in cs studies? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf ========================================================================== == 1 of 4 == Date: Wed, Nov 10 2004 4:22 am From: Michael Borgwardt <[EMAIL PROTECTED]> Chris Uppal wrote: > Thinking in algorithms is completely central to programming. So much so that > you often don't realise that you are doing it at all. I'd even say it's both central and special to computer science in general. I was once asked by a math professor what I liked best about his lecture on group theory and answered that it was the part where he introduced an algorithm to enumerate coset classes. As a CS student, this was easy to grasp for me and came almost naturally, while I really struggled to understand most of the rest (very theoretical math). He was quite amused by this and said that this was exactly the part where the math students had the biggest problems. == 2 of 4 == Date: Wed, Nov 10 2004 4:55 am From: Ian Heggie <[EMAIL PROTECTED]> bebop o'saurus wrote: > hi everybody, > > i am wondering: > > 1) does anybody here use (in their everyday java coding gigs) any of the > algorithms they were taught in their cs classes? Yes ... > 2) what algorithms learned in your cs studies have you used recently? As another poster said, most algorithms have implementations already around. The ones that aren't are either to simple to require a helper class (eg linear search through an array), or are more correctly called patterns (eg language compilers, interpreters etc) - back in 1979-81 when I went through uni, the terminology wasnt there, but the concepts where, if you where prepared to think out of the box. > 3) if you haven't used any cs studies algorithms in your real-world jobs, > why not? > > 4) if you do use any cs algorithms in your real-world jobs, how often do you > use them? I frequently use the pattern behind language compilers and interpreters frequently. Where ever there is repetition in intent in code, I look for either refactoring the code to separate it out into a separate class, or otherwise developing a higher level command language. An example of writing an interpreter was taking documents written about how to manually test a specific product(eg click "details" link, type "xyz" into name field, press [Add] button, verify "record was added" is visible, repeat test for each row in such an such table), and making an interpreter that would perform those tests automatically. The principle benefits where communication with non programmers, increased speed of writing tests and the ability for non programmers to have a major role in the writing of the tests. A slightly more obscure example is writing a compiler that takes a database schema and produces Java, html and javascript code. Which when compiled for the web server and interpreted on the client side browser provide standard table maintenance functionality. The compiler differs from typical compilers because its input is declarative rather than procedural, and the output is for multiple environments on different machines, but that's just letting your thinking get out of the box. Combined with an interest in learning and thinking out of the box, the basic mental pattern that I use, is write it manually once, write it again a second time ... but the third time you have to do something, tell the computer to do itself! > thanks in advance for your replies. Regards ian == 3 of 4 == Date: Wed, Nov 10 2004 4:57 am From: Ian Heggie <[EMAIL PROTECTED]> bebop o'saurus wrote: > hi everybody, > > i am wondering: > > 1) does anybody here use (in their everyday java coding gigs) any of the > algorithms they were taught in their cs classes? Yes ... > 2) what algorithms learned in your cs studies have you used recently? As another poster said, most algorithms have implementations already around. The ones that aren't are either to simple to require a helper class (eg linear search through an array), or are more correctly called patterns (eg language compilers, interpreters etc) - back in 1979-81 when I went through uni, the terminology wasnt there, but the concepts where, if you where prepared to think out of the box. > 3) if you haven't used any cs studies algorithms in your real-world jobs, > why not? > > 4) if you do use any cs algorithms in your real-world jobs, how often do you > use them? I frequently use the pattern behind language compilers and interpreters frequently. Where ever there is repetition in intent in code, I look for either refactoring the code to separate it out into a separate class, or otherwise developing a higher level command language. An example of writing an interpreter was taking documents written about how to manually test a specific product(eg click "details" link, type "xyz" into name field, press [Add] button, verify "record was added" is visible, repeat test for each row in such an such table), and making an interpreter that would perform those tests automatically. The principle benefits where communication with non programmers, increased speed of writing tests and the ability for non programmers to have a major role in the writing of the tests. A slightly more obscure example is writing a compiler that takes a database schema and produces Java, html and javascript code. Which when compiled for the web server and interpreted on the client side browser provide standard table maintenance functionality. The compiler differs from typical compilers because its input is declarative rather than procedural, and the output is for multiple environments on different machines, but that's just letting your thinking get out of the box. Combined with an interest in learning and thinking out of the box, the basic mental pattern that I use, is write it manually once, write it again a second time ... but the third time you have to do something, tell the computer to do itself! > thanks in advance for your replies. Regards ian == 4 of 4 == Date: Wed, Nov 10 2004 4:56 am From: Ian Heggie <[EMAIL PROTECTED]> bebop o'saurus wrote: > hi everybody, > > i am wondering: > > 1) does anybody here use (in their everyday java coding gigs) any of the > algorithms they were taught in their cs classes? Yes ... > 2) what algorithms learned in your cs studies have you used recently? As another poster said, most algorithms have implementations already around. The ones that aren't are either to simple to require a helper class (eg linear search through an array), or are more correctly called patterns (eg language compilers, interpreters etc) - back in 1979-81 when I went through uni, the terminology wasnt there, but the concepts where, if you where prepared to think out of the box. > 3) if you haven't used any cs studies algorithms in your real-world jobs, > why not? > > 4) if you do use any cs algorithms in your real-world jobs, how often do you > use them? I frequently use the pattern behind language compilers and interpreters frequently. Where ever there is repetition in intent in code, I look for either refactoring the code to separate it out into a separate class, or otherwise developing a higher level command language. An example of writing an interpreter was taking documents written about how to manually test a specific product(eg click "details" link, type "xyz" into name field, press [Add] button, verify "record was added" is visible, repeat test for each row in such an such table), and making an interpreter that would perform those tests automatically. The principle benefits where communication with non programmers, increased speed of writing tests and the ability for non programmers to have a major role in the writing of the tests. A slightly more obscure example is writing a compiler that takes a database schema and produces Java, html and javascript code. Which when compiled for the web server and interpreted on the client side browser provide standard table maintenance functionality. The compiler differs from typical compilers because its input is declarative rather than procedural, and the output is for multiple environments on different machines, but that's just letting your thinking get out of the box. Combined with an interest in learning and thinking out of the box, the basic mental pattern that I use, is write it manually once, write it again a second time ... but the third time you have to do something, tell the computer to do itself! > thanks in advance for your replies. Regards ian ========================================================================== TOPIC: Execute problem with JCreator http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b864ab013f6b9085 ========================================================================== == 1 of 4 == Date: Wed, Nov 10 2004 4:23 am From: "Mark K" <[EMAIL PROTECTED]> well duh.. let me see.. hmmm ill take item 1 but if those that are trying to help offer the help you have.. i dont want it. Yes I do agree.. spoiled little rich kid! There are nice ways of offering help and then there is the way you offered.. Unless your going to truly help me out (without the BS statements) please dont! "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, 09 Nov 2004 18:21:58 GMT, Mark K wrote: > > > If you dont have an answer or can provide any help, please dont post! > > I have done this conversation too many times to do it again > for yet another 'screaming noob', I'm too busy at the moment. > So I'll ask you straight up. Are you more interested in .. > a) Learning Java? > b) P*ssing off those who are trying to help you? > > -- > Andrew Thompson > http://www.PhySci.org/codes/ Web & IT Help > http://www.PhySci.org/ Open-source software suite > http://www.1point1C.org/ Science & Technology > http://www.LensEscapes.com/ Images that escape the mundane == 2 of 4 == Date: Wed, Nov 10 2004 5:32 am From: Andrew Thompson <[EMAIL PROTECTED]> On Wed, 10 Nov 2004 12:23:13 GMT, Mark K wrote: Please refrain from top-posting Mark. I find it most confusing <http://www.physci.org/codes/javafaq.jsp#netiquette> >"Andrew Thompson" <[EMAIL PROTECTED]> wrote in message... >> ..Are you more interested in .. >> a) Learning Java? >> b) P*ssing off those who are trying to help you? ... > ..well duh.. let me see.. hmmm ill take item 1 It is a pity your desire to learn Java has not translated into a sound strategy to do achieve that. > ..but if those that are trying to help offer the help you have.. Which, for the record is here.. <http://groups.google.com/[EMAIL PROTECTED]> > ..i dont want it. Did you actually read it, or any of the links? I get no impression that you have. You have certainly not responded to any of my comments in a logical or useful way. > Yes I do agree.. spoiled little rich kid! > > There are nice ways of offering help and then there is the way you offered.. What was it about that post that upset you? > Unless your going to truly help me out (without the BS statements) please > dont! If you continue to display the attitudes and immaturity that you have thus far, you are not going to get very far with getting help from this group *or* c.l.j.help. Now wake up to yourself and stop wasting our bandwidth with your pathetic moaning about how 'the world done me wrong'. It does not wash with (just about) anyone here. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane == 3 of 4 == Date: Wed, Nov 10 2004 6:29 am From: "Mark K" <[EMAIL PROTECTED]> Andrew .. please dont respond to any of my posts. To anyone else I was able to execute it using java Test I have also posted the output in a previous post. That is all I got when I hit the execute button. Any further help would be greatly appreciated. Mark == 4 of 4 == Date: Wed, Nov 10 2004 6:35 am From: Andrew Thompson <[EMAIL PROTECTED]> On Wed, 10 Nov 2004 14:29:21 GMT, Mark K wrote: > Andrew .. please dont respond to any of my posts. Not practical, I will hadly remember you beyond tomorrow. I often don't look closely at 'From:' lines, in any case. You, on the other hand, have the pwoer to do what you keep requesting of me. ..Research 'Plonk'. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: Simple question: manifest.mf http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/110ae3b5be82f131 ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 4:33 am From: Andrea Desole <[EMAIL PROTECTED]> I couldn't spot it without the link. That was just a good team work :-) Andrew Thompson wrote: > On Wed, 10 Nov 2004 11:38:01 +0100, Andrea Desole wrote: > > >>Andrew Thompson wrote: >> >>>On Wed, 10 Nov 2004 10:53:00 +0100, ShadowMan wrote: >>> >>> >>>>How can I avoid a long Class-path line ? >>> >>><http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Manifest%20Specification> >>>This would indicate 'not'. It must be a single line. >> >>actually, on the same page I read this: >> >>No line may be longer than 72 bytes (not characters), in its >>UTF8-encoded form. If a value would make the initial line longer than >>this, it should be continued on extra lines (each starting with a single >>SPACE). > > > Well spotted! Thanks for the clarification. > ========================================================================== TOPIC: Making the switch in html page reader from header info to gzip main content http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/784c97b0dd5bc696 ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 12:29 am From: steven <[EMAIL PROTECTED]> Okay, you have this line in the code to begin with InputStream socketsInputStream = socket.getInputStream(); If you read off the html stream of a web page, and it utilizes gzip encoding for the main data it server in the html page, then how do you easily funnel the rest of the sockets data into : BufferedReader reader = new BufferedReader( new InputStreamReader( new GZIPInputStream( new FileInputStream( socketsInputStream ) ) ) ); when the socketsInputStream originally was fueling the BufferedReader d = new BufferedReader(new InputStreamReader(socketsInputStream),1); to get the header info from the html server that says. I gave it size 1 in hopes it would not peel off any more stream past the lone \r\n that separates the html header from the data. Problem is that the implementation of the InputStreamReader may use a buffer that is larger than 1, so some unspecified amount of the data after the header may have been lost from the sockets input stream. So , what is the easy way to read the header , then read the gziped data of the html page's stream. Reason I ask is that I get a : java.io.IOException: Not in GZIP format error when I try to switch the socketsInputStream to the gzipped enabled BufferedReader. Make sense? Thanks ========================================================================== TOPIC: swt ole http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ce8281a1fe92cb9b ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 5:15 am From: Thierry <[EMAIL PROTECTED]> Hi guys, I am new in SWT and I am looking for a GOOD tutorial. Does someone has one GOOD tutorial to show me ? I am more concentrated in OLE. Thanks, Th. ========================================================================== TOPIC: JNI , shared stubs, CFunction (not CFunc) ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7e1c6074e9e71a98 ========================================================================== == 1 of 3 == Date: Wed, Nov 10 2004 5:38 am From: rover <[EMAIL PROTECTED]> Hi, I've been reading about JNI and shared stubs at http://java.sun.com/docs/books/jni/html/jniTOC.html However, when i try to use the class "CFunction" (see 9.4.3 @ url) , my compiler (IntelliJ) says it cannot find the class. I did find a jnistb10.zip , containing CFunc, CMalloc, CPtr, and the C code for "disp.dll". However, this zip contains "CFunc" instead of "CFunction" ! This is fine for wrapping a simple C calling convention function like "atol" (this example works with CFunc) , but i want to wrap some "stdcall" win api functions. With CFunc i get an access violation, probally due to the fact its not a C but a stdcall function. So i've been searching for the new and improved classes, namely CFunction , but unfortunally i cannot find it anywhere. Strange how it seems to be part of the JVM since 1.2 , but just doesnt seem to be there. Anyone who can help me ? Thanks, Rover == 2 of 3 == Date: Wed, Nov 10 2004 6:41 am From: rover <[EMAIL PROTECTED]> rover wrote: > Hi, > > I've been reading about JNI and shared stubs at > > http://java.sun.com/docs/books/jni/html/jniTOC.html > > However, when i try to use the class "CFunction" (see 9.4.3 @ url) , my > compiler (IntelliJ) says it cannot find the class. > I did find a jnistb10.zip , containing CFunc, CMalloc, CPtr, and the C > code for "disp.dll". However, this zip contains "CFunc" instead of > "CFunction" ! This is fine for wrapping a simple C calling convention > function like "atol" (this example works with CFunc) , but i want to > wrap some "stdcall" win api functions. With CFunc i get an access > violation, probally due to the fact its not a C but a stdcall function. > So i've been searching for the new and improved classes, namely > CFunction , but unfortunally i cannot find it anywhere. Strange how it > seems to be part of the JVM since 1.2 , but just doesnt seem to be there. > > Anyone who can help me ? > > Thanks, > > Rover Found it :) At http://java.sun.com/docs/books/jni/ : "Download the example code in this book in ZIP or tar.gz formats" The zip contains what i was searching for :) == 3 of 3 == Date: Wed, Nov 10 2004 6:36 am From: "Chris Uppal" <[EMAIL PROTECTED]> rover wrote: > I've been reading about JNI and shared stubs at > > http://java.sun.com/docs/books/jni/html/jniTOC.html > > However, when i try to use the class "CFunction" (see 9.4.3 @ url) , my > compiler (IntelliJ) says it cannot find the class. That class, and the others, are not part of JNI, but are part of a software package developed by the author and described in his book. (And pretty cool too, I may add.) If you go up a couple of levels to: http://java.sun.com/docs/books/jni/ then you'll find a link to download the code for the examples from the book. That includes the source to the CFunction, etc, as well as the corresponding JNI source. I haven't tried it, but it looks as if it will handle stdcall functions, see the file: jniexamples/chap9/SharedStubs/dispatch_x86.c for example. -- chris ========================================================================== TOPIC: Java client connected to non-Java server problems http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9dcb548fa77a4b46 ========================================================================== == 1 of 2 == Date: Wed, Nov 10 2004 5:42 am From: [EMAIL PROTECTED] (FISH) [EMAIL PROTECTED] (Illusionistx) wrote in message news:<[EMAIL PROTECTED]>... > I'm trying to connect a java client application to a chat server i > wrote in vb. i know the server works, and i know the client works(when > used with a java server), but when i use the vb server and the java > client, the client doesn't get the data sent from the server. But then > when i send back from the client to the server, then what i sent from > the server shows up, so it's like the buffer isn't getting read or > flushed when i send from the server. What is the best approach i > should take on this? Firstly, be absolutely certain you know whether it's the client or the server at fault. It's very easy to assume a particular bit of software is blameless - you need an independent test. Telnet to the server and, as best you can, try to use it 'manually'. This will tell you whether the server is sending out data. If it is, the fault is likely in your Java client. If it isn't, the fault is probably in your VB server. Are the reading and writing parts running in separate threads? It sounds like your code isn't accepting/processing incoming messages until after it sends an outgoing message. (You haven't done something silly, like put both the accepting and sending code in an event handler tied to the SEND button on your client UI... have you? ;-) -FISH- ><> == 2 of 2 == Date: Wed, Nov 10 2004 6:10 am From: "Chris Uppal" <[EMAIL PROTECTED]> FISH wrote: > Firstly, be absolutely certain you know whether it's the client or the > server at fault. It's very easy to assume a particular bit of software > is blameless - you need an independent test. Telnet to the server and > [...] This is very sound advice, but I'd suggest that rather than using Telnet, a network sniffer like ethereal www.ethereal.com/ would be better still. If you are transmitting data over network at all (and who isn't these days) then sooner or later you will have to learn to make at least simple use of tools like ethereal -- and once you have learned you'll wonder why you ever tried to do without them in the first place. -- chris ========================================================================== TOPIC: optimizeit: how to workaround/minimize wrong cput time in Object.wait() http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/567c06e241a81e28 ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 5:35 am From: NOBODY <[EMAIL PROTECTED]> It is definitly an optimizeit limitation. OI 6 gives the same shit. Jprobe doesn't. The weird YourKitProfiler doesn't. I will try good old fashion sun's hprof today (just because this one is free... and may be more of a reference...) >Then are you satisfied with the throughput? No. And I'm just trying to apply the 80%-20% rule. Once optimized, I should see code in the hotspots, not wait()! I have never seen that before, ever, in 6 years. Modern pc's are probably too fast for optimizeit approach of profiling. Note that in instrumentation mode, OI gave me substackframes under wait ()! Like wait called my other methods! (probably those methods that ran between the 2 wait)... I want my money back! hehehe! > I did a small test where I increased overall wait time by sleeping > before the notify and wait didn't even show up in the profiler results > (with -Xrunhprof). Probably testing another profiler is best you can > do at the moment. You have to notify more, not less. You want to cause the waiting thread wait to exit, do a quick job and go back to wait, so that the OI profiler thinks no other method/line of code was running but thread was not blocked. > Since this seems to affect only one place in the code, did you > consider instrumenting the code with measurements of your own? You > could have a wait counter and a wait time counter and thus determine > average wait time. System.currentTimeMillis is only ms, not nanoseconds...! Allright, Thanks Robert. I will report a bug to borland... if at all possible... Have a good week. ========================================================================== TOPIC: jar question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e00c9cb51a3d4eea ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 6:02 am From: [EMAIL PROTECTED] (FISH) "hilz" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > Hi all: > > I am trying to create a library "myLib.jar" that includes three other jar > files: > > myLibA.jar > myLibB.jar > myLibC.jar AFAIK this isn't going to work. You may be interested to know, however, that the manifest supports a Class-Path entry, which is a whitespace separated list of other resources needed by your code. If, for example, you placed all the support jars into a subdirectory called 'lib', then you would use the following entry in your main application jar manifest: Class-Path: lib/myLibA.jar lib/myLibB.jar lib/myLibC.jar Which would allow your main jar file to be run via the -jar option (assuming the same command line switches as Sun's JRE). To distribute your work, supply a Zip or other suitable archive (NOT A JAR - unless it's one of these clever self extracting jars!) with the 'executable' jar file and the lib directory packed inside. -FISH- ><> ========================================================================== TOPIC: Regular Expression in Python http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50cba468c291c4d2 ========================================================================== == 1 of 2 == Date: Wed, Nov 10 2004 6:15 am From: [EMAIL PROTECTED] (newPeter) Hi, I am trying to figureout some data from python, pat = re.compile(r'^(.{3})(\d{1})\w|\s') pat.search(' 183 14 1 1282 0 2004-11-08/13:26:14.21').groups() it searches and matches the record rightly: output willbe: (' 183 ', '1') but if i am trying to search for one digit e.g, pat = re.compile(r'^(.{13})(\d{1})\w|\s') pat.search(' 183 14 1 1282 0 2004-11-08/13:26:14.21').groups() output is: (Nothing,Nothing) is there any restrction from Python or my code needs some correction? Thanks, SF. == 2 of 2 == Date: Wed, Nov 10 2004 6:57 am From: "Ann" <[EMAIL PROTECTED]> "newPeter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I am trying to figureout some data from python, > > pat = re.compile(r'^(.{3})(\d{1})\w|\s') > > pat.search(' 183 14 1 1282 0 2004-11-08/13:26:14.21').groups() > > it searches and matches the record rightly: output willbe: > (' 183 ', '1') > > but if i am trying to search for one digit e.g, > > pat = re.compile(r'^(.{13})(\d{1})\w|\s') > pat.search(' 183 14 1 1282 0 2004-11-08/13:26:14.21').groups() > > output is: (Nothing,Nothing) > > is there any restrction from Python or my code needs some correction? > Thanks, > SF. Do you need to escape your curly brackets? I don't understand the dot. ========================================================================== TOPIC: How to tell if a java application was invoked with 'java' or 'javaw' http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e4cc744d7674421 ========================================================================== == 1 of 2 == Date: Wed, Nov 10 2004 6:26 am From: [EMAIL PROTECTED] (Michael) Is it possible for a 'main' function to tell if java was invoked with 'java' or 'javaw'? Thanks, == 2 of 2 == Date: Wed, Nov 10 2004 6:32 am From: Andrew Thompson <[EMAIL PROTECTED]> On 10 Nov 2004 06:26:05 -0800, Michael wrote: > Is it possible for a 'main' function to tell if java was invoked with > 'java' or 'javaw'? Sure, feed it an argument. But what about if it's invoked by double clicking a Jar file, or by JWS? What if it is instantiated by an applet? What is the actual problem you are trying to solve here? What do you hope to achieve by knowing? -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: How to translate Japanese String into UTF-32 encoded using Java APIs ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5c01f1e464ef13e3 ========================================================================== == 1 of 3 == Date: Wed, Nov 10 2004 6:33 am From: [EMAIL PROTECTED] (Marat) Hello Andrew! It is really InsufficientOrangeException .. How did you know that ??? I suppose you are farmer with a huge experience in fruit collecting ;-) So I guess you do not even know what is UnsupportedEncodingException .. No comments ... Reposting is caused by timeout session , btw ... Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > On 9 Nov 2004 12:56:20 -0800, Marat wrote: > > > The following work arrounds throws exceptions : > > Is that an InsufficientStrawberriesException? No? > Well perhaps you had better be more precise. > <http://www.physci.org/codes/javafaq.jsp#exact> > > And, please do not repost your question, especially > after just 5 minutes. == 2 of 3 == Date: Wed, Nov 10 2004 6:40 am From: Michael Borgwardt <[EMAIL PROTECTED]> Marat wrote: > It is really InsufficientOrangeException .. How did you know that ??? > I suppose you are farmer with a huge experience in fruit collecting ;-) > So I guess you do not even know what is UnsupportedEncodingException .. The name alone says it all, doesn't it? The encoding UTF-32 is not supported by your JVM. That's no big surprise since it is not one of the required encodings and Java doesn't support characters outside of UCS-2 anyway. Why don't you use UTF-16? == 3 of 3 == Date: Wed, Nov 10 2004 7:00 am From: Andrew Thompson <[EMAIL PROTECTED]> On 10 Nov 2004 06:33:43 -0800, Marat wrote: > Hello Andrew! Hello Marat. Please don't top-post, I find it most confusing.. <http://www.physci.org/codes/javafaq.jsp#netiquette> > Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL > PROTECTED]>... >> On 9 Nov 2004 12:56:20 -0800, Marat wrote: >> >>> The following work arrounds throws exceptions : >> >> Is that an InsufficientStrawberriesException? No? >> Well perhaps you had better be more precise. >> <http://www.physci.org/codes/javafaq.jsp#exact> ... > It is really InsufficientOrangeException .. How did you know that ??? > I suppose you are farmer with a huge experience in fruit collecting ;-) No, merely a consumer with a sweet tooth. > So I guess .. Stop guessing, you're not especially good at it. >..you do not even know what is UnsupportedEncodingException .. It is an exception caused when you attempt to use an encoding which is not supported (such as "klingon"). Sun is a bit 'secretive' about the supported encodings, but a quick search led me here.. <http://java.sun.com/webservices/docs/1.2/tutorial/doc/Encodings.html#wp64107> and here <http://java.sun.com/j2se/1.5.0/docs/guide/intl/locale.doc.html#jfc-table> Hunt around, but as far as I could see, no metnion of UTF-32. > No comments ... ?? > Reposting is caused by timeout session timeout session? That's a new one on me. >.., btw ... ..good, good. No 'sorry about wasting the bandwidth' then? -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ========================================================================== TOPIC: Problem building jdk 1.3 from source for Windows http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127339514e54c614 ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 6:35 am From: "Ann" <[EMAIL PROTECTED]> "Ulas Ergin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Ann" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > > > > My view of compiling stuff for windows when a binary is available: > > Are you nuts? > > I completely agree with you Ann but unfortunately I have to. Well, good luck with it then. ========================================================================== TOPIC: Thread-question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 6:40 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Chris Uppal wrote: > Carl Howells wrote: > > >>Bad idea. On most modern JVMs, finalizers seriously mess up garbage >>collection. > > > I have to say that I find this implausible. Obviously finalisation adds > overhead to the GC operation, but that's because it's doing extra work -- > /useful/ extra work -- but it sounds as if you mean something more than that. > Do you have any references ? I haven't looked up references (yet) but my understanding is that Carl is correct, if perhaps overly emphatic. Based only on the API docs and JLS, one can argue that instances of classes that do not override finalize() can be collected without actually invoking Object.finalize(), as the VM can know that its Object.finalize() is specified to do nothing. More importantly, however, it is possible for a finalize() method to make the object it is invoked on reachable again (an odd state indeed: finalized and reachable), so after finalizing an object with a non-default finalizer, the GC must completely redo its reachability analysis for that object. Naturally, that also affects the reachability of objects to which the one in question holds references. The VM must also keep track of whether or not reachable objects have been finalized, because they are only ever finalized once (per specification). That probably doesn't add much overhead, but it may result in unexpected behavior when the second time an object becomes unreachable it is discarded without its finalizer being invoked. >>In fact, if the JVM can avoid it, it'll just *not* collect >>objects with finalizers. It's not a very good way to get code run. > > > It's perfectly at liberty not to collect anything. But again you seem to be > going beyond that and stating that it (they) will discriminate against objects > with finalisers. Again, this sounds implausible. Do you have a reference for > it ? That would be an implementation question, but I suspect that many Java GC implementations indeed do exactly as Carl describes. It really is a much bigger deal to collect an object with a non-default finalizer than to collect other objects. It might be a little too strong to say that Java's finalization mechanism is broken, but I have never personally run into any task to which it is suited. It is definitely a trap, because people -- especially those with experience in some other OO languages, such as C++ -- tend to make incorrect assumptions about how finalization works. It has been said here before and it will be repeated again: a Java finalizer is not at all the same thing as a C++ destructor. John Bollinger [EMAIL PROTECTED] ========================================================================== TOPIC: What is the best way to exit a Runnable thread immediately? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/934dba84dd994004 ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 6:50 am From: "Ann" <[EMAIL PROTECTED]> "Chris Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ken Adams wrote: > > Basically I implement the Runnable interface and in my run function I do > > have a while loop that checks a condition to quit, but what if my run > > function is long say calls a bunch of different methods. Do I have to wait > > till all the methods finish. I want to be able to quit anytime in the > > progress of these functions. I suppose I could check the condition between > > each method call but that doesn't seem like a very good choice. Any > > suggestions? > > Checking multiple times is about what you want to do, if you need to > check several times per loop iteration. > My understanding is that checking a flag is the best, but if there are latency problems you might see what happens if you use this: public void interrupt() {} which is in the Thread class. Then your thread must have a handler. ========================================================================== TOPIC: Sockets and TCP Data Segments http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/af31f913a137c3ea ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 6:52 am From: [EMAIL PROTECTED] (Pete Mainwaring) We are writing data to a socket and in most cases, a TCP segment is then passed down to the IP layer and a separate packet is sent across the network. However, occasionally we get two or three lots of data being sent in the same TCP segment, which the receiving station cannot handle. We have enabled TCP_NODELAY, but this hasn't resolved the problem. Is there a way of forcing each piece of data to be sent in its own packet? (By the way, I'm not a Java programmer - I'm the network administrator. I've been capturing the packets across the network because we have this problem, but the programmer can't see anything in the available commands when handlin sockets to set this). Thanks, Pete ========================================================================== TOPIC: returning a subclass through an interface http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4 ========================================================================== == 1 of 2 == Date: Wed, Nov 10 2004 6:58 am From: "xarax" <[EMAIL PROTECTED]> "Chris Uppal" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Andy Fish wrote: > > > I am writing an API call which returns an object of type X. In my code, I > > build an object which is of type Y - a subclass of X. > > > > I'm worried that if I return the object Y, the caller will be able to use > > reflection or a debugger to find out about the extra properties of Y. Is > > this concern valid or is there something inherent that stops him doing > > this? > > There's nothing much stopping it; if Y is public then the caller could even > just downcast the "X" into a Y. > > I'm curious as to why you want the extra protection ? It's not normally > something that you need. > > > > assuming my concern is valid, I need to make a "clone" of Y but for the > > clone to be a superclass (i.e. X). Is there any clever way of doing this? > > The class X only contains public immutable properties and has no methods > > so there is no need to deep copy. > > ?? Has no methods ?? > > Anyway, assuming that you don't mean that the way it sounds (and also assuming > that you have good reason to want give your "Y" more protection than the > language directly affords), what you could do is return an object that > /contains/ your Y, and implements the public methods of X by delagating them to > the Y. > > Of course, that would still be open to abuse -- there's no way of preventing > someone using a debugger, or reflection (plus an open security policy), or JNI, > or even a custom JVM, from "getting at" the Y. The general approach to prevent downcasting is to protect the subtype somehow. (Forget about stopping a debugger. There may be someway to prevent the debugger from seeing the true type using a security mechanism, but I don't know how or why you would do that.) Another way is to specify the super class as an interface type and use a protected/private inner class to implement that interface. Downcasting would not show anything useful. == 2 of 2 == Date: Wed, Nov 10 2004 6:59 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Andy Fish wrote: > I am writing an API call which returns an object of type X. In my code, I > build an object which is of type Y - a subclass of X. > > I'm worried that if I return the object Y, the caller will be able to use > reflection or a debugger to find out about the extra properties of Y. Is > this concern valid or is there something inherent that stops him doing this? Pretty much nothing prevents such analysis. On the other hand, nothing prevents a user from digging Y.class out of your jar and running it through javap, either. As to whether or not the concern is _valid_, I'd say you need to make a good case for why the caller must *at all costs* be prevented from doing what you describe before I would accept the concern as valid. > assuming my concern is valid, I need to make a "clone" of Y but for the > clone to be a superclass (i.e. X). Is there any clever way of doing this? Construct and return an X in the first place? I don't see the point of an object that is not an X, but yet is indistinguishable from one despite scrutiny. > The class X only contains public immutable properties and has no methods so > there is no need to deep copy. I hope you don't mean that X exposes its fields to the world. As long as access to its properties goes through accessor methods you have a great deal of flexibility, including a variety of ways to accomplish some of the things I imagine you might be trying to do. Before I make any specific recommendation, however, I need to know what things you actually are trying to do. (I have a vivid imagination. :-) ) John Bollinger [EMAIL PROTECTED] ========================================================================== TOPIC: class design need help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8f96c289e7ec780d ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 7:06 am From: Chris Smith <[EMAIL PROTECTED]> HS1 wrote: > However, it is not swing and I am still confused. I will try following your > suggestion: "That class should contain an event listener setup to notify > others of when it's changed" Please give more information about your problem and environment. Your being so vague about the application is not helping the matter. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ========================================================================== TOPIC: call perl programm from java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/46e3606311661fde ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 7:06 am From: "Sam" <[EMAIL PROTECTED]> Hello, is it possible to start a perl program from inside a java program and if so how? Thanks a lot! Sam ========================================================================== TOPIC: How to send an email with an attachment? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/154f0f65b6851d8b ========================================================================== == 1 of 1 == Date: Wed, Nov 10 2004 7:08 am From: "yihan" <[EMAIL PROTECTED]> Hello, I want to send a email with an attachment using Javamail. Can anybody help me? Thank you. zhao ======================================================================= 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
