Jim Lang

Greenhorn
+ Follow
since Oct 04, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jim Lang

This is a simplified version of another set of classes - and in the larger set of classes C is a class that implements the Iterator interface. It's ok to have 'class C<X> implements Iterator<E>' and the compiler is also happy for me to omit the '<X>' - which seems to be sufficient from the point of view of satisfying the Iterator type-safety part, and for the class to rely on the generic identifiers from the outer class.

Then there's the purist in me that thinks that I should always be enforcing the type of C in any case. On the other hand, it doesn't matter so much because that's a private inner class that can only be instantiated by the outer class, so as long as I make sure that the outer class doesn't abuse the lack of type checking in the inner class it's all hunky-dory.

Perhaps I'm just being upended by feeling the need to add generics everywhere because it's a new feature (to me at least). The most important thing for me is getting used to when I should use these new features, and when I shouldn't. Perhaps in this case, as you sensibly suggest for class C, I just shouldn't declare the type parameter.
14 years ago
Dear ranchers,

This is a bit of a painful one, since I know that Java 5 does not permit the construction of generic arrays. It seems strange that this is not permitted since to implement collection classes using arrays would be a natural thing to do.

Fair enough, I see it's not a proper type to create an array with, and I can see that generics are only doing their thing at compile-time (so this might cause problems for runtime type-checking) but shouldn't there be some sort of way to do this using 'nice' java?

Can anyone suggest a way to do this that isn't a nasty hack (or an only mildly nasty hack if there's no nice way to do it)?

Many thanks - Jim
14 years ago
If I use this listing as an example it should illustrate what I meant in my last post:

What bugs me is providing '<X>' to class C when it's never even used. Or can I omit it because it's never used (as in above listing)? Is there anythign wrong with this approach from a type-safety point of view (I don't think so, but then I'm only getting to know generics)

Honestly, Java becomes more like C++ with every new release.
14 years ago
Thanks for your help - I hadn't tried just changing the one identifier attached to class C. However, the problem now that I'm trying to get my head around is that when you use a different identifer for the generic identifier in class C, and leave the rest of the class as it was, I can't see how you can then instantiate C while enforcing the type-safety, since the type you now pass to C is never used anywhere within C.

Or is that kind of redundancy ok, since I'm implementing it as an inner class?
[ March 23, 2007: Message edited by: Jim Lang ]
14 years ago
Dear ranchers,

I've been a diehard Java 1.4 programmer for a fair while, but I'm trying to catch up now - and I've got a problem with using generics and inner classes together.

Consider the following simplified example:

The message the compiler spits out is:

I can see that the generic identifier 'E' used by class C masks the generic identifier 'E' used by class A, but I can't see a way round this - even if I change the generic identifier 'E' used by class C to some other identifier the compiler still complains.

Can anyone shed some light on how I can get around this problem, but still use inner classes and generics

Many thanks,
Jim

(edited because I was mixing up the term varargs with the term generics, so fixed it)
[ March 23, 2007: Message edited by: Jim Lang ]
14 years ago
Hi y'all
I've been reading through some shell scripts and what I see as the first line differs. In some cases I know why.
For example, a shell script may start:

which is fine, I know it's an indicator to the executing shell which shell to use as the command interpreter.
However, sometimes I come across scripts where the first line starts:

but I'm not sure why...
Can someone please enlighten me?
Thanks,
Jim
18 years ago
I have also heard the old 'don't use Exceptions for flow control' argument, which I can't say I understand, since the try..catch..finally block is there for a form of flow control anyway.
If anyone can explain the reasons for that caveat to me I would appreciate it.
Besides that I suppose I will go with the Object return type, although I feel that it definitely is not the most 'OO' solution. I would prefer the solution to include specific exceptions, but to preserve flexibility and to make sure that the interface does not change in future versions (only the javadoc changes) I shall opt for the former.
18 years ago
Hi all,
I couldn't decide where to post this so I posted it here...
I am looking at implementing an API in java, for java clients to connect to remote services, and there is a fundamental design decision that I am trying to resolve.
The question is whether it is better to implement the various different parts of the api with Exceptions to indicate particular errors, or to use a return type of 'Object' so that either an Integer containing an error code can be returned in the case of an error, or another specified collection/object in the case of success.
In the case of the former a client would be using a 'try/catch/finally' construct to deal with problems while for the latter problems would be dealt with in an 'if instanceof Integer... else...' kind of construct.
Can anyone advise me in this?
18 years ago
I am looking at log4j for use as a logging subsystem and have read the available docs. However, I want to use it to define multiple loggers - so that I can send different kinds of messages to different log files (DEBUG to a debug.log, INFO to an info.log, etc) from the same application. Another use would be to separate log files in a particular application by subject area - so database-related logging goes to a db.log, jndi-related logging to a jndi.log, etc.
Can anyone tell me whether this kind of functionality is already built into log4j ? I can write a related set of classes to do this for me but want to avoid re-inventing it if it's already a feature.
19 years ago
If I want to deploy my EJB-based web app in WLS 6.1, fine, I can do it.
However, on the basis that we have the licences, if I want to deploy a jar file for a client-based app that includes the files necessary for connection to the EJBs provided, is there a ready-made jar file that I can distribute which includes the Weblogic classes (eg.InitialContext etc etc), along with the necessary EJB stubs?
Surely the weblogic.jar file is too huge to distribute to the client machines as part of a client install...
19 years ago
Can anyone tell me what the differences between Dreamweaver and Dreamweaver UltraDev are? Are they the same?
I've been trying connections between versions and I've found that 6.0 to 5.1 won't work (no backward compatibility there).
Has anyone tried connecting from 6.1 to 6.0 ? Does backward compatibility exist for those?
The connections I'm making are between clients (using weblogicaux.jar from one version) and EJBs (using weblogicaux.jar from the other).
[This message has been edited by Jim Lang (edited October 17, 2001).]
19 years ago
So I tried a practical example, and used the following lines:

However, that only gives me a way to output the input stream to the subprocess. How can I capture the output stream of the executed subprocess? Is this possible?
[This message has been edited by Jim Lang (edited October 13, 2001).]
19 years ago
It's all very well posturing and beating your chest about how the US will go to war with all terrorists and those that protect them but the obvious problem with terrorists, as with guerilla warfare, is that there is no visible enemy. And it is most probably nigh on impossible to provide the sort of proof of someone like Bin Laden's involvement that would vindicate the absolute support of countries like Pakistan. As so many other countries have had to do in the past it seems to me that angry US citizens should try to accept that being the victim of terrorism is not something that can easily be fought through the use of conventional firepower. Terrorism on US soil from a foreign quarter is not something that US citizens are accustomed to, but when grief gives rise to an immediate call for retaliation it should be tempered with the knowledge that retaliation against an unknown foe can only be a blind alley. After all it is only reasonable to respond with such devastating firepower as has been suggested by some of the members of this board if there is incontrovertible proof to support it. The apparent 'war on terrorism' is pure rhetoric and makes little sense (because the enemy is unseen) whereas to confront the causes of the hatred and terrorism makes more constructive sense.
To pronounce all-out war on particular middle eastern nations will only turn more innocent people against the west, in the long run creating another generation of potential enemies. Violence is truly a vicious circle, and condoning the inevitable targeting of more innocent people in retaliation is wrong, whatever your background or creed.
Maybe I am stating the obvious here but man's continued inhumanity to his/her fellow man never fails to amaze me. The terrible acts of terrorism perpetrated this week are awful and all those affected have my absolute sympathies. But unless the real perpetrators can be rooted out there is no point in pointing fingers at other groups (including members of this board) in what appears to me to be an unthinking kneejerk reaction.
19 years ago
I just saw a very scary interview on BBC TV news with a representative of British Moslem youth. He was declaring that Moslems in his experience considered themselves to be Moslems who happened to have been raised in and who were living in England, rather than being British. hmm...
He then started quoting the Koran, a part that states that an attack on another Moslem is considered to be an attack on all Moslems. He gave an example as an attack on Bin Laden as being unacceptable as it would be equivalent to an attack on Moslems everywhere.
When asked by Jon Snow about the Moslems that died in the attack on the WTC he couldn't answer.
When asked another question he started blaming Western foreign policy for all the current troubles. There was no trace of any sympathy in his attitude throughout the interview.
I can't believe that someone could be given airtime to come out with such inflammatory comments and attitude.
19 years ago