| Author |
Generics and jar files
|
Luke Murphy
Ranch Hand
Joined: May 12, 2010
Posts: 299
|
|
Hi,
I have a parameterised class in one jar file which is invoked by classes outside that jar file.
When I make calls to this class and treat like it is parameterised, it won't compile. The client does not recognise the parameterisation of the classes it invokes.
Calls to the parameterised class within the same jar file are fine but from outside the jar file don't work.
Any ideas?
|
 |
Stephan van Hulst
Bartender
Joined: Sep 20, 2010
Posts: 3065
|
|
|
Care to post your error messages?
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3860
|
|
|
The obvious thing that springs to mind is that there might be another version of the class (possibly non-generic) somewhere on the classpath that's being used instead.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
Is the client project configured to use the same Java version?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Luke Murphy
Ranch Hand
Joined: May 12, 2010
Posts: 299
|
|
Rob Prime wrote:Is the client project configured to use the same Java version?
This must be some annoying / config issue.
But let me just clarify the concepts... generification happes pre compile so there is no change in the byte code.
Therefore, the jar file with the generifed classes is the exact same as the jar with no generified classes? Correct?
So when the client uses the generified jar file, how does it know it is permissable to use parameterised references to generified classes in the jar file?
If it can't get information about generification from byte code where does it get it from?
Error from my IDE is:
The type Rel is not generic; it cannot be parameterized with arguments <blah>
Rel is a class which I have generified.
java compiler level is 1.5
|
 |
Luke Murphy
Ranch Hand
Joined: May 12, 2010
Posts: 299
|
|
Luke Murphy wrote:
Rob Prime wrote:Is the client project configured to use the same Java version?
This must be some annoying / config issue.
But let me just clarify the concepts... generification happes pre compile so there is no change in the byte code.
Therefore, the jar file with the generifed classes is the exact same as the jar with no generified classes? Correct?
So when the client uses the generified jar file, how does it know it is permissable to use parameterised references to generified classes in the jar file?
If it can't get information about generification from byte code where does it get it from?
Error from my IDE is:
The type Rel is not generic; it cannot be parameterized with arguments <blah>
Rel is a class which I have generified.
java compiler level is 1.5
I found the problem. My jar was obfuscated.
Thanks to all for the help here.
|
 |
 |
|
|
subject: Generics and jar files
|
|
|