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

Today's topics:

* Is instanceof dirty? - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/395347a70489adef
* Listeners and Events - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eaffb27697eae746
* detecting a socket reset - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f3ee4dbd2fe41b8
* Simple question: manifest.mf - 5 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/110ae3b5be82f131
* memory-use measurement - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/60467ae40717e75f
* Java newbie: RMI woes on Linux - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/96a016c1721dc337
* Restricting the applet classloader? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3cfe733a0792057b
* comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2004-10-08) - 1 
messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2328481e0eed4070
* ZipOutputStream, ZipFile and Linux unzip do not agree on the file count in 
zip - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7aced318b9e04b5c
* Few beginner questions,pls help - 4 messages, 4 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34bf858415de0785
* returning a subclass through an interface - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b62cd9cf6edaa6c4
* tomcat vs. resin - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/86085f5203580e61
* Does Tomcat support multi-CPUs? - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d4853dfb94cefa18
* who uses algorithms learned in cs studies? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf
* Implicit object creation - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ea9ee9cb601f58c
* Thread-question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5766e179910e25fa
* MIDlet Design Question - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/45f298001caa915e
  
==========================================================================
TOPIC: Is instanceof dirty?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/395347a70489adef
==========================================================================

== 1 of 3 ==
Date:   Wed,   Nov 10 2004 1:23 am
From: [EMAIL PROTECTED] (Jesper Nordenberg) 

It's called the visitor pattern.

/Jesper Nordenberg



== 2 of 3 ==
Date:   Wed,   Nov 10 2004 2:22 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Jesper Nordenberg wrote:
> It's called the visitor pattern.

Or double-dispatch.

    -- chris





== 3 of 3 ==
Date:   Wed,   Nov 10 2004 3:07 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

John C. Bollinger wrote:

> The one place where I find myself frequently using instanceof in Java is
> in equals() methods,
[...]
> That particular kind of use
> doesn't seem to quite to square with your characterization (above)
> because the question isn't really a generic "what class are you?" but
> rather "is your class compatible with mine?".  Would you agree that that
> kind of use makes more sense in your worldview?

Yes, I'd forgotten about that case.  Thanks for the reminder.  It does indeed
make more sense.

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.

For one thing it applies between all pairs of objects, no matter how unrelated
they are (which, basically, is why you need the instanceof test, or an
equivalent).  Normally it would be seen as a congitive error (category error)
to try to compare, say, an IncomeTaxBand with an IncomeTaxReturn, let alone
with an AbstractRenderable, but equals() is expected to be up to the task...

And then too, it's context independent, but for real purposes comparison
/isn't/ independent of the context.  You are normally wanting to know if two
things are "the same" /for some purpose/, yet there's no mention of the context
in equals().

There's something twisted about the object-modelling involved in equals().  I'm
almost tempted to say that it shouldn't exist at all.  It's certainly very
ungainly.


> 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 can't remember ever implementing equals() in Java, which may be
significant in itself -- or maybe I'm just in denial ;-)

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.  "Paradigm"
would be a better name than "species", but unfortunately that word has been
hijacked by bloody Kuehn (sp?) and I don't think many people would recognise it
in the correct/original sense of "defining example".

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.  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 ?

    -- chris






==========================================================================
TOPIC: Listeners and Events
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/eaffb27697eae746
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 1:52 am
From: SMMT <[EMAIL PROTECTED]> 

Thank you Michael and Thomas for you opinions. It seams I was wrong thinking 
there is a better way 
doing things , I'll continue using the same code. (Thomas, I was not talking 
about Swing events , 
the MVC implementation I talked about is between objects created by my self.)




==========================================================================
TOPIC: detecting a socket reset
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6f3ee4dbd2fe41b8
==========================================================================

== 1 of 3 ==
Date:   Wed,   Nov 10 2004 1:50 am
From: [EMAIL PROTECTED] (Harvey Tate) 

Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> On 9 Nov 2004 06:16:39 -0800, Harvey Tate wrote:
> 
> > I am writing some code to read data from a socket. 
> 
> You mentioned that barely more than an hour 
> ago, and got a response.


I think I hit the submit button twice by accident...



== 2 of 3 ==
Date:   Wed,   Nov 10 2004 1:51 am
From: [EMAIL PROTECTED] (Harvey Tate) 

thanks gordon - I'll discuss this with the guys at the other end of the socket!



== 3 of 3 ==
Date:   Wed,   Nov 10 2004 2:26 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On 10 Nov 2004 01:50:10 -0800, Harvey Tate wrote:

> Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL 
> PROTECTED]>...
>> On 9 Nov 2004 06:16:39 -0800, Harvey Tate wrote:
>> 
>>> I am writing some code to read data from a socket. 
>> 
>> You mentioned that barely more than an hour 
>> ago, and got a response.
> 
> I think I hit the submit button twice by accident...

I thought so too, in that case I might have made no comment, 
until I realised your posts were not separated by 
'a couple of seconds' which might support the 
'hit button twice' hypothesis.  

No, instead the posts were separated by approximately 
'one hour ten minutes'.  This completely does *not* support the 
'hit button twice' hypothesis (or if that's what you consider a 
'double click' - I'd hate see your work output stats!)

[  Or, in other words.  Don't give me that crap.  ]

-- 
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 5 ==
Date:   Wed,   Nov 10 2004 1:53 am
From: "ShadowMan" <[EMAIL PROTECTED]> 

Hi all
I have to specify a long number of jars in Class-path field of MANIFEST.MF 
file.
If I put some of them on new line it seem that application server doesn't 
see them...I also tried to use '\' at end of line...but it still doesn't 
work

How can I avoid a long Class-path line ?

thanx
-- 
ShadowMan 





== 2 of 5 ==
Date:   Wed,   Nov 10 2004 2:10 am
From: "KC Wong" <[EMAIL PROTECTED]> 

> I have to specify a long number of jars in Class-path field of MANIFEST.MF
file.

> If I put some of them on new line it seem that application server doesn't
> see them...I also tried to use '\' at end of line...but it still doesn't
> work

The manifest is parsed in a line by line style I think... and I have not
read about any line continuation syntax in the docs.


> How can I avoid a long Class-path line ?

Either repackage the jar you depends on, or... turn on line wrap in your
editor - it might make you feel better :)





== 3 of 5 ==
Date:   Wed,   Nov 10 2004 2:14 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

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.  

OTOH, what are all these jar files?  If you have a list of jars 
too long for a single line, how many bytes does that add up to 
in the files themselves?

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



== 4 of 5 ==
Date:   Wed,   Nov 10 2004 2:38 am
From: Andrea Desole <[EMAIL PROTECTED]> 

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).



== 5 of 5 ==
Date:   Wed,   Nov 10 2004 2:53 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

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.

-- 
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: memory-use measurement
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/60467ae40717e75f
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 2:18 am
From: Reiner Funck <[EMAIL PROTECTED]> 

Hallo,

my memory-use measurement for a Java-process (Java 1.5)
shows 170000 Bytes.
(memoryuse = Runtime.totalMemory() - Runtime.freeMemory())

The simultaneously measurement with  ps  shows 64000 Bytes.
(Suse 9.1, kernel 2.6.4)

What is wrong?

Many thanks for help
Reiner





==========================================================================
TOPIC: Java newbie: RMI woes on Linux
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/96a016c1721dc337
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 2:11 am
From: Nigel Wade <[EMAIL PROTECTED]> 

Andy wrote:

> I am a java newbie and was trying my hand at RMI. I have an interface,
> a server implementing that interface and a utility class with "public
> static void main" to register the server class. I also have a client,
> which calls the server using Naming.lookup(...) and calls methods on
> it.
> Of course, before binding the server I start the rmiregistry on my
> local machine, without specifying the port and by specifying the
> following option:
> 
>  -J-Djava.security.policy=E:\mydir\...\rmiserver.policy
> 
> Later, when I try to register the server, the registration fails with
> an access denied error on localhost:1099.
> 
> The policy file I am using is simple:
> 
> grant{
>  permission java.security.AllPermissions;
> };
> 
> Any pointers would be greatly appreciated.
> 
> IMP: I am facing this problem on my Linux box. Whereas on my Windows,
> a similar program runs without cribs. (No advocacy meant for Windows.)
> 
> Cheers,
> Andy

E:\mydir\...\rmiserver.policy
is a very strange Linux pathname. 

Try without any security policy. I find this works ok on Linux for
testing/development purposes.

Do you have a firewall on the Linux box? Is it enabled, and does it allow
connections to port 127.0.0.1:1099? Is the rmiregistry actually listening
on 1099?

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
            University of Leicester, Leicester, LE1 7RH, UK 
E-mail :    [EMAIL PROTECTED] 
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555




==========================================================================
TOPIC: Restricting the applet classloader?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3cfe733a0792057b
==========================================================================

== 1 of 2 ==
Date:   Wed,   Nov 10 2004 2:23 am
From: [EMAIL PROTECTED] (Filip Larsen) 

I have a client-server setup where the client is distributed as an
applet in a single jar file containing all class files and resource
bundle files needed by the applet. However, during initialization of
the many resource bundles used by the applet, the classloader sends
great many requests to the server for non-existing resource bundle
files.

Previously, in an unrelated project, I fixed this problem by simply
providing "empty" resource bundle class files with the client jar, but
in this case that solution would require a great number of such dummy
files.

So, I was wondering if a more elegant solution perhaps was possible
using a "restricted" class loader during the load of the resource
bundles. Persuing this I quickly bang my head on a SecurityException
from the security manager (since the applet is and should be
unsigned).

Anyone know of another solution to stop the applet from making all
those futile server requests?


Regards,
-- 
Filip Larsen



== 2 of 2 ==
Date:   Wed,   Nov 10 2004 3:13 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

Filip Larsen wrote:
> So, I was wondering if a more elegant solution perhaps was possible
> using a "restricted" class loader during the load of the resource
> bundles. Persuing this I quickly bang my head on a SecurityException
> from the security manager (since the applet is and should be
> unsigned).

It looks as if this is not a classloader problem at all, but the 
getBundle() method just does what it is supposed to do, and looks up a 
bundle under a lot of different names. So, if you don't want this, don't 
use getBundle(), but implement something on your own, which uses the 
searchs strategy you like.

When you do so, the getResource[AsStream]() methods of the classloader 
might be very handy.

/Thomas




==========================================================================
TOPIC: comp.lang.java.{help,programmer} - what they're for (mini-FAQ 2004-10-08)
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2328481e0eed4070
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 2:25 am
From: [EMAIL PROTECTED] (David Alex Lamb) 

Last-Modified: Fri Oct  8 11:38:42 2004 by David Alex Lamb
Archive-name: computer-lang/java/help/minifaq
Posting-Frequency: every 4 days

Before posting read Jon Skeet's "How to get answers on the comp.lang.java.*
newsgroups" at http://www.pobox.com/~skeet/java/newsgroups.html

Java FAQs and advice:
- Java FAQ (Andrew Thompson)  http://www.physci.org/codes/javafaq.jsp
  including his list of other FAQs http://www.physci.org/codes/javafaq.jsp#faq
- Java/Javascript/Powerbuilder HOWTO (Real Gagnon)
  http://www.rgagnon.com/howto.html
- Java Glossary (Roedy Green)  http://www.mindprod.com/jgloss.html
- jGuru jFAQs (John Zukowski)    http://www.jguru.com/jguru/faq/
- Focus on Java (John Zukowski)   http://java.about.com/
- Java Q&A (David Reilly)  http://www.davidreilly.com/jcb/faq/
- Java GUI FAQ (Thomas Weidenfeller) http://www.physci.org/guifaq.jsp

