This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Generics and jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Generics and jar files" Watch "Generics and jar files" New topic
Author

Generics and jar files

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
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: 3391
    
    9
Care to post your error messages?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4244
    
    7

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: 19552
    
  16

Is the client project configured to use the same Java version?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
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: 300
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics and jar files
 
Similar Threads
NICE = java++ ?
how to get file path
View direct through a web service question
Help launching an applet created in Netbeans environment
read properties file from jar