comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * 'A'++ == 'B': Always True? - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb79b41e32f311b2 * the troubles with Java on old Win CE device. - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a25ce1189dd5c24 * EJB find methods. Why do they return only the primary key? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f78cddca61b64ba * CORBA or some other methodology? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7b217bf697c503b * I wrote my own Java in BASIC ! ! ! - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/29ec22b23b7d5d6d * Looking for co-op, internship or volunteer java programmer. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/392330321f8c5f4d * poblem with Java ( XP SP2) - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9671bb3935502091 * Is "String s = "abc";" equal to "String s = new String("abc");"? - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/57b8aacdcf136f3f * Java 2 Platform Standard Edition 5.0 - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2d99340e425e96cd * Java Thread Analysis - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c30c46b2c50ca5f * Hardware spec published? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/de3a1ca8e469825c * Character Encoding of a DOM object - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/989f73fe61ccf13b * loading a class whose bytecode comes in a byte[] - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e991c30dd027000 * Problem with ant javac task not finding interface dependence - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/16a880cc5daeb7d7 * Which way is more efficient - comparing strings of different letter casing - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3acc767a96f24a10 * Search for byte pattern in a binary file. - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc671002cbe38f70 * Deserializing in JDK1.5 without unchecked cast warning - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f79675ff00f1ea8d ========================================================================== TOPIC: 'A'++ == 'B': Always True? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb79b41e32f311b2 ========================================================================== == 1 of 3 == Date: Thurs, Nov 18 2004 2:12 am From: Michael Borgwardt <[EMAIL PROTECTED]> Chris Smith wrote: > I don't know for certain. I have vague memories of a Japanese encoding > that cannot represent all ASCII characters... but I'm not sure if it > lacks 'A' and 'B' or not. I happen to be pretty familar with Japanese encodings, and there are none that don't support the latin letters. In fact, most support them *twice*, once in an ASCII-compatible way and once as "full-width" versions, i.e. filling a square like the Japanese characters do. What you remember is probably the absence of the backslash and tilde in a very early Japanese encoding (that influenced the current ones), which were replaced by the yen sign an an overline. This has the result that when you switch Windows 2000 or XP to Japanese encoding for non-unicode applications, all file paths suddenly use yen signs instead of backslashes... == 2 of 3 == Date: Thurs, Nov 18 2004 2:18 am From: Michael Borgwardt <[EMAIL PROTECTED]> Chris Smith wrote: > I think you missed the point of Michael's response. That was that if > the source file was written in a text editor, and then saved in some > encoding that doesn't represent the character A, Or represents it in a different way than the compiler expects. I guess my real point was that while Java chars and literals are Unicode, Java source code before being fed to the compiler consists of bytes, i.e. is *not* Unicode. == 3 of 3 == Date: Thurs, Nov 18 2004 7:11 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Chris Smith wrote: > Doug Pardee <[EMAIL PROTECTED]> wrote: > >>Okay, everyone's been running all over the place with this one, >>dragging in all sorts of irrelevant stuff like Oriental languages. > > > Yes, and it's been such fun. ;) > > >>First, the character constant 'A' will *always* result in the char >>value of \u0041. This is defined by chapter 3 of the Java Language >>Specification (second edition) and by the nature of Unicode. Anyone who >>thinks that Oriental languages matter doesn't understand the whole >>point of Unicode: it combines ALL language 'glyphs' into a single >>unambiguous numbering system. Unicode values \0000-\007F always >>represent ASCII codes 0-127, okay? > > > I think you missed the point of Michael's response. That was that if > the source file was written in a text editor, and then saved in some > encoding that doesn't represent the character A, then the input to the > compiler could be wrong, and hence the result would be wrong. But I think Michael's point, albeit correct in some sense, was not germane. The OP was asking about Java source, but Michael was focusing on the _representation_ of the Java source. Something like, "the byte sequence you presented might be interpreted under some character encodings as Java source where the equality condition in question is false." (By all means correct me if I have misrepresented the point.) That misses on a very important issue: if we are considering Java source then we are necessarily considering _character_ data already. This is a key aspect of the Java programming language, albeit a sufficiently low-level one that it rarely rates a second thought. If the Java source is character data then converting it to bytes according to some (possibly identity) conversion and converting it back to characters via some different mechanism might do any manner of nasty things to it, true, but it's an invalid transformation. > It's a silly little exercise in abstract thought, and not really meant > for the OP at all. If you insist on making me take a side, it would be > that this possibility is irrelevant in discussing the result of Fritz's > code anyway, since in this scenario Fritz's code never really gets run. > I'd consider this analogous to proposing that disk corruption of the > class file might cause the wrong result. And in some sense I'm continuing the silly little exercise by truing to poke a hole in the argument. I think the analogy to class file corruption is particularly apt in light of my take on the issue (above). > Nevertheless, despite by disagreement with the semantic matter, I > believe Michael understands unicode quite well. I have no doubt about that. John Bollinger [EMAIL PROTECTED] ========================================================================== TOPIC: the troubles with Java on old Win CE device. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a25ce1189dd5c24 ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 2:35 am From: "Michael Shestero" <[EMAIL PROTECTED]> > > I have an old Windows CE 2.1 device with MIPS CPU. The only one VM I have found for this device is pocket-Java 1.0 (Sun). There was probably some VM by Micorsoft, but I cannot find it (MS annihilated every mention about it on the site). > > I found that classes created by default Java compiler (from JDKs) don't work: the message "class XXX is not found" appeared. But classes created by Jikes compiler works fine. [...] > > The second problem is that there is no Swing library included into that VM. > > I hope it is nevertheless possible to use the Swing there if I recompile it > > all using Jikes. > No, that won't work. Why it doesn't work? I thought the Swing is just a library of classes written in pure Java, so having the source I can rebuild it.(?) I would like to know more about "different versions of specifications of class-files". They are in strict accordance with the version of Java language (version of JDK), aren't they? Can I compile/run the source written on Java version X into binary bite-code version Y? (of couse I would like to have X>Y). >But including the old Swing JARs, from the time when it was > distributed separately might. You can find that old release here: > http://java.sun.com/products/archive/jfc/1.1.1/index.html > Or maybe this older version fits your JVM better: > http://java.sun.com/products/archive/jfc/1.0.3/index.html I tried the fitst one, and it seems to begin work. But my application couldn't start because it call new methods and classes which are absentv in this version of Swing. Michael == 2 of 2 == Date: Thurs, Nov 18 2004 2:43 am From: Michael Borgwardt <[EMAIL PROTECTED]> Michael Shestero wrote: >>>The second problem is that there is no Swing library included into that VM. >>>I hope it is nevertheless possible to use the Swing there if I recompile it >>>all using Jikes. >> >>No, that won't work. > > Why it doesn't work? I thought the Swing is just a library of classes > written in pure Java, so having the source I can rebuild it.(?) Yes, but only if you have all the classes it depends on, and I think the Swing libraries included in the SDK make use of some APIs not present in older Java versions. But if you want to try, the source code of all the API classes (including Swing) comes with the SDK, in a file "src.zip" in the base directory of the SDK installation - though you have the option not to install it during the SDK installation. > I would like to know more about "different versions of specifications of > class-files". They are in strict accordance with the version of Java > language (version of JDK), aren't they? Not sure what you mean with this. The spec versions are defined by Sun and each version of the JDK understands at least the version it produces and lower ones. But the version numbers are completely different from the JDK version numbers. > Can I compile/run the source written > on Java version X into binary bite-code version Y? (of couse I would like to > have X>Y). That's what the -target option of javac does, though it uses the JDK version numbers. ========================================================================== TOPIC: EJB find methods. Why do they return only the primary key? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f78cddca61b64ba ========================================================================== == 1 of 3 == Date: Thurs, Nov 18 2004 2:33 am From: Andrea Desole <[EMAIL PROTECTED]> Playing around with EJBs, I'm noticing that the find methods in the home interface return a complete bean (well, its interface), but the implementation of the find method in the bean itself returns only the primary key. What I know is that the container first gets the primary key using the find method, and then retrieves the object (maybe using ejbLoad?). What I don't understand is why I should access the database (or whatever repository where I can find my information) twice, instead of just building the bean and returning it in the find method. It can't be because the client only works on a stub, because all the calls on my stub will eventually go to the real object, so I'll need it anyway. It can be because the complete bean is not always needed (for example for a remove), but is it really a gain? Am I missing something? == 2 of 3 == Date: Thurs, Nov 18 2004 4:51 am From: [EMAIL PROTECTED] Andrea Desole wrote: > Playing around with EJBs, I'm noticing that the find methods in the home > interface return a complete bean (well, its interface), but the > implementation of the find method in the bean itself returns only the > primary key. > What I know is that the container first gets the primary key using the > find method, and then retrieves the object (maybe using ejbLoad?). > What I don't understand is why I should access the database (or whatever > repository where I can find my information) twice, instead of just > building the bean and returning it in the find method. It can't be > because the client only works on a stub, because all the calls on my > stub will eventually go to the real object, so I'll need it anyway. It > can be because the complete bean is not always needed (for example for a > remove), but is it really a gain? > Am I missing something? well, you just discovered one of many reasons why CMP EJB's and EJB in general is a bad but very hyped idea. http://c2.com/cgi/wiki?WhatsWrongWithEjb And no, your not missing anything, accessing n entity beans, by specification, leads to at least n+1 calls to the database. http://c2.com/cgi/wiki?EntityBmpFinders == 3 of 3 == Date: Thurs, Nov 18 2004 5:03 am From: Michael Borgwardt <[EMAIL PROTECTED]> [EMAIL PROTECTED] wrote: > well, you just discovered one of many reasons why CMP EJB's and EJB in > general is a bad but very hyped idea. > http://c2.com/cgi/wiki?WhatsWrongWithEjb > > And no, your not missing anything, accessing n entity beans, by > specification, leads to at least n+1 calls to the database. > http://c2.com/cgi/wiki?EntityBmpFinders Lots of opinionated badmouthing, little agreement or substance on those pages. ========================================================================== TOPIC: CORBA or some other methodology? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a7b217bf697c503b ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 3:59 am From: [EMAIL PROTECTED] (Dave Monroe) [EMAIL PROTECTED] (Ted Holden) wrote in message news:<[EMAIL PROTECTED]>... > Another seriously stupid question here...... > > I've got a situation in which a java applet has to retrieve > information from a server and the process which generates the > information is complex and performance-critical enough that it pretty > much has to be written in C++ asnd not Java. > > The one thing I know of which does that sort of thing is CORBA. > > But then, my knowledge of Java is pretty miniscule. Does anybody have > any reason to believe that there might be any other methodology for > doing that sort of thing, i.e. for allowing a Java applet to access a > server object written in C++ which for any reason might be preferable > to CORBA? Applets have a security restriction that prohibits them from interacting with either the host system (other than cookies) or any network address other than the one that served the applet in the first place. The security restriction can be bypassed by affixing a digital signature to the applet. At that point it's up to the user at the host end to either accept or reject the signed applet. I would suggest you go server-to-server rather than applet-to-server. The applet-to-server architecture is pretty lame. Take a look at servlets and/or Java Server Pages. Also RMI-IIOP. == 2 of 2 == Date: Thurs, Nov 18 2004 6:36 am From: Bruno Grieder <[EMAIL PROTECTED]> Thomas Weidenfeller wrote: > Ted Holden wrote: > >> I've got a situation in which a java applet has to retrieve > > > Applet? Well, consider an application, deployed via JavaWebStart. > >> information from a server and the process which generates the >> information is complex and performance-critical enough that it pretty >> much has to be written in C++ asnd not Java. > > > Java performance is in general on par with that of C or C++. It always > depends a little bit on who fabricated the benchmarks, if C/C++ or Java > comes out better. If you want to have a conservative estimate, than > assume that Java is maybe 10% slower than C/C++. > >> The one thing I know of which does that sort of thing is CORBA. > > > You talk about performance, and then you talk about CORBA? With its huge > marshaling/unmarshalling overhead? Well, yes, CORBA can be used to > exchange data, but any other TCP or UDP based protocol would do, too. > You could build your own, customized protocol (which you can fine-tune > to your needs, but which is probably the most work). You could use HTTP > + HTML to transport the data, you could (not recommended) use SOAP. Or > whatever suits your needs. > > If you go for an applet, you would have to take care that the Java > security mechanisms don't come in your way. E.g. unless the applet is > signed, it can't communicate with any other server than the server from > which it was loaded. > > Oh, and if you go for CORBA be prepared that a lot of corporate > firewalls have the necessary ports closed, so you need to be prepared to > tunnel, or convince people to open the ports. > >> But then, my knowledge of Java is pretty miniscule. Does anybody have >> any reason to believe that there might be any other methodology for >> doing that sort of thing, i.e. for allowing a Java applet to access a >> server object written in C++ which for any reason might be preferable >> to CORBA? > > > Sounds like you already made up your mind and that you want to go for > CORBA. CORBA would almost be my last choice, not my first. The fact that the server object is written in C++ should have little influence on your decision as long as the protocols can be implemented in both C++ and Java (and there are many). My choice would rather evolve around things like: -what level of security do I need (authentication, encryption, signature, etc...) -do I need real RPC capabilities or just "posting/retrieving" data? -is this on a LAN, WAN,... -what ports can I use? -what sort of bandwith do I have? -do I want synchronous/asynchronous behaviour? -do I need this thing to look good on slides? -do I have people that know this technology? -etc.... Perfectly acceptable security can be achieved with a simple https post or get. Now, if you want procedure calls with type marshalling but simple stuff, why not XML-RPC? You want the marketing hype, why not a web-service? Goold old heavy industrial strength on a LAN, Corba? etc... Bruno > > /Thomas ========================================================================== TOPIC: I wrote my own Java in BASIC ! ! ! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/29ec22b23b7d5d6d ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 3:50 am From: "Rhino" <[EMAIL PROTECTED]> "Thomas Weidenfeller" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hans-Marc Olsen wrote: > > Java was too expensive for me, so I wrote my own Java in BASIC. > > I have written that already in c.l.j.help: > > This is a prank to flood can.* (no idea what that hierarchy is about) > newsgroups with angry responses - see the newsgroup line in the original > posting. This is going on for some time now, in many newsgroups. > The can.* hierarchy is for newsgroups dealing with Canada. I'm not aware of any can.* newsgroups dealing with Java or even programming. > It is best to ignore these posting. If you feel the need to respond, at > least remove the other newsgroups from your posting. If you feel the > need to "discuss" the "contents", set a follow up to a .advocacy group. > Agreed. Rhino ========================================================================== TOPIC: Looking for co-op, internship or volunteer java programmer. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/392330321f8c5f4d ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 3:55 am From: "Rhino" <[EMAIL PROTECTED]> "Chris Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > xarax <[EMAIL PROTECTED]> wrote: > > Let me get this straight. You want someone to donate > > their skills (listed above) to benefit your company? > > The part that was most amusing to me was that, after all this, he asked > for resumes to prove qualifications, and said he'd contact people to > interview them. Ha! > There are some old sayings that come to mind when I read this 'ad': 1. "A workman is worthy of his hire." 2. "You get what you pay for." If anyone actually offers to work free for this guy, I'd add one more: "There's a sucker born every minute." Rhino ========================================================================== TOPIC: poblem with Java ( XP SP2) http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9671bb3935502091 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 4:24 am From: [EMAIL PROTECTED] (Ruvim Pinka) [EMAIL PROTECTED] (Ruvim Pinka) wrote in message news:<[EMAIL PROTECTED]>... > Hello! > > The one java network application work fine under Windows 2000 and XP > SP1, but don't work under XP SP2. probably, problem is not in SP2 On a different machines an application has a differenet settings (very latent).. > In the Java Web Start Console i have a follow dump: > ===== > Java 2 Runtime Environment: Version 1.4.2_03 by Sun Microsystems Inc. > AxisFault > faultCode: {http://xml.apache.org/axis/}HTTP > faultSubcode: > faultString: (405)Method not allowed > [...] > (405)Method not allowed > > at > org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:630) > > Does anybody solve such problem ? ========================================================================== TOPIC: Is "String s = "abc";" equal to "String s = new String("abc");"? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/57b8aacdcf136f3f ========================================================================== == 1 of 3 == Date: Thurs, Nov 18 2004 4:34 am From: "Bruce Sam" <[EMAIL PROTECTED]> In my opinion,"String s = "abc";" has only created a reference s not a object."String s= new String("abc");" has created a new object and its reference is s.Is it right?If I'm right,I still have a question.When I can use first one not need the second one? == 2 of 3 == Date: Thurs, Nov 18 2004 4:38 am From: Michael Borgwardt <[EMAIL PROTECTED]> Bruce Sam wrote: > In my opinion,"String s = "abc";" has only created a reference s not a > object."String s= new String("abc");" has created a new object and its > reference is s.Is it right? Not really. Both declare a reference, and while the first doesn't explicitly *create* an object at runtime, there still *is* an Object. It's part of the constant pool of the class and created when the class is loaded. == 3 of 3 == Date: Thurs, Nov 18 2004 6:03 am From: kaeli <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] enlightened us with... > In my opinion,"String s = "abc";" has only created a reference s not a > object."String s= new String("abc");" has created a new object and its > reference is s.Is it right?If I'm right,I still have a question.When I > can use first one not need the second one? > > It is my understanding that if you don't specify the "new" keyword, if another string object already has a reference to the value "abc", a new object is not created (no more memory is allocated) - instead, it points to the same spot in memory. If nothing does, it does create a new object (memory allocation). If you specify the new keyword, a new object is always created (memory allocation), regardless. Mostly the difference is seen with the equals method and '=='. See this page for a better explanation: http://www.jchq.net/certkey/0502certkey.htm -- -- ~kaeli~ You feel stuck with your debt if you can't budge it. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace ========================================================================== TOPIC: Java 2 Platform Standard Edition 5.0 http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2d99340e425e96cd ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 4:36 am From: [EMAIL PROTECTED] (Sam) I'm very new to Java 2 Platform Standard Edition 5.0 but I very keen to learn it. Please advise where I could get online tutorial / reference website of Java 2 Platform Standard Edition 5.0. Looking good news from you soon. Many thanks. == 2 of 2 == Date: Thurs, Nov 18 2004 4:41 am From: Michael Borgwardt <[EMAIL PROTECTED]> Sam wrote: > I'm very new to Java 2 Platform Standard Edition 5.0 but I very keen > to learn it. > > Please advise where I could get online tutorial / reference website of > Java 2 Platform Standard Edition 5.0. > > Looking good news from you soon. Are you looking for an introduction to Java in general, or only to the new feature of version 1.5 (the 5.0 is considered nonsense by most people here)? For the first, take a look at Sun's Java tutorial: http://java.sun.com/docs/books/tutorial/index.html For the second, lokk at the release notes for 1.5: http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html ========================================================================== TOPIC: Java Thread Analysis http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c30c46b2c50ca5f ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 4:37 am From: Stephen Kellett <[EMAIL PROTECTED]> In message <[EMAIL PROTECTED]>, Carl <[EMAIL PROTECTED]> writes >Does anyone know of a tool that can be used to track a thread's >lineage. We currently have the situation where several thousand >threads will be running in our system. We believe that some piece of Java Thread Validator. Also detects deadlocks, etc. http://www.softwareverify.com/publicBeta.html Stephen -- Stephen Kellett Object Media Limited http://www.objmedia.demon.co.uk RSI Information: http://www.objmedia.demon.co.uk/rsi.html == 2 of 2 == Date: Thurs, Nov 18 2004 6:51 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Carl wrote: > The profiler is useful in that it seems to answer the questions: > How many threads of each class are running? > Given a top level thread, what other threads were called by whom? > > It does not appear to answer: > How many ThreadB's did ThreadA invoke? Do you mean "instantiate"? "Start"? Something else? Neither Threads nor threads are "invoked". Moreover, Neither Threads nor threads instantiate or start Threads, at least not in the sense that we usually apply to the various actors in an object-oriented program. "Threads" are object handles on "threads" of sequential execution. Various objects may instantiate Thread objects, in the context of one or another thread, and may, in the context of some possibly different thread, use that Thread object to start a new thread. Once started, a thread does not retain any sense of the thread that provided the context in which it was started (neither directly nor via the corresponding Thread objects). Likewise, a Thread object does not, any more than any other object, retain any sense of the object that instantiated it, nor of the object(s) that invoked any particular method on it (e.g. start()). > Given a low level thread, what threads invoked it? That doesn't make any sense at all. Running threads do not invoke other threads. They may synchronize with each other in a variety of ways. They may access shared objects (but shared objects, by definition, do not belong to any particular thread). If you have thread pool then you could ask the question of which threads or objects have provided jobs for particular threads in the pool, but unless you have coded some logging mechanism to record that data at the time it occurs then there is no reliable way to divine it later. Details of the execution history of your program are not available from the program state itself in the general case. As such, no debugger or profiler is going to be able to give you some of the information you seek unless you instrument the program to provide it (in which case a debugger or profiler would be a rather clunky way to get at it, as opposed, say, to a log file, thread names in a thread dump, etc.). John Bollinger [EMAIL PROTECTED] ========================================================================== TOPIC: Hardware spec published? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/de3a1ca8e469825c ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 5:02 am From: "VisionSet" <[EMAIL PROTECTED]> "Chris Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > VisionSet <[EMAIL PROTECTED]> wrote: > > Does sun produce a hardware spec for swing? > > eg graphics card/cpu specs? > > Such a thing doesn't make much sense, since Swing doesn't include any > hardware. What, exactly, do you want to know? > I want to know the minumum hardware spec of hardware items relevant to running a Swing app. ie Graphics card and CPU. I know for instance that trying to run a Swing app on an old laptop I use is a non-starter, I at least have to whack the colours down to 256. Surely there is sense in saying something like minimum 400 Mhz CPU etc My desktop is 700 Mhz with an average at the time (5 years ago) graphics card. This I judge to be a minimum, but wondered if there was any official recommendation. All those instructions to go between java and native has a certain cost. -- Mike W ========================================================================== TOPIC: Character Encoding of a DOM object http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/989f73fe61ccf13b ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 5:05 am From: Martin Honnen <[EMAIL PROTECTED]> Rakesh Pandit wrote: > 1. We have a input xml stream of the type: > > <?xml version="1.0" encoding = "shift_JIS"?> > <TestMessage> > </TestMessage> > > 2. We then create a DOM object out of thr xml stream > > Document doc = m_docBuilder.parse(xmlstream); > > 3. We wanted to find out the encoding property of the > doc, which should give us the result "shift_JIS". > > Is their a method to extract this property ? There is (with Java JDK 1.5/5.0): http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-inputEncoding so you will need doc.getInputEncodind() -- Martin Honnen http://JavaScript.FAQTs.com/ ========================================================================== TOPIC: loading a class whose bytecode comes in a byte[] http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4e991c30dd027000 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 5:57 am From: "John C. Bollinger" <[EMAIL PROTECTED]> Luca Rosellini wrote: > Hi everybody, I have this problem with classloaders: > > Suppose to have two nodes A and B, node A creates a new class C1 > (in the package "Package") which implements an interface (call it > myInterface) known to both node A and B. OK. > A retrieves the bytecode for C1, stores it in a byte[] and send > it in a datagram to node B. Fine. > In order to properly load the class on B's JVM I actually inherit > from ClassLoader and override loadClass method in this way: > > class myClassLoader extends ClassLoader{ > ... > ... > > public Class loadClass(String className, boolean res){ > // check if the clas has not yet been loaded > // blah blah > > byte[] classData = buffer_containing_bytecode; > > Class result = defineClass(className, classData, 0, > classData.length); > ... > ... > return result; > } > > } You should be overriding findClass(String), not loadClass(String, boolean). That will allow the the base implementation to handle more of the details for you (such as checking whether the class is already loaded), and will allow your ClassLoader to participate in the standard ClassLoader delegation model, which is probably where your current version is falling down. When defining a custom ClassLoader it is almost always findClass that you want to override. Refer to ClassLoader's API docs for details. > when I need to load the class in my program I do the following (in a > try-catch clause): > > myClassLoader cl = new myClassLoader(); Assuming your custom ClassLoader were set up correctly for delegation, that instantiation would make your custom ClassLoader delegate to the system ClassLoader. That might be OK, and perhaps it would even be the expressly desired behavior, but it is more likely that you want to delegate to this.getClass().getClassLoader(). > Class myClass = cl.loadClass("P.C1",true); That should work. It may not be especially useful to tell the class loader to link the class immediately -- I would just use the one-arg form of loadClass unless it is important to your application that the class be linked immediately. > loadClass seems to return successfully, if I use reflection on myClass object > to > get informations on methods or fields of the class I get correct results. To the extent you checked, as far as you could determine. > This leads me to think that class is loaded properly. > However if I try to create an Instance from myClass using > myClass.newInstance() I > get an InstantiationException. Which, according to the API docs, tells you that the system thinks the Class in question represents an abstract class or an interface. I think that may be a red herring in your case, though. > Any of you knows what I am doing wrong? > > P.S.: There's another solution that works, but I don't like it, it looks > much more like a workaround than a solution and a write on disk is needed: > when the bytecode arrives on node B I dump it in a file called "C1.class" > in a folder called"Package" using a File a object and calling deleteOnExit() > on that File object. when tring to create a new instance from object > myClass everything as expected. This is pretty strong evidence that your ClassLoader implementation is what's causing the trouble. Rewrite it to correctly make use of the ClassLoader delegation model (as described above) and instantiate it with the right delegation parent (probably the ClassLoader of the instantiating class). If that doesn't solve the problem then come back with the full stack trace of your exception and complete code for the ClassLoader and attempted class instantiation. If there is Java code for the class being transferred and its dependencies then that might be helpful too. John Bollinger [EMAIL PROTECTED] ========================================================================== TOPIC: Problem with ant javac task not finding interface dependence http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/16a880cc5daeb7d7 ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 6:02 am From: Collin VanDyck <[EMAIL PROTECTED]> Hello! This is a curiosity which I cannot off the top of my head explain. In a very simple way, I have one class that implements an interface which defines a static final constant; we'll call that constant "DB_VERSION". My class that implements this interface explicitly references this DB_VERSION and uses it in its instance methods. If I make a change to that interface, incrementing the DB_VERSION, apparently my ant javac task will recompile the interface correctly, but at runtime the class that implemented the interface will still be using the older value for DB_VERSION. I can, of course, fix this by cleaning out the previous build files, but that takes a while. Is there a setting I can set on javac to find this dependency between my object and the interface and compile both? Thanks Collin ========================================================================== TOPIC: Which way is more efficient - comparing strings of different letter casing http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3acc767a96f24a10 ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 6:10 am From: kaeli <[EMAIL PROTECTED]> If I have a string and I don't know the letter case, and I wish to compare it to a known string of known case, which of these methods is more efficient? The string is (would be) in the variable "myStr" and we do not know if it is null and we do not know the case of the letters. A: if ("VALUE".compareToIgnoreCase(myStr) == 0) { // do something } B: myStr = myStr==null?null:myStr.toUpperCase() if ("VALUE".equals(myStr)) { // do something } Even more efficient code than either of these two welcome. :) -- -- ~kaeli~ Local Area Network in Australia:... the LAN down under. http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace == 2 of 2 == Date: Thurs, Nov 18 2004 6:44 am From: Michael Borgwardt <[EMAIL PROTECTED]> kaeli wrote: > If I have a string and I don't know the letter case, and I wish to compare it > to a known string of known case, which of these methods is more efficient? > > The string is (would be) in the variable "myStr" and we do not know if it is > null and we do not know the case of the letters. > > A: > if ("VALUE".compareToIgnoreCase(myStr) == 0) { > // do something > } > > B: > myStr = myStr==null?null:myStr.toUpperCase() > if ("VALUE".equals(myStr)) { > // do something > } 1. Why are you worrying about this? Has a profiler told you that it's this comparison that your application spends most of its time in? 2. Use the source, Luke. You have access to the source code of the String class. 3. Looking at it will reveal that it's full of checks and optimizations for special cases, which means that your question cannot be meaningfully answered - it depends on the kind of strings you want to compare. 4. Why don't you just try it out? Writing a little benchmark will give you an answer four your actual data, JVM and hardware, and is a matter of 5 minutes. ========================================================================== TOPIC: Search for byte pattern in a binary file. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cc671002cbe38f70 ========================================================================== == 1 of 2 == Date: Thurs, Nov 18 2004 6:16 am From: "xarax" <[EMAIL PROTECTED]> "Thomas Weidenfeller" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ryan Tan via JavaKB.com wrote: > > Hi there, does anyone have a quick way to search for a byte pattern in a binary file? > > Look at (Google for) algorithms like Boyer-Moore, Knuth-Morris-Pratt or > Rabin-Karp. His main concern is about finding the byte pattern when it crosses a buffer boundary. The algorithms mentioned above presume the entire file is in memory. == 2 of 2 == Date: Thurs, Nov 18 2004 6:35 am From: Michael Borgwardt <[EMAIL PROTECTED]> xarax wrote: >>>Hi there, does anyone have a quick way to search for a byte pattern in a >>>binary file? > >>Look at (Google for) algorithms like Boyer-Moore, Knuth-Morris-Pratt or >>Rabin-Karp. > > > His main concern is about finding the byte pattern > when it crosses a buffer boundary. The algorithms > mentioned above presume the entire file is in memory. His main concern seemed to be about that *and* about the speed. The algorithms Thomas referred him to will take care of the speed concern as far as possible. The finding of patterns covering buffer boundaries is a minor technical problem. I'd solve it by keeping two buffers in memory and only replacing the "older" one when you've gone through it. Oh, and refuse to search for a pattern that's larger than the buffer size. ========================================================================== TOPIC: Deserializing in JDK1.5 without unchecked cast warning http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f79675ff00f1ea8d ========================================================================== == 1 of 1 == Date: Thurs, Nov 18 2004 7:06 am From: [EMAIL PROTECTED] (Andrew Lee) Thanks for the link. Yeah, it's unfortunate that @SuppressWarnings hasn't been implemented but I'll use it for now and hope for the best. "bilbo" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > As far as I know you currently can't. Sun has defined a > @SuppressWarnings annotation that can be used to suppress unchecked > warnings, among others, in a section of code. Unfortunately it's not > actually implemented in the first Java 1.5 release. So you can add the > annotation to your code now and take comfort in the fact that in some > future release of the JDK your code will compile with no warnings. > > See > http://www.langer.camelot.de/GenericsFAQ/FAQSections/TechnicalDetails.html#FAQ004 > for more information. ======================================================================= 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