comp.lang.java.help     Set-up problems, catch-all first aid.
    According to its charter, this unmoderated group is for immediate help
    on any Java problem, especially when the source of the difficulty is
    hard to pin down in terms of topics treated on other groups.
        This is the appropriate group for end-users, programmers and
    administrators who are having difficulty installing a system capable of
    running Java applets or programs.  It is also the right group for
    people trying to check their understanding of something in the
    language, or to troubleshoot something simple.

comp.lang.java.programmer  Programming in the Java language.
    An unmoderated group for discussion of Java as a programming language.
    Specific example topics may include:
      o types, classes, interfaces, and other language concepts
      o the syntax and grammar of Java
      o threaded programming in Java - sychronisation, monitors, etc.
      o possible language extensions (as opposed to API extensions).
    The original charter said that discussion explicitly should not include
    API features that are not built into the Java language and gave examples
    like networking and the AWT.  These days AWT belongs in clj.gui, and
    networking (and many other APIs) are often discussed in clj.programmer.

Do not post binary classfiles or long source listings on any of these
groups. Instead, the post should reference a WWW or FTP site (short source
snippets to demonstrate a particular point or problem are fine).  For some
problems you might consider posting a SSCCE (Short, Self Contained, Correct
(Compilable), Example); see http://www.physci.org/codes/sscce.jsp

Don't post on topics that have their own groups, such as:
 comp.lang.java.3d        The Java 3D API
 comp.lang.java.advocacy  Arguments about X versus Y, for various Java X and Y
 comp.lang.java.beans     JavaBeans and similar component frameworks
 comp.lang.java.corba     Common Object Request Broker Architecture and Java
 comp.lang.java.databases Using databases from Java
 comp.lang.java.gui       Java graphical user interface design and construction
 comp.lang.java.machine   Java virtual machines, like JVM and KVM
 comp.lang.java.security  Using Java securely
 comp.lang.java.softwaretools Tools for developing/maintaining Java programs
Don't cross-post between these groups and c.l.j.programmer or .help -- it just
wastes the time of people reading the general groups.

Don't post about JavaScript; it's a different language.  See
comp.lang.javascript instead.
-- 
"Yo' ideas need to be thinked befo' they are say'd" - Ian Lamb, age 3.5
http://www.cs.queensu.ca/~dalamb/   qucis->cs to reply (it's a long story...)




==========================================================================
TOPIC: ZipOutputStream, ZipFile and Linux unzip do not agree on the file count 
in zip
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7aced318b9e04b5c
==========================================================================

== 1 of 2 ==
Date:   Wed,   Nov 10 2004 2:26 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

C B wrote:
> I use ZipOutputStream to build a zip file.  The program zipped 72417
> files, but after checking it with ZipFile, ZipFile.size() reported
> only 6881 files in the file.  So unfortunately, Java is unable to read
> all the entries in the zip file, but Linux's PK-INFO (unzip) is able
> to read the file.

If you subtract the numbers, you will get a very familiar number (old 
trick in such cases - play with the numbers. Looking at the binary 
representation also often provides clues). Here the result indicates 
that you most likely have a short (16 bit) integer overflow. I can't 
tell you if this happens in your code, in Sun's Java code, in the C ZIP 
library use by Sun, or if this might even be a limitation of the ZIP 
file format.

/Thomas



== 2 of 2 ==
Date:   Wed,   Nov 10 2004 3:13 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Thomas Weidenfeller wrote:

> I can't
> tell you if this happens in your code, in Sun's Java code, in the C ZIP
> library use by Sun, or if this might even be a limitation of the ZIP
> file format.

It's a limit of the ZIP file format.  The bug-report link that Real posted has
some more detail.

    -- chris






==========================================================================
TOPIC: Few beginner questions,pls help
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34bf858415de0785
==========================================================================

== 1 of 4 ==
Date:   Wed,   Nov 10 2004 2:28 am
From: [EMAIL PROTECTED] (onTilt) 

Hi,
I have few questions and doubts,so please help:

Is it true that Runtime class holds runtime information on all
objects?

Is it true that a subclass has more,  or equal amount of functionality
when compared to its superclass?

When i am checking two objects for equality, what are four
characteristics that i must check?

I am not clear about the difference between copying and cloning,is
there any difference at all? if so,  is there a risk when cloning?





== 2 of 4 ==
Date:   Wed,   Nov 10 2004 2:53 am
From: "dingo" <[EMAIL PROTECTED]> 

Sounds like you want us to do your homework

"onTilt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
> I have few questions and doubts,so please help:
>
> Is it true that Runtime class holds runtime information on all
> objects?
>
> Is it true that a subclass has more,  or equal amount of functionality
> when compared to its superclass?
>
> When i am checking two objects for equality, what are four
> characteristics that i must check?
>
> I am not clear about the difference between copying and cloning,is
> there any difference at all? if so,  is there a risk when cloning?
>
>





== 3 of 4 ==
Date:   Wed,   Nov 10 2004 3:01 am
From: Thomas Weidenfeller <[EMAIL PROTECTED]> 

onTilt wrote:
> Hi,
> I have few questions and doubts,so please help:

Unfortunately, I have my doubts, too. This looks very much like 
homework. So please, if this is homework, don't ask here. We don't do 
homework. Ask your teacher, tutor, or professor for help, and consult 
your textbooks and course notes.

In case this isn't homework, please consider to provide us with some 
more background information, e.g. which concrete problem you try to solve.

/Thomas



== 4 of 4 ==
Date:   Wed,   Nov 10 2004 3:00 am
From: Andrew Thompson <[EMAIL PROTECTED]> 

On Wed, 10 Nov 2004 10:28:45 GMT, onTilt wrote:

> sub: Few beginner questions,pls help

Beginner questions are better dealt with on a 
different group described here..
<http://www.physci.org/codes/javafaq.jsp#cljh>

-- 
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: 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 3:00 am
From: "Andy Fish" <[EMAIL PROTECTED]> 

Hi,

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?

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.

TIA

Andy





== 2 of 2 ==
Date:   Wed,   Nov 10 2004 3:27 am
From: "Chris Uppal" <[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.

    -- chris






==========================================================================
TOPIC: tomcat vs. resin
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/86085f5203580e61
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 3:10 am
From: [EMAIL PROTECTED] (hiwa) 

"Ryan" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> has anyone used both of these? anyone have opinions of how they compare?

1)For different encodings handling, Resin is smart and Tomcat is
inflexible. Tomcat is good if everything is UTF-8.

2)For servlets and related classes, you store only source files on
Resin. Compile/recompile is done automatically. Quite handy.

3)Resin can be used as a stand-alone full server. Tomcat usually needs
Apache.

4)Resin mailing-list is adequate in its traffic. Tomcat is quite
overwhelming and your post does not always get good answer. Too many
newbies there!

5)If you are a paid customer of Resin, you can get full support from
Resin tech staff. License fee is cheap.

6)Resin dev lead Scott is a nice guy and very knowledgeable about Web
app technology in general. You can get good answers from him on their
mailing-list.

7)Resin configuration and deployment is much simpler than Tomcat.
Tomcat is unclear about the root responsibility of dev staff. Their
file set is quite messy.




==========================================================================
TOPIC: Does Tomcat support multi-CPUs?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d4853dfb94cefa18
==========================================================================

== 1 of 2 ==
Date:   Wed,   Nov 10 2004 3:17 am
From: "David" <[EMAIL PROTECTED]> 

Does Tomcat (4.x or 5.x) support multi-CPUs?

thanks,
david





== 2 of 2 ==
Date:   Wed,   Nov 10 2004 4:03 am
From: "Andy Flowers" <[EMAIL PROTECTED]> 

Off the top of my head I'd say that is not a Tomcat issue, rather it's a JVM 
issue.

Tomcat runs in the context of a JVM, so if the JVM support a single 
processor then that's all that Tomcat can use. If the JVM supports multiple 
then it may spread the load.

Tomcat as itself is multi threaded so if the JVM supports multi processors 
then it might use them, but it's JVM dependant.

It might be worth taking a look at the JVM docs to see what they say about 
multi processor usage

"David" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Does Tomcat (4.x or 5.x) support multi-CPUs?
>
> thanks,
> david
>
> 






==========================================================================
TOPIC: who uses algorithms learned in cs studies?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/640d2fa7355d4dcf
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 2:19 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

bebop o'saurus wrote:

> 1) does anybody here use (in their everyday java coding gigs) any of the
> algorithms they were taught in their cs classes?

I -- and everyone else -- use them all the time.

What's rarer is to have to /code/ any of the basic algorithms.  As other people
have noted some of the most useful and popular algorithms are already packaged
for us in standard libraries (in one language or another).  But still, I don't
think it's possible to make use even of pre-packaged algorithms unless you know
roughly what they do, and (more importantly) /why/ they do it that way.

Actually, there isn't a fixed set of "algorithms" -- for almost any real
problem there are many many published algorithms with different
time/space/complexity tradeoffs, and it's rarely possible to put a finger on
one of them as say "this is the best".  And of course, new algorithms are
invented all the time.  Sometimes you will have to invent your own algorithms,
that's fun to do if you are up to the task.  You are much less likely to make a
complete balls-up of it if you've had some practise with the algorithms they
teach in CS.

Thinking in algorithms is completely central to programming.  So much so that
you often don't realise that you are doing it at all.

    -- chris







==========================================================================
TOPIC: Implicit object creation
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ea9ee9cb601f58c
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 1:22 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

Hal Rosser wrote:

> That's the good thing about it - you don't need to know - its taken care
> of by the jvm

Agreed.  But I think it's worth adding that most GC implementations are
specifically optimised to handle short-lived garbage (such as the temporary
object in the OP's post) efficiently.

    -- chris






==========================================================================
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 1:16 am
From: "Chris Uppal" <[EMAIL PROTECTED]> 

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 ?

> 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 ?

(BTW I don't think finalisation is likely to be at all appropriate as a
solution to the OP's problem.)

    -- chris








==========================================================================
TOPIC: MIDlet Design Question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/45f298001caa915e
==========================================================================

== 1 of 1 ==
Date:   Wed,   Nov 10 2004 12:19 am
From: "Darryl L. Pierce" <[EMAIL PROTECTED]> 

Rhino wrote:

>  if (label.equals(CANCEL_INSERT_TEXT)) {
>   System.out.println(CLASS_NAME + "." + METHOD_NAME + " - User chose " +
> CANCEL_INSERT_TEXT + ".");
>   String msg = "Insert Cancelled.";
>   Alert cancelled = new Alert("Action", msg, null, AlertType.INFO);
>   cancelled.setTimeout(5000); //milliseconds
>   display.setCurrent(cancelled);
>   return;
>   }

Uh uh. Your should be calling the form of setCurrent() that takes both an
Alert *and* a Displayable. That tells the system what Displayable to show
*after* the Alert has expired or been dismissed. 

if(label.equals(CANCEL_INSERT_TEXT))
{
    Alert cancelled = new Alert("Action",msg,null,AlertType.INFO);
    cancelled.setTimeout(5000);
    Display.getDisplay(myMidlet).setCurrent(cancelled,theNextDisplayable);
}

-- 
/**
 * @author Darryl L. Pierce <[EMAIL PROTECTED]>
 * @see    The Infobahn Offramp <http://mcpierce.multiply.com>
 * @quote  "Lobby, lobby, lobby, lobby, lobby, lobby..." - Adrian Monk
 */



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

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 

Reply via email to