Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using JDK 5 lib with 1.4 application

 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm about to use a 3rd party library that makes use of JDK 5 features (like annotations and typed collections). The application I have to develop must use JDK 1.4. Do I have to expect any problems? I'm thinking of something like a method returning a List<String> but I assign the return to an 1.4-style List? The library's documentation says that one needs JDK 1.3 or above to use it, but the documentation isn't that good anyway.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Java1.4 in your application then you wont be able to use 3rd party libraries that are compiled using Java5
 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone confirm this?
 
Gavin Tranter
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could be wrong but I dont see how the JDK 1.4 Javac can begin to understand the "new" features of 1.5, annatations it might ignore, but generics (List<String> its just not going to have a clue about.

You coudl easierly test by creating a small library using 1.5 language features and see if 1.4 handles it, as I said, i dont think it will, but could be wrong.
It is total possible to take JAR's from different versions of JDK's and use them in older versions. However Generics isint a library, its a language feature which needs Javac support, so any libraries/JAR that relie on a new language feature arent going to work. (at least thats my view)

I would (try) find a JDK 1.4 version, of the library you need.

G

[ April 16, 2007: Message edited by: Gavin Tranter ]
[ April 16, 2007: Message edited by: Gavin Tranter ]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Out of the box, it will not work. The library may be amenable to a treatment of Retroweaver, which would create a Java 1.4-compatible version - if its license allows that.
 
Mike Himstead
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I took the sample application provided with the library and took a look. It used annotations to suppress warnings regarding unchecked conversions of collections. I had to remove the annotations, of course.

Then I changed some stuff concerning the typed collections and the new for-loop to make it (the sample application!) 1.4-compatible. I do get a 1.4-collection I have to treat the old-fashioned way when looping through it (casting), but I do get a List. To be more specific: the API says that getHTMLReport() returns List<String> and I do


The list is "okay" and I can loop through it. Unfortenately, I do get an error later on which is most probably unrelated to the JDK version.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic