File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

eclipse 3.1, java 5

 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i just migrated some code to eclipse 3.1 and configured it to java 5; ever since i get these yellow warnings.
eg:
QUOTE]
The serializable class EncontraContratoException does not declare a static final serialVersionUID field of type long

How can i get rid of them?

TiA
 
Steven Bell
Ranch Hand
Posts: 1071
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a 'final static long serialVersionUID' to your class.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, Steven

i found that in /properties for proj/enable project specific settings/potential programming problems/ i can tune warnings.

but i wonder why should i code that line: is it java5 specific?
May it generate problems if i dont?

TiA
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See http://www.prevayler.org/wiki.jsp?topic=serialVersionUID
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not 1.5 specific but in the past didn't generate a compiler warning.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i migrated my code to eclipse 3.1 but i'm not yet prepared to change it to java5

i have douzens of msgs like:
Type safety: The method iterator() belongs to the raw type Set. References to generic type Set<E> should be parameterized

i'd like to know if i could turn off those msgs while i keep working, ( eventually turning them on again when having those features understood), and if that turning off would be safe.

It's not 1.5 specific but in the past didn't generate a compiler warning.

maybe i'm not aware of those compile msgs because eclipse hiddes that from me;

but when i use command line to compile several files previously written with 1.4, java5 often tells me to recompile with -Xlint and then i see warnings, mostly (if all) about using deprecated stuff
 
Steven Bell
Ranch Hand
Posts: 1071
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can tell eclipse to use the 1.4 compiler. I'm not sure if you can turn off the warnings with the 1.5 compiler.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i disabled those above mentioned warnings inside eclipse, using java5

from command line i can see:
prompt>javac -cp . logica/ActoMedico.java
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
prompt>javac -Xlint -cp . logica/ActoMedico.java
logica/ActoMedico.java:28: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.ut
.Set
tecnicas.add(tecnica);
^
1 warning

 
Steven Bell
Ranch Hand
Posts: 1071
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's giving you warnings about using collections without using generics. These won't go away unless you find some way to disable them in eclipse, or start using generics.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These won't go away unless you find some way to disable them in eclipse

yes, i already described how to

One Q:
can i use java5 iterator (blabla b : bla)without generics or all this new java5 stuff?
(i tried without success...)

TiA
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by miguel lisboa:

yes, i already described how to

One Q:
can i use java5 iterator (blabla b : bla)without generics or all this new java5 stuff?
(i tried without success...)

TiA

The java 5 iterator uses generics by definition, which explains the lack of success.
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by miguel lisboa:


One Q:
can i use java5 iterator (blabla b : bla)without generics or all this new java5 stuff?
(i tried without success...)

TiA


Perhaps I am not understanding what you are asking. I think you are asking if you can compile/run with java 5 and use the only the new for loop construct; that is, with raw collections (that don't use generic features). You can do this:

import java.util.ArrayList;


Since you're not using generics you need to cast the objects if you need them as Integer (or whatever object type you are using).
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be nice to know how to teach Eclipse understand Java 1.5 syntax. It's screwing my sources very badly.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic